feat(nixos): wire navidrome into pikachu

This commit is contained in:
2026-09-12 18:51:11 -04:00
parent c21b7a632c
commit 6f8195260a
3 changed files with 64 additions and 23 deletions

View File

@@ -5,6 +5,8 @@
}: }:
let let
cfg = config.guests.navidrome; cfg = config.guests.navidrome;
envFile = "/run/secrets/navidrome.env";
hasLastfmSecrets = cfg.lastfmApiKeySecret != null && cfg.lastfmSecretSecret != null;
in in
{ {
options.guests.navidrome = { options.guests.navidrome = {
@@ -52,10 +54,16 @@ in
description = "Additional non-secret Navidrome settings."; description = "Additional non-secret Navidrome settings.";
}; };
environmentFile = lib.mkOption { lastfmApiKeySecret = lib.mkOption {
type = lib.types.nullOr lib.types.path; type = lib.types.nullOr lib.types.str;
default = null; default = "services/navidrome/lastfm/api-key";
description = "Guest path to a file containing secret Navidrome environment variables."; description = "SOPS secret name containing the Navidrome Last.fm API key.";
};
lastfmSecretSecret = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = "services/navidrome/lastfm/secret";
description = "SOPS secret name containing the Navidrome Last.fm secret.";
}; };
}; };
@@ -80,24 +88,31 @@ in
port port
enableSharing enableSharing
settings settings
environmentFile
; ;
environmentFile = if hasLastfmSecrets then envFile else null;
}; };
mounts = { mounts =
${cfg.dataDir} = { {
directory = cfg.dataPath; ${cfg.dataDir} = {
owner = config.registry."stable-uid".${config.networking.hostName}.navidrome; directory = cfg.dataPath;
group = "storage"; owner = config.registry."stable-uid".${config.networking.hostName}.navidrome;
mode = "0770"; group = "storage";
mode = "0770";
};
${cfg.musicDir} = {
directory = cfg.musicPath;
owner = "root";
group = "storage";
mode = "2770";
};
}
// lib.optionalAttrs hasLastfmSecrets {
${envFile} = {
file = config.sops.templates."navidrome.env".path;
readOnly = true;
};
}; };
${cfg.musicDir} = {
directory = cfg.musicPath;
owner = "root";
group = "storage";
mode = "2770";
};
};
limits = { limits = {
memory = lib.mkDefault "2G"; memory = lib.mkDefault "2G";
@@ -105,5 +120,20 @@ in
tasksMax = lib.mkDefault 512; tasksMax = lib.mkDefault 512;
}; };
}; };
sops.secrets = lib.optionalAttrs hasLastfmSecrets {
${cfg.lastfmApiKeySecret} = { };
${cfg.lastfmSecretSecret} = { };
};
sops.templates."navidrome.env" = lib.mkIf hasLastfmSecrets {
owner = "root";
group = "storage";
mode = "0440";
content = ''
ND_LASTFM_APIKEY=${config.sops.placeholder.${cfg.lastfmApiKeySecret}}
ND_LASTFM_SECRET=${config.sops.placeholder.${cfg.lastfmSecretSecret}}
'';
};
}; };
} }

View File

@@ -23,11 +23,6 @@ in
enableACME = true; enableACME = true;
locations."/".proxyPass = "http://10.23.20.32"; locations."/".proxyPass = "http://10.23.20.32";
}; };
"music.alexion.dev" = {
forceSSL = true;
enableACME = true;
locations."/".proxyPass = "http://10.23.20.32";
};
"photos.alexion.dev" = { "photos.alexion.dev" = {
forceSSL = true; forceSSL = true;
enableACME = true; enableACME = true;

View File

@@ -120,6 +120,22 @@
}; };
}; };
guests.navidrome = {
enable = true;
vlan = 20;
mac = "BC:24:11:C9:17:83";
dataPath = "/pikachu/data/navidrome";
musicPath = "/pikachu/media/music";
address = "10.23.20.43";
reverseProxy = {
enable = true;
route = {
domain = "music.alexion.dev";
port = 4533;
};
};
};
guests.reverse-proxy = { guests.reverse-proxy = {
enable = true; enable = true;
vlan = 20; vlan = 20;