diff options
author | Kloenk <kloenk@kloenk.de> | 2019-10-18 21:04:08 +0200 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2019-11-24 18:52:52 +0100 |
commit | eee6ae33e874912c8ec218c8ac1eeef89afd85d2 (patch) | |
tree | 638ce7cc8211c30abbffc85a1d4ac082b4a45f8b /modules/services/spotifyd.nix | |
parent | b1dd373f5ad3fd3f5e727ff9be72c76c2f7919fa (diff) |
spotifyd: add module
Diffstat (limited to 'modules/services/spotifyd.nix')
-rw-r--r-- | modules/services/spotifyd.nix | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/modules/services/spotifyd.nix b/modules/services/spotifyd.nix new file mode 100644 index 00000000000..831b3bdb710 --- /dev/null +++ b/modules/services/spotifyd.nix @@ -0,0 +1,53 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.spotifyd; + + configFile = pkgs.writeText "spotifyd.conf" '' + ${generators.toINI {} cfg.settings} + ''; + +in + +{ + options.services.spotifyd = { + enable = mkEnableOption "SpotifyD connect"; + + settings = mkOption { + type = types.attrsOf (types.attrsOf types.str); + default = {}; + description = "Configuration for spotifyd"; + example = literalExample '' + { + global = { + user = "Alex"; + password = "foo"; + device_name = "nix"; + }; + } + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.spotifyd ]; + + systemd.user.services.spotifyd = { + Unit = { + Description = "spotify daemon"; + Documentation = "https://github.com/Spotifyd/spotifyd"; + }; + + Install.WantedBy = [ "default.target" ]; + + Service = { + ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --config ${configFile}"; + Restart = "always"; + RestartSec = 12; + }; + }; + }; +} |