nixos/navidrome: init module and test

Co-authored-by: aciceri <andrea.ciceri@autistici.org>
Co-authored-by: nyanloutre <paul@nyanlout.re>
This commit is contained in:
nyanloutre 2020-12-05 19:11:21 +01:00 committed by Jonathan Ringer
parent 945d0225b1
commit c9fc751673
7 changed files with 101 additions and 1 deletions

View file

@ -172,6 +172,16 @@
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
<itemizedlist spacing="compact">
<listitem>
<para>
<link xlink:href="https://www.navidrome.org/">navidrome</link>,
a personal music streaming server with subsonic-compatible
api. Available as
<link linkend="opt-services.navidrome.enable">navidrome</link>.
</para>
</listitem>
</itemizedlist>
</section> </section>
<section xml:id="sec-release-21.11-incompatibilities"> <section xml:id="sec-release-21.11-incompatibilities">
<title>Backward Incompatibilities</title> <title>Backward Incompatibilities</title>

View file

@ -53,6 +53,9 @@ pt-services.clipcat.enable).
- [isso](https://posativ.org/isso/), a commenting server similar to Disqus. - [isso](https://posativ.org/isso/), a commenting server similar to Disqus.
Available as [isso](#opt-services.isso.enable) Available as [isso](#opt-services.isso.enable)
* [navidrome](https://www.navidrome.org/), a personal music streaming server with
subsonic-compatible api. Available as [navidrome](#opt-services.navidrome.enable).
## Backward Incompatibilities {#sec-release-21.11-incompatibilities} ## Backward Incompatibilities {#sec-release-21.11-incompatibilities}
- The `staticjinja` package has been upgraded from 1.0.4 to 3.0.1 - The `staticjinja` package has been upgraded from 1.0.4 to 3.0.1

View file

@ -254,6 +254,7 @@
./services/audio/mopidy.nix ./services/audio/mopidy.nix
./services/audio/networkaudiod.nix ./services/audio/networkaudiod.nix
./services/audio/roon-bridge.nix ./services/audio/roon-bridge.nix
./services/audio/navidrome.nix
./services/audio/roon-server.nix ./services/audio/roon-server.nix
./services/audio/slimserver.nix ./services/audio/slimserver.nix
./services/audio/snapserver.nix ./services/audio/snapserver.nix

View file

@ -0,0 +1,71 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.navidrome;
settingsFormat = pkgs.formats.json {};
in {
options = {
services.navidrome = {
enable = mkEnableOption pkgs.navidrome.meta.description;
settings = mkOption rec {
type = settingsFormat.type;
apply = recursiveUpdate default;
default = {
Address = "127.0.0.1";
Port = 4533;
};
example = {
MusicFolder = "/mnt/music";
};
description = ''
Configuration for Navidrome, see <link xlink:href="https://www.navidrome.org/docs/usage/configuration-options/"/> for supported values.
'';
};
};
};
config = mkIf cfg.enable {
systemd.services.navidrome = {
description = "Navidrome Media Server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = ''
${pkgs.navidrome}/bin/navidrome --configfile ${settingsFormat.generate "navidrome.json" cfg.settings}
'';
DynamicUser = true;
StateDirectory = "navidrome";
WorkingDirectory = "/var/lib/navidrome";
RuntimeDirectory = "navidrome";
RootDirectory = "/run/navidrome";
ReadWritePaths = "";
BindReadOnlyPaths = [
builtins.storeDir
] ++ lib.optional (cfg.settings ? MusicFolder) cfg.settings.MusicFolder;
CapabilityBoundingSet = "";
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
RestrictNamespaces = true;
PrivateDevices = true;
PrivateUsers = true;
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
SystemCallArchitectures = "native";
SystemCallFilter = [ "@system-service" "~@privileged" "~@resources" ];
RestrictRealtime = true;
LockPersonality = true;
MemoryDenyWriteExecute = true;
UMask = "0066";
ProtectHostname = true;
};
};
};
}

View file

@ -283,6 +283,7 @@ in
nat.firewall = handleTest ./nat.nix { withFirewall = true; }; nat.firewall = handleTest ./nat.nix { withFirewall = true; };
nat.firewall-conntrack = handleTest ./nat.nix { withFirewall = true; withConntrackHelpers = true; }; nat.firewall-conntrack = handleTest ./nat.nix { withFirewall = true; withConntrackHelpers = true; };
nat.standalone = handleTest ./nat.nix { withFirewall = false; }; nat.standalone = handleTest ./nat.nix { withFirewall = false; };
navidrome = handleTest ./navidrome.nix {};
ncdns = handleTest ./ncdns.nix {}; ncdns = handleTest ./ncdns.nix {};
ndppd = handleTest ./ndppd.nix {}; ndppd = handleTest ./ndppd.nix {};
nebula = handleTest ./nebula.nix {}; nebula = handleTest ./nebula.nix {};

12
nixos/tests/navidrome.nix Normal file
View file

@ -0,0 +1,12 @@
import ./make-test-python.nix ({ pkgs, ... }: {
name = "navidrome";
machine = { ... }: {
services.navidrome.enable = true;
};
testScript = ''
machine.wait_for_unit("navidrome")
machine.wait_for_open_port("4533")
'';
})

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetchurl, ffmpeg, ffmpegSupport ? true, makeWrapper }: { lib, stdenv, fetchurl, ffmpeg, ffmpegSupport ? true, makeWrapper, nixosTests }:
with lib; with lib;
@ -31,6 +31,8 @@ stdenv.mkDerivation rec {
--prefix PATH : ${makeBinPath (optional ffmpegSupport ffmpeg)} --prefix PATH : ${makeBinPath (optional ffmpegSupport ffmpeg)}
''; '';
passthru.tests.navidrome = nixosTests.navidrome;
meta = { meta = {
description = "Navidrome Music Server and Streamer compatible with Subsonic/Airsonic"; description = "Navidrome Music Server and Streamer compatible with Subsonic/Airsonic";
homepage = "https://www.navidrome.org/"; homepage = "https://www.navidrome.org/";