summary refs log tree commit diff
path: root/nixos/modules/services/networking/shairport-sync.nix
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2015-11-27 02:44:56 +0100
committerFranz Pletz <fpletz@fnordicwalking.de>2015-12-12 20:30:47 +0100
commit6734127545570274acefbabd5c6259822f231a24 (patch)
tree5d6d6660293fc653ada9fbf865c12a0e4c9bebd7 /nixos/modules/services/networking/shairport-sync.nix
parent069b1891d34f2a1a674daf6baad02d73ab8228c6 (diff)
downloadnixpkgs-6734127545570274acefbabd5c6259822f231a24.tar
nixpkgs-6734127545570274acefbabd5c6259822f231a24.tar.gz
nixpkgs-6734127545570274acefbabd5c6259822f231a24.tar.bz2
nixpkgs-6734127545570274acefbabd5c6259822f231a24.tar.lz
nixpkgs-6734127545570274acefbabd5c6259822f231a24.tar.xz
nixpkgs-6734127545570274acefbabd5c6259822f231a24.tar.zst
nixpkgs-6734127545570274acefbabd5c6259822f231a24.zip
shairport-sync service: add module
Adds a new service module for shairport-sync. Tested with a local
and remote pulseaudio server. Needs to be run as a user in the pulse group
to access pulseaudio.
Diffstat (limited to 'nixos/modules/services/networking/shairport-sync.nix')
-rw-r--r--nixos/modules/services/networking/shairport-sync.nix80
1 files changed, 80 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/shairport-sync.nix b/nixos/modules/services/networking/shairport-sync.nix
new file mode 100644
index 00000000000..a523e66d09b
--- /dev/null
+++ b/nixos/modules/services/networking/shairport-sync.nix
@@ -0,0 +1,80 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+  cfg = config.services.shairport-sync;
+
+in
+
+{
+
+  ###### interface
+
+  options = {
+
+    services.shairport-sync = {
+
+      enable = mkOption {
+        default = false;
+        description = ''
+          Enable the shairport-sync daemon.
+
+          Running with a local system-wide or remote pulseaudio server
+          is recommended.
+        '';
+      };
+
+      arguments = mkOption {
+        default = "-v -o pulse";
+        description = ''
+          Arguments to pass to the daemon. Defaults to a local pulseaudio
+          server.
+        '';
+      };
+
+      user = mkOption {
+        default = "shairport";
+        description = ''
+          User account name under which to run shairport-sync. The account
+          will be created.
+        '';
+      };
+
+    };
+
+  };
+
+
+  ###### implementation
+
+  config = mkIf config.services.shairport-sync.enable {
+
+    services.avahi.enable = true;
+
+    users.extraUsers = singleton
+      { name = cfg.user;
+        description = "Shairport user";
+        isSystemUser = true;
+        createHome = true;
+        home = "/var/lib/shairport-sync";
+        extraGroups = [ "audio" ] ++ optional config.hardware.pulseaudio.enable "pulse";
+      };
+
+    systemd.services.shairport-sync =
+      {
+        description = "shairport-sync";
+        after = [ "network.target" "avahi-daemon.service" ];
+        wantedBy = [ "multi-user.target" ];
+        serviceConfig = {
+          User = cfg.user;
+          ExecStart = "${pkgs.shairport-sync}/bin/shairport-sync ${cfg.arguments}";
+        };
+      };
+
+    environment.systemPackages = [ pkgs.shairport-sync ];
+
+  };
+
+}