summary refs log tree commit diff
path: root/nixos/modules/services/audio/squeezelite.nix
blob: 05506f5bcc7ace2f97bfe88ed6a0d350bee5388e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ config, lib, pkgs, ... }:

with lib;

let
  dataDir = "/var/lib/squeezelite";
  cfg = config.services.squeezelite;

in {

  ###### interface

  options = {

    services.squeezelite= {

      enable = mkEnableOption "Squeezelite, a software Squeezebox emulator";

      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";
      serviceConfig = {
        DynamicUser = true;
        ExecStart = "${pkgs.squeezelite}/bin/squeezelite -N ${dataDir}/player-name ${cfg.extraArguments}";
        StateDirectory = builtins.baseNameOf dataDir;
        SupplementaryGroups = "audio";
      };
    };

  };

}