nix-config/hosts/nixedo/services/homepage/default.nix

52 lines
1 KiB
Nix
Raw Normal View History

2025-04-30 01:10:02 +01:00
{
config,
lib,
options,
...
}:
with lib;
2025-04-28 00:36:43 +01:00
2025-04-30 01:10:02 +01:00
let
cfg = homelab.services.${service};
homelab = config.features.homelab;
2025-04-30 01:10:02 +01:00
opts = options.services.${service};
service = "homepage-dashboard";
in
{
options.features.homelab.services.${service} = {
2025-04-30 01:10:02 +01:00
enable = mkEnableOption "Enable ${service}";
port = mkOption {
default = opts.listenPort.default;
type = types.port;
};
url = mkOption {
default = "${config.networking.hostName}.${homelab.baseDomain}";
type = types.str;
};
};
config = mkIf cfg.enable {
services = {
${service} = {
2025-04-28 00:36:43 +01:00
enable = true;
2025-04-30 01:10:02 +01:00
listenPort = cfg.port;
2025-04-28 00:36:43 +01:00
openFirewall = true;
2025-04-28 00:36:43 +01:00
services = (import ./services.nix { inherit config; });
widgets = import ./widgets.nix;
};
2025-04-30 01:10:02 +01:00
nginx.virtualHosts.${cfg.url} = {
2025-04-28 00:36:43 +01:00
forceSSL = true;
2025-04-30 01:10:02 +01:00
useACMEHost = homelab.baseDomain;
2025-04-30 01:10:02 +01:00
locations."/".proxyPass =
"http://localhost:${toString config.services.homepage-dashboard.listenPort}";
2025-04-28 00:36:43 +01:00
};
};
2025-04-30 01:10:02 +01:00
};
}