listenbrainz-mpd: add module

This commit is contained in:
Sefa Eyeoglu 2023-03-14 10:22:09 +01:00 committed by Robert Helgesson
parent e386ec640e
commit e60080ddfb
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 62 additions and 0 deletions

2
.github/CODEOWNERS vendored
View file

@ -440,6 +440,8 @@ Makefile @thiagokokada
/modules/services/lieer.nix @tadfisher
/modules/services/listenbrainz-mpd.nix @Scrumplex
/modules/services/lorri.nix @Gerschtli
/modules/services/mako.nix @onny

View file

@ -948,6 +948,14 @@ in
'programs.i3status-rust.package' to an older version.
'';
}
{
time = "2023-03-22T07:20:00+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.listenbrainz-mpd'.
'';
}
];
};
}

View file

@ -243,6 +243,7 @@ let
./services/keybase.nix
./services/keynav.nix
./services/lieer.nix
./services/listenbrainz-mpd.nix
./services/lorri.nix
./services/mako.nix
./services/mbsync.nix

View file

@ -0,0 +1,51 @@
{ config, lib, pkgs, ... }:
let
inherit (lib.options) mkEnableOption mkPackageOption mkOption;
inherit (lib.modules) mkIf;
cfg = config.services.listenbrainz-mpd;
tomlFormat = pkgs.formats.toml { };
in {
meta.maintainers = [ lib.maintainers.Scrumplex ];
options.services.listenbrainz-mpd = {
enable = mkEnableOption "listenbrainz-mpd";
package = mkPackageOption pkgs "listenbrainz-mpd" { };
settings = mkOption {
type = tomlFormat.type;
default = { };
description = ''
Configuration for listenbrainz-mpd written to
<filename>$XDG_CONFIG_HOME/listenbrainz-mpd/config.toml</filename>.
'';
example = { submission.tokenFile = "/run/secrets/listenbrainz-mpd"; };
};
};
config = mkIf cfg.enable {
systemd.user.services."listenbrainz-mpd" = {
Unit = {
Description = "ListenBrainz submission client for MPD";
Documentation = "https://codeberg.org/elomatreb/listenbrainz-mpd";
After = [ "mpd.service" ];
Requires = [ "mpd.service" ];
};
Service = {
ExecStart = "${cfg.package}/bin/listenbrainz-mpd";
Restart = "always";
RestartSec = 5;
};
Install.WantedBy = [ "default.target" ];
};
xdg.configFile."listenbrainz-mpd/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "listenbrainz-mpd.toml" cfg.settings;
};
};
}