1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/modules/spotifyd.nix

65 lines
1.8 KiB
Nix
Raw Permalink Normal View History

2022-03-10 21:52:12 +01:00
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.spotifyd;
toml = pkgs.formats.toml {};
2022-03-10 21:52:12 +01:00
spotifydConf =
if cfg.settings != {}
then toml.generate "spotify.conf" cfg.settings
else pkgs.writeText "spotifyd.conf" cfg.config;
in {
options = {
services.spotifyd = {
enable = mkEnableOption "spotifyd, a Spotify playing daemon";
config = mkOption {
default = "";
type = types.lines;
description = ''
(Deprecated) Configuration for Spotifyd. For syntax and directives, see
<link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
'';
};
settings = mkOption {
default = {};
type = toml.type;
description = ''
Configuration for Spotifyd. For syntax and directives, see
<link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = (cfg.config == "" && cfg.settings != {}) || (cfg.config != "" && cfg.settings == {});
message = "Using the stringly typed .config attribute is discouraged. Use the TOML typed .settings attribute instead.";
}
];
systemd.services.spotifyd = {
2022-03-10 21:52:12 +01:00
wantedBy = ["multi-user.target"];
after = ["network-online.target" "sound.target"];
description = "spotifyd, a Spotify playing daemon";
environment.SHELL = "/bin/sh";
serviceConfig = {
ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --cache-path /var/cache/spotifyd --config-path ${spotifydConf}";
Restart = "always";
RestartSec = 12;
DynamicUser = true;
CacheDirectory = "spotifyd";
SupplementaryGroups = ["audio"];
};
};
};
2022-03-10 21:52:12 +01:00
meta.maintainers = [maintainers.anderslundstedt];
}