93 lines
2.2 KiB
Nix
93 lines
2.2 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.modules.services.navidrome;
|
|
in
|
|
{
|
|
options.modules.services.navidrome = {
|
|
enable = lib.mkEnableOption "Navidrome";
|
|
|
|
package = lib.mkPackageOption pkgs "navidrome" { };
|
|
|
|
port = lib.mkOption {
|
|
type = lib.types.port;
|
|
default = 4533;
|
|
description = "Port Navidrome listens on.";
|
|
};
|
|
|
|
dataDir = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "/var/lib/navidrome";
|
|
description = "Directory where Navidrome stores state.";
|
|
};
|
|
|
|
musicDir = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "/music";
|
|
description = "Directory where Navidrome reads the music library.";
|
|
};
|
|
|
|
user = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "navidrome";
|
|
description = "User account that runs Navidrome.";
|
|
};
|
|
|
|
group = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "storage";
|
|
description = "Group account that owns Navidrome state and media access.";
|
|
};
|
|
|
|
enableSharing = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Enables Navidrome sharing support.";
|
|
};
|
|
|
|
settings = lib.mkOption {
|
|
type = lib.types.attrs;
|
|
default = { };
|
|
description = "Additional non-secret Navidrome settings.";
|
|
};
|
|
|
|
environmentFile = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.path;
|
|
default = null;
|
|
description = "File containing secret Navidrome environment variables.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkMerge [
|
|
{
|
|
registry."stable-uid".${config.networking.hostName}.navidrome = 20004;
|
|
}
|
|
|
|
(lib.mkIf cfg.enable {
|
|
users.users.${cfg.user} = {
|
|
isSystemUser = true;
|
|
uid = config.registry."stable-uid".${config.networking.hostName}.navidrome;
|
|
group = cfg.group;
|
|
home = cfg.dataDir;
|
|
};
|
|
|
|
services.navidrome = {
|
|
enable = true;
|
|
inherit (cfg) package user group environmentFile;
|
|
openFirewall = true;
|
|
settings = cfg.settings // {
|
|
Address = "0.0.0.0";
|
|
Port = cfg.port;
|
|
DataFolder = cfg.dataDir;
|
|
MusicFolder = cfg.musicDir;
|
|
EnableSharing = cfg.enableSharing;
|
|
};
|
|
};
|
|
})
|
|
];
|
|
}
|