initial liquidsoap service expression

+77
+2
nixos/modules/misc/ids.nix
··· 162 162 systemd-network = 152; 163 163 systemd-resolve = 153; 164 164 systemd-timesync = 154; 165 + liquidsoap = 155; 165 166 166 167 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! 167 168 ··· 290 291 systemd-network = 152; 291 292 systemd-resolve = 153; 292 293 systemd-timesync = 154; 294 + liquidsoap = 155; 293 295 294 296 # When adding a gid, make sure it doesn't match an existing uid. And don't use gids above 399! 295 297
+1
nixos/modules/module-list.nix
··· 89 89 ./services/audio/alsa.nix 90 90 # Disabled as fuppes it does no longer builds. 91 91 # ./services/audio/fuppes.nix 92 + ./services/audio/liquidsoap.nix 92 93 ./services/audio/mpd.nix 93 94 ./services/audio/mopidy.nix 94 95 ./services/backup/almir.nix
+74
nixos/modules/services/audio/liquidsoap.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + streams = builtins.attrNames config.services.liquidsoap.streams; 7 + 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 + preStart = 18 + '' 19 + mkdir -p /var/log/liquidsoap 20 + chown liquidsoap -R /var/log/liquidsoap 21 + ''; 22 + serviceConfig = { 23 + PermissionsStartOnly="true"; 24 + ExecStart = "${pkgs.liquidsoap}/bin/liquidsoap ${stream}"; 25 + User = "liquidsoap"; 26 + }; 27 + }; 28 + }; 29 + in 30 + { 31 + 32 + ##### interface 33 + 34 + options = { 35 + 36 + services.liquidsoap.streams = mkOption { 37 + 38 + description = 39 + '' 40 + Set of Liquidsoap streams to start, 41 + one systemd service per stream. 42 + ''; 43 + 44 + default = {}; 45 + 46 + example = { 47 + myStream1 = literalExample "\"/etc/liquidsoap/myStream1.liq\""; 48 + myStream2 = literalExample "./myStream2.liq"; 49 + myStream3 = literalExample "\"out(playlist(\"/srv/music/\"))\""; 50 + }; 51 + 52 + type = types.attrsOf (types.either types.path types.str); 53 + }; 54 + 55 + }; 56 + ##### implementation 57 + 58 + config = mkIf (builtins.length streams != 0) { 59 + 60 + users.extraUsers.liquidsoap = { 61 + uid = config.ids.uids.liquidsoap; 62 + group = "liquidsoap"; 63 + extraGroups = [ "audio" ]; 64 + description = "Liquidsoap streaming user"; 65 + home = "/var/lib/liquidsoap"; 66 + createHome = true; 67 + }; 68 + 69 + users.extraGroups.liquidsoap.gid = config.ids.gids.liquidsoap; 70 + 71 + systemd.services = builtins.listToAttrs ( map streamService streams ); 72 + }; 73 + 74 + }