feat(nixos): add navidrome environment secrets

This commit is contained in:
2026-09-12 21:07:57 -04:00
parent 04a771cb07
commit e2f56651a5
2 changed files with 29 additions and 0 deletions

View File

@@ -5,6 +5,9 @@
}:
let
serviceConfig = config.containers.navidrome.config.modules.services.navidrome;
lastfmApiKeySecret = "services/navidrome/lastfm/api-key";
lastfmSecretSecret = "services/navidrome/lastfm/secret";
hostSecrets = ../secrets + "/${config.networking.hostName}.yaml";
in
{
options.guests.navidrome = {
@@ -51,6 +54,10 @@ in
group = "storage";
mode = "2770";
};
${serviceConfig.environmentFile} = {
file = config.sops.templates."navidrome.env".path;
readOnly = true;
};
};
limits = {
@@ -60,5 +67,19 @@ in
};
};
sops.secrets = {
${lastfmApiKeySecret}.sopsFile = hostSecrets;
${lastfmSecretSecret}.sopsFile = hostSecrets;
};
sops.templates."navidrome.env" = {
owner = "root";
group = "storage";
mode = "0440";
content = ''
ND_LASTFM_APIKEY=${config.sops.placeholder.${lastfmApiKeySecret}}
ND_LASTFM_SECRET=${config.sops.placeholder.${lastfmSecretSecret}}
'';
};
};
}

View File

@@ -23,6 +23,13 @@ in
readOnly = true;
description = "Guest path for Navidrome's `MusicFolder` setting.";
};
environmentFile = lib.mkOption {
type = lib.types.path;
default = "/run/secrets/navidrome.env";
readOnly = true;
description = "Guest path for Navidrome's environment file.";
};
};
config = lib.mkMerge [
@@ -43,6 +50,7 @@ in
user = "navidrome";
group = "storage";
openFirewall = true;
environmentFile = cfg.environmentFile;
settings = {
Address = "0.0.0.0";
Port = 4533;