From ccdf386a971362e49e3bde750657ec88d1f30704 Mon Sep 17 00:00:00 2001 From: Phil Wetzel Date: Sat, 11 Jun 2016 08:46:02 -0400 Subject: [PATCH] squeezelite service: init --- nixos/modules/misc/ids.nix | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/audio/squeezelite.nix | 67 ++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 nixos/modules/services/audio/squeezelite.nix diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index d421167c859c..4cf76610c031 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -269,6 +269,7 @@ nzbget = 245; mosquitto = 246; toxvpn = 247; + squeezelite = 248; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -508,6 +509,7 @@ nzbget = 245; mosquitto = 246; #toxvpn = 247; # unused + #squeezelite = 248; #unused # When adding a gid, make sure it doesn't match an existing # uid. Users and groups with the same name should have equal diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 7d93801dbe1f..cda9acf0dda8 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -110,6 +110,7 @@ ./services/audio/liquidsoap.nix ./services/audio/mpd.nix ./services/audio/mopidy.nix + ./services/audio/squeezelite.nix ./services/backup/almir.nix ./services/backup/bacula.nix ./services/backup/crashplan.nix diff --git a/nixos/modules/services/audio/squeezelite.nix b/nixos/modules/services/audio/squeezelite.nix new file mode 100644 index 000000000000..f1a60be992d8 --- /dev/null +++ b/nixos/modules/services/audio/squeezelite.nix @@ -0,0 +1,67 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + uid = config.ids.uids.squeezelite; + cfg = config.services.squeezelite; + +in { + + ###### interface + + options = { + + services.squeezelite= { + + enable = mkEnableOption "Squeezelite, a software Squeezebox emulator"; + + dataDir = mkOption { + default = "/var/lib/squeezelite"; + type = types.str; + description = '' + The directory where Squeezelite stores its name file. + ''; + }; + + extraArguments = mkOption { + default = ""; + type = types.str; + description = '' + Additional command line arguments to pass to Squeezelite. + ''; + }; + + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + systemd.services.squeezelite= { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" "sound.target" ]; + description = "Software Squeezebox emulator"; + preStart = "mkdir -p ${cfg.dataDir} && chown -R squeezelite ${cfg.dataDir}"; + serviceConfig = { + ExecStart = "${pkgs.squeezelite}/bin/squeezelite -N ${cfg.dataDir}/player-name ${cfg.extraArguments}"; + User = "squeezelite"; + PermissionsStartOnly = true; + }; + }; + + users.extraUsers.squeezelite= { + inherit uid; + group = "nogroup"; + extraGroups = [ "audio" ]; + description = "Squeezelite user"; + home = "${cfg.dataDir}"; + }; + + }; + +}