fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . spotifyd ; 8 9tomlFormat = pkgs . formats . toml { }; 10 11configFile = tomlFormat . generate "spotifyd.conf" cfg . settings ; 12 13in { 14options . services . spotifyd = { 15enable = mkEnableOption "SpotifyD connect" ; 16 17package = mkOption { 18type = types . package ; 19default = pkgs . spotifyd ; 20defaultText = literalExpression "pkgs.spotifyd" ; 21example = 22literalExpression "(pkgs.spotifyd.override { withKeyring = true; })" ; 23description = '' 24The `spotifyd` package to use. 25Can be used to specify extensions. 26'' ; 27}; 28 29settings = mkOption { 30type = tomlFormat . type ; 31default = { }; 32description = "Configuration for spotifyd" ; 33example = literalExpression '' 34{ 35global = { 36username = "Alex"; 37password = "foo"; 38device_name = "nix"; 39}; 40} 41'' ; 42}; 43}; 44 45config = mkIf cfg . enable { 46assertions = [ 47( lib . hm . assertions . assertPlatform "services.spotifyd" pkgs 48lib . platforms . linux ) 49]; 50 51home . packages = [ cfg . package ]; 52 53systemd . user . services . spotifyd = { 54Unit = { 55Description = "spotify daemon" ; 56Documentation = "https://github.com/Spotifyd/spotifyd" ; 57}; 58 59Install . WantedBy = [ "default.target" ]; 60 61Service = { 62ExecStart = 63" ${ cfg . package } /bin/spotifyd --no-daemon --config-path ${ configFile } " ; 64Restart = "always" ; 65RestartSec = 12 ; 66}; 67}; 68}; 69}