2021-08-29 23:05:59 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) callPackageWith mkEnableOption mkIf mkOption
|
|
|
|
recursiveUpdate types;
|
|
|
|
|
|
|
|
cfg = config.services.navidrome;
|
|
|
|
package = callPackageWith pkgs ../../pkgs/navidrome-bin { };
|
|
|
|
settingsFormat = pkgs.formats.json {};
|
|
|
|
|
2021-09-22 13:30:05 +02:00
|
|
|
in lib.optionalAttrs (lib.versionOlder lib.version "21.11pre") {
|
2021-08-29 23:05:59 +02:00
|
|
|
|
|
|
|
options = {
|
|
|
|
services.navidrome = {
|
|
|
|
|
|
|
|
enable = mkEnableOption package.meta.description;
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = package;
|
|
|
|
description = "Navidrome package to use.";
|
|
|
|
};
|
|
|
|
|
|
|
|
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 = ''
|
|
|
|
${cfg.package}/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;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|