refactor(nixos): make navidrome secret names options

This commit is contained in:
2026-09-12 21:15:17 -04:00
parent fa918d4476
commit 262d92876b

View File

@@ -6,9 +6,6 @@
let
guestCfg = config.guests.navidrome;
serviceCfg = 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 = {
@@ -25,6 +22,18 @@ in
example = "/srv/music";
description = "Host path mounted as Navidrome's library folder.";
};
lastfmApiKeySecret = lib.mkOption {
type = lib.types.str;
default = "services/navidrome/lastfm/api-key";
description = "SOPS secret name containing the Navidrome Last.fm API key.";
};
lastfmSecretSecret = lib.mkOption {
type = lib.types.str;
default = "services/navidrome/lastfm/secret";
description = "SOPS secret name containing the Navidrome Last.fm secret.";
};
};
config = lib.mkIf guestCfg.enable {
@@ -69,8 +78,8 @@ in
};
sops.secrets = {
${lastfmApiKeySecret}.sopsFile = hostSecrets;
${lastfmSecretSecret}.sopsFile = hostSecrets;
${guestCfg.lastfmApiKeySecret}.sopsFile = ../secrets + "/${config.networking.hostName}.yaml";
${guestCfg.lastfmSecretSecret}.sopsFile = ../secrets + "/${config.networking.hostName}.yaml";
};
sops.templates."navidrome.env" = {
@@ -78,8 +87,8 @@ in
group = "storage";
mode = "0440";
content = ''
ND_LASTFM_APIKEY=${config.sops.placeholder.${lastfmApiKeySecret}}
ND_LASTFM_SECRET=${config.sops.placeholder.${lastfmSecretSecret}}
ND_LASTFM_APIKEY=${config.sops.placeholder.${guestCfg.lastfmApiKeySecret}}
ND_LASTFM_SECRET=${config.sops.placeholder.${guestCfg.lastfmSecretSecret}}
'';
};
};