1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00
home-manager/modules/services/listenbrainz-mpd.nix
Austin Horstman 86402a17b6 treewide: flatten single file modules
Some files don't need nesting and can be root level again to reduce
conflicts with other PRs.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-06-23 16:20:26 -05:00

60 lines
1.5 KiB
Nix

{
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" { nullable = true; };
settings = mkOption {
type = tomlFormat.type;
default = { };
description = ''
Configuration for listenbrainz-mpd written to
{file}`$XDG_CONFIG_HOME/listenbrainz-mpd/config.toml`.
'';
example = {
submission.token_file = "/run/secrets/listenbrainz-mpd";
};
};
};
config = mkIf cfg.enable {
systemd.user.services."listenbrainz-mpd" = lib.mkIf (cfg.package != null) {
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";
};
Install.WantedBy = [ "default.target" ];
};
xdg.configFile."listenbrainz-mpd/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "listenbrainz-mpd.toml" cfg.settings;
};
};
}