nixos/navidrome: init module and test

Co-authored-by: aciceri <andrea.ciceri@autistici.org>
Co-authored-by: nyanloutre <paul@nyanlout.re>

authored by

nyanloutre
aciceri
nyanloutre
and committed by
Jonathan Ringer
c9fc7516 945d0225

+101 -1
+10
nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
··· 172 172 </para> 173 173 </listitem> 174 174 </itemizedlist> 175 + <itemizedlist spacing="compact"> 176 + <listitem> 177 + <para> 178 + <link xlink:href="https://www.navidrome.org/">navidrome</link>, 179 + a personal music streaming server with subsonic-compatible 180 + api. Available as 181 + <link linkend="opt-services.navidrome.enable">navidrome</link>. 182 + </para> 183 + </listitem> 184 + </itemizedlist> 175 185 </section> 176 186 <section xml:id="sec-release-21.11-incompatibilities"> 177 187 <title>Backward Incompatibilities</title>
+3
nixos/doc/manual/release-notes/rl-2111.section.md
··· 53 53 - [isso](https://posativ.org/isso/), a commenting server similar to Disqus. 54 54 Available as [isso](#opt-services.isso.enable) 55 55 56 + * [navidrome](https://www.navidrome.org/), a personal music streaming server with 57 + subsonic-compatible api. Available as [navidrome](#opt-services.navidrome.enable). 58 + 56 59 ## Backward Incompatibilities {#sec-release-21.11-incompatibilities} 57 60 58 61 - The `staticjinja` package has been upgraded from 1.0.4 to 3.0.1
+1
nixos/modules/module-list.nix
··· 254 254 ./services/audio/mopidy.nix 255 255 ./services/audio/networkaudiod.nix 256 256 ./services/audio/roon-bridge.nix 257 + ./services/audio/navidrome.nix 257 258 ./services/audio/roon-server.nix 258 259 ./services/audio/slimserver.nix 259 260 ./services/audio/snapserver.nix
+71
nixos/modules/services/audio/navidrome.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.navidrome; 7 + settingsFormat = pkgs.formats.json {}; 8 + in { 9 + options = { 10 + services.navidrome = { 11 + 12 + enable = mkEnableOption pkgs.navidrome.meta.description; 13 + 14 + settings = mkOption rec { 15 + type = settingsFormat.type; 16 + apply = recursiveUpdate default; 17 + default = { 18 + Address = "127.0.0.1"; 19 + Port = 4533; 20 + }; 21 + example = { 22 + MusicFolder = "/mnt/music"; 23 + }; 24 + description = '' 25 + Configuration for Navidrome, see <link xlink:href="https://www.navidrome.org/docs/usage/configuration-options/"/> for supported values. 26 + ''; 27 + }; 28 + 29 + }; 30 + }; 31 + 32 + config = mkIf cfg.enable { 33 + systemd.services.navidrome = { 34 + description = "Navidrome Media Server"; 35 + after = [ "network.target" ]; 36 + wantedBy = [ "multi-user.target" ]; 37 + serviceConfig = { 38 + ExecStart = '' 39 + ${pkgs.navidrome}/bin/navidrome --configfile ${settingsFormat.generate "navidrome.json" cfg.settings} 40 + ''; 41 + DynamicUser = true; 42 + StateDirectory = "navidrome"; 43 + WorkingDirectory = "/var/lib/navidrome"; 44 + RuntimeDirectory = "navidrome"; 45 + RootDirectory = "/run/navidrome"; 46 + ReadWritePaths = ""; 47 + BindReadOnlyPaths = [ 48 + builtins.storeDir 49 + ] ++ lib.optional (cfg.settings ? MusicFolder) cfg.settings.MusicFolder; 50 + CapabilityBoundingSet = ""; 51 + RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ]; 52 + RestrictNamespaces = true; 53 + PrivateDevices = true; 54 + PrivateUsers = true; 55 + ProtectClock = true; 56 + ProtectControlGroups = true; 57 + ProtectHome = true; 58 + ProtectKernelLogs = true; 59 + ProtectKernelModules = true; 60 + ProtectKernelTunables = true; 61 + SystemCallArchitectures = "native"; 62 + SystemCallFilter = [ "@system-service" "~@privileged" "~@resources" ]; 63 + RestrictRealtime = true; 64 + LockPersonality = true; 65 + MemoryDenyWriteExecute = true; 66 + UMask = "0066"; 67 + ProtectHostname = true; 68 + }; 69 + }; 70 + }; 71 + }
+1
nixos/tests/all-tests.nix
··· 283 283 nat.firewall = handleTest ./nat.nix { withFirewall = true; }; 284 284 nat.firewall-conntrack = handleTest ./nat.nix { withFirewall = true; withConntrackHelpers = true; }; 285 285 nat.standalone = handleTest ./nat.nix { withFirewall = false; }; 286 + navidrome = handleTest ./navidrome.nix {}; 286 287 ncdns = handleTest ./ncdns.nix {}; 287 288 ndppd = handleTest ./ndppd.nix {}; 288 289 nebula = handleTest ./nebula.nix {};
+12
nixos/tests/navidrome.nix
··· 1 + import ./make-test-python.nix ({ pkgs, ... }: { 2 + name = "navidrome"; 3 + 4 + machine = { ... }: { 5 + services.navidrome.enable = true; 6 + }; 7 + 8 + testScript = '' 9 + machine.wait_for_unit("navidrome") 10 + machine.wait_for_open_port("4533") 11 + ''; 12 + })
+3 -1
pkgs/servers/misc/navidrome/default.nix
··· 1 - { lib, stdenv, fetchurl, ffmpeg, ffmpegSupport ? true, makeWrapper }: 1 + { lib, stdenv, fetchurl, ffmpeg, ffmpegSupport ? true, makeWrapper, nixosTests }: 2 2 3 3 with lib; 4 4 ··· 30 30 wrapProgram $out/bin/navidrome \ 31 31 --prefix PATH : ${makeBinPath (optional ffmpegSupport ffmpeg)} 32 32 ''; 33 + 34 + passthru.tests.navidrome = nixosTests.navidrome; 33 35 34 36 meta = { 35 37 description = "Navidrome Music Server and Streamer compatible with Subsonic/Airsonic";