home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit da47ba87768ed1be3423d177a5f2414efc9b4adf
parent 240c852994d7e8215d8d06c021ff754deecf5d47
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Wed, 24 Oct 2018 19:28:37 +0200

modules: introduce modules (folder) and add shairport-sync modules…

… also adding it to shikoku.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mbase.nix | 2+-
Amodules/module-list.nix | 7+++++++
Amodules/services/shairport-sync.nix | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mshikoku.nix | 1+
4 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/base.nix b/base.nix @@ -3,7 +3,7 @@ let home_directory = builtins.getEnv "HOME"; in rec { - +imports = [ modules/module-list.nix ]; programs = { home-manager = { enable = true; diff --git a/modules/module-list.nix b/modules/module-list.nix @@ -0,0 +1,7 @@ +{ pkgs, lib, ... }: + +{ + imports = [ + ./services/shairport-sync.nix + ]; +} diff --git a/modules/services/shairport-sync.nix b/modules/services/shairport-sync.nix @@ -0,0 +1,72 @@ +{ 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 -j -o pa"; + description = '' + Arguments to pass to the daemon. Defaults to a local pulseaudio + server. + ''; + }; + + }; + + }; + + + ###### implementation + + config = mkIf config.services.shairport-sync.enable { + + /* + Requires the following in NixOS (or elsewhere). + + services.avahi.enable = true; + services.avahi.publish.enable = true; + services.avahi.publish.userServices = true; + networking.firewall.allowedUDPPortRanges = [ { from = 6001; to = 6101; } ]; + networking.firewall.allowedTCPPorts = [ 5000 ]; + */ + + systemd.user.services.shairport-sync = { + Unit = { + After = [ "network.target" "sound.target" ]; + Description = "Airplay audio player"; + }; + Install = { + WantedBy = [ "default.target" ]; + }; + Service = { + Environment = "PATH=${config.home.profileDirectory}/bin"; + ExecStart = "${pkgs.shairport-sync}/bin/shairport-sync ${cfg.arguments}"; + ExecStop = "${pkgs.procps}/bin/pkill shairport-sync"; + Type = "forking"; + }; + }; + }; +} diff --git a/shikoku.nix b/shikoku.nix @@ -28,4 +28,5 @@ virtmanager zoom-us ]; + services.shairport-sync.enable = true; }