python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / nixos / modules / services / audio / liquidsoap.nix
blobc313104c46096c9676386d2b7a1d3981fc10ec81
1 { config, lib, pkgs, ... }:
3 with lib;
5 let
6   streams = builtins.attrNames config.services.liquidsoap.streams;
8   streamService =
9     name:
10     let stream = builtins.getAttr name config.services.liquidsoap.streams; in
11     { inherit name;
12       value = {
13         after = [ "network-online.target" "sound.target" ];
14         description = "${name} liquidsoap stream";
15         wantedBy = [ "multi-user.target" ];
16         path = [ pkgs.wget ];
17         serviceConfig = {
18           ExecStart = "${pkgs.liquidsoap}/bin/liquidsoap ${stream}";
19           User = "liquidsoap";
20           LogsDirectory = "liquidsoap";
21         };
22       };
23     };
27   ##### interface
29   options = {
31     services.liquidsoap.streams = mkOption {
33       description =
34         lib.mdDoc ''
35           Set of Liquidsoap streams to start,
36           one systemd service per stream.
37         '';
39       default = {};
41       example = {
42         myStream1 = "/etc/liquidsoap/myStream1.liq";
43         myStream2 = literalExpression "./myStream2.liq";
44         myStream3 = "out(playlist(\"/srv/music/\"))";
45       };
47       type = types.attrsOf (types.either types.path types.str);
48     };
50   };
51   ##### implementation
53   config = mkIf (builtins.length streams != 0) {
55     users.users.liquidsoap = {
56       uid = config.ids.uids.liquidsoap;
57       group = "liquidsoap";
58       extraGroups = [ "audio" ];
59       description = "Liquidsoap streaming user";
60       home = "/var/lib/liquidsoap";
61       createHome = true;
62     };
64     users.groups.liquidsoap.gid = config.ids.gids.liquidsoap;
66     systemd.services = builtins.listToAttrs ( map streamService streams );
67   };