at 25.11-pre 1.2 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 inherit (lib) 10 mkEnableOption 11 mkIf 12 mkOption 13 optionalString 14 types 15 ; 16 17 dataDir = "/var/lib/squeezelite"; 18 cfg = config.services.squeezelite; 19 pkg = if cfg.pulseAudio then pkgs.squeezelite-pulse else pkgs.squeezelite; 20 bin = "${pkg}/bin/${pkg.pname}"; 21 22in 23{ 24 25 ###### interface 26 27 options.services.squeezelite = { 28 enable = mkEnableOption "Squeezelite, a software Squeezebox emulator"; 29 30 pulseAudio = mkEnableOption "pulseaudio support"; 31 32 extraArguments = mkOption { 33 default = ""; 34 type = types.str; 35 description = '' 36 Additional command line arguments to pass to Squeezelite. 37 ''; 38 }; 39 }; 40 41 ###### implementation 42 43 config = mkIf cfg.enable { 44 systemd.services.squeezelite = { 45 wantedBy = [ "multi-user.target" ]; 46 after = [ 47 "network.target" 48 "sound.target" 49 ]; 50 description = "Software Squeezebox emulator"; 51 serviceConfig = { 52 DynamicUser = true; 53 ExecStart = "${bin} -N ${dataDir}/player-name ${cfg.extraArguments}"; 54 StateDirectory = builtins.baseNameOf dataDir; 55 SupplementaryGroups = "audio"; 56 }; 57 }; 58 }; 59}