Compare commits

..

1 Commits

Author SHA1 Message Date
45c6d01b1f refactor(reverse-proxy): use route registry 2026-08-24 21:58:54 -04:00
3 changed files with 31 additions and 24 deletions

View File

@@ -392,10 +392,20 @@
}; };
}; };
testConfig = testConfig =
(self.nixosConfigurations.pikachu.extendModules { (lib.nixosSystem {
specialArgs.registry = registry; system = "x86_64-linux";
specialArgs = {
my = self.lib;
inherit registry;
};
modules = [
./modules/reverse-proxy.nix
{
modules.reverse-proxy.enable = true;
}
];
}).config; }).config;
vhosts = testConfig.containers.reverse-proxy.config.services.nginx.virtualHosts; vhosts = testConfig.services.nginx.virtualHosts;
in in
pkgs.runCommand "reverse-proxy-fleet-routes-check" { } '' pkgs.runCommand "reverse-proxy-fleet-routes-check" { } ''
${ ${
@@ -449,10 +459,12 @@
address = "10.23.20.126"; address = "10.23.20.126";
reverseProxy = { reverseProxy = {
enable = true; enable = true;
host = "files.alexion.dev"; route = {
domain = "files.alexion.dev";
port = 3923; port = 3923;
}; };
}; };
};
system.stateVersion = "26.11"; system.stateVersion = "26.11";
} }
]; ];

View File

@@ -87,10 +87,12 @@
address = "10.23.20.42"; address = "10.23.20.42";
reverseProxy = { reverseProxy = {
enable = true; enable = true;
host = "budget.alexion.dev"; route = {
domain = "budget.alexion.dev";
port = 5006; port = 5006;
}; };
}; };
};
guests.reverse-proxy = { guests.reverse-proxy = {
enable = true; enable = true;
@@ -107,8 +109,10 @@
address = "10.23.20.126"; address = "10.23.20.126";
reverseProxy = { reverseProxy = {
enable = true; enable = true;
host = "files.alexion.dev"; route = {
domain = "files.alexion.dev";
port = 3923; port = 3923;
};
trustedSources = [ "${registry.address.${config.networking.hostName}."reverse-proxy"}/32" ]; trustedSources = [ "${registry.address.${config.networking.hostName}."reverse-proxy"}/32" ];
}; };
volumes = { volumes = {

View File

@@ -20,7 +20,7 @@ let
name, name,
interior ? { }, interior ? { },
}: }:
{ config, lib, ... }@args: { config, lib, ... }:
let let
optionPath = [ "guests" ] ++ lib.splitString "." name; optionPath = [ "guests" ] ++ lib.splitString "." name;
cfg = lib.getAttrFromPath optionPath config; cfg = lib.getAttrFromPath optionPath config;
@@ -132,15 +132,9 @@ let
reverseProxy = { reverseProxy = {
enable = lib.mkEnableOption "a reverse-proxy route for this guest"; enable = lib.mkEnableOption "a reverse-proxy route for this guest";
host = lib.mkOption { route = lib.mkOption {
type = lib.types.str; type = self.lib.registry.definitions.route.type;
description = "Primary hostname served by this guest's reverse-proxy route."; description = "Route registry entry published for this guest.";
};
port = lib.mkOption {
type = lib.types.ints.between 1 65535;
example = 3923;
description = "Backend TCP port served by this guest.";
}; };
}; };
mounts = lib.mkOption { mounts = lib.mkOption {
@@ -288,10 +282,7 @@ let
registry.address.${config.networking.hostName}.${machineName} = lib.mkIf (cfg.address != null) cfg.address; registry.address.${config.networking.hostName}.${machineName} = lib.mkIf (cfg.address != null) cfg.address;
registry.route.${config.networking.hostName}.${machineName} = lib.mkIf cfg.reverseProxy.enable { registry.route.${config.networking.hostName}.${machineName} = lib.mkIf cfg.reverseProxy.enable cfg.reverseProxy.route;
domain = cfg.reverseProxy.host;
inherit (cfg.reverseProxy) port;
};
assertions = [ assertions = [
{ {
@@ -351,7 +342,7 @@ let
bindMounts = userMounts // secretMounts; bindMounts = userMounts // secretMounts;
specialArgs = specialArgs // lib.optionalAttrs (args ? registry) { inherit (args) registry; }; inherit specialArgs;
config = { config = {
imports = [ imports = [