fix(nixos): source homepage location from secrets

This commit is contained in:
2026-09-15 20:37:04 -04:00
parent 4a42b8459d
commit 06d92a9bcf
2 changed files with 34 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
}: }:
let let
cfg = config.guests.homepage; cfg = config.guests.homepage;
environmentFile = "/run/secrets/homepage.env";
in in
{ {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@@ -12,6 +13,12 @@ in
interior.modules.services.homepage = { interior.modules.services.homepage = {
enable = true; enable = true;
hostName = config.networking.hostName; hostName = config.networking.hostName;
inherit environmentFile;
};
mounts.${environmentFile} = {
file = config.sops.templates."homepage.env".path;
readOnly = true;
}; };
limits = { limits = {
@@ -20,5 +27,17 @@ in
tasksMax = lib.mkDefault 256; tasksMax = lib.mkDefault 256;
}; };
}; };
sops.secrets = {
"services/metadata/latitude" = { };
"services/metadata/longitude" = { };
};
sops.templates."homepage.env" = {
content = ''
HOMEPAGE_VAR_LATITUDE=${config.sops.placeholder."services/metadata/latitude"}
HOMEPAGE_VAR_LONGITUDE=${config.sops.placeholder."services/metadata/longitude"}
'';
};
}; };
} }

View File

@@ -134,6 +134,12 @@ in
default = null; default = null;
description = "Host headers accepted by Homepage. Defaults to matching address and route registry entries."; description = "Host headers accepted by Homepage. Defaults to matching address and route registry entries.";
}; };
environmentFile = lib.mkOption {
type = lib.types.path;
default = "/run/secrets/homepage.env";
description = "Environment file passed to Homepage.";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@@ -141,6 +147,7 @@ in
enable = true; enable = true;
openFirewall = true; openFirewall = true;
inherit (cfg) listenPort; inherit (cfg) listenPort;
environmentFiles = [ cfg.environmentFile ];
allowedHosts = lib.concatStringsSep "," (if cfg.allowedHosts == null then derivedAllowedHosts else cfg.allowedHosts); allowedHosts = lib.concatStringsSep "," (if cfg.allowedHosts == null then derivedAllowedHosts else cfg.allowedHosts);
services = homepageServices; services = homepageServices;
widgets = [ widgets = [
@@ -150,6 +157,14 @@ in
text = "tracion"; text = "tracion";
}; };
} }
{
openmeteo = {
units = "metric";
latitude = "{{HOMEPAGE_VAR_LATITUDE}}";
longitude = "{{HOMEPAGE_VAR_LONGITUDE}}";
cache = 5;
};
}
{ {
datetime = { datetime = {
text_size = "xl"; text_size = "xl";