diff --git a/configs/nixos/guests/homepage.nix b/configs/nixos/guests/homepage.nix index a21048a..c169f46 100644 --- a/configs/nixos/guests/homepage.nix +++ b/configs/nixos/guests/homepage.nix @@ -5,6 +5,7 @@ }: let cfg = config.guests.homepage; + environmentFile = "/run/secrets/homepage.env"; in { config = lib.mkIf cfg.enable { @@ -12,6 +13,12 @@ in interior.modules.services.homepage = { enable = true; hostName = config.networking.hostName; + inherit environmentFile; + }; + + mounts.${environmentFile} = { + file = config.sops.templates."homepage.env".path; + readOnly = true; }; limits = { @@ -20,5 +27,17 @@ in 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"} + ''; + }; }; } diff --git a/configs/nixos/modules/services/homepage.nix b/configs/nixos/modules/services/homepage.nix index daf7f92..6386ebc 100644 --- a/configs/nixos/modules/services/homepage.nix +++ b/configs/nixos/modules/services/homepage.nix @@ -134,6 +134,12 @@ in default = null; 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 { @@ -141,6 +147,7 @@ in enable = true; openFirewall = true; inherit (cfg) listenPort; + environmentFiles = [ cfg.environmentFile ]; allowedHosts = lib.concatStringsSep "," (if cfg.allowedHosts == null then derivedAllowedHosts else cfg.allowedHosts); services = homepageServices; widgets = [ @@ -150,6 +157,14 @@ in text = "tracion"; }; } + { + openmeteo = { + units = "metric"; + latitude = "{{HOMEPAGE_VAR_LATITUDE}}"; + longitude = "{{HOMEPAGE_VAR_LONGITUDE}}"; + cache = 5; + }; + } { datetime = { text_size = "xl";