1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00
home-manager/modules/services/listenbrainz-mpd.nix

56 lines
1.5 KiB
Nix
Raw Normal View History

2023-03-14 10:22:09 +01:00
{ config, lib, pkgs, ... }:
let
inherit (lib.options) mkEnableOption mkPackageOption mkOption;
2023-03-14 10:22:09 +01:00
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";
2023-03-14 10:22:09 +01:00
package = mkPackageOption pkgs "listenbrainz-mpd" { };
2023-03-14 10:22:09 +01:00
settings = mkOption {
type = tomlFormat.type;
default = { };
description = ''
2023-03-14 10:22:09 +01:00
Configuration for listenbrainz-mpd written to
{file}`$XDG_CONFIG_HOME/listenbrainz-mpd/config.toml`.
2023-03-14 10:22:09 +01:00
'';
2024-05-28 00:07:22 +02:00
example = { submission.token_file = "/run/secrets/listenbrainz-mpd"; };
2023-03-14 10:22:09 +01:00
};
};
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;
Type = if lib.versionAtLeast cfg.package.version "2.3.2" then
"notify"
else
"simple";
2023-03-14 10:22:09 +01:00
};
Install.WantedBy = [ "default.target" ];
};
xdg.configFile."listenbrainz-mpd/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "listenbrainz-mpd.toml" cfg.settings;
};
};
}