refactor(network): use address registry

This commit was merged in pull request #60.
This commit is contained in:
2026-08-23 23:02:43 -04:00
parent 6f963920ec
commit c267a2ec5c
5 changed files with 55 additions and 94 deletions

View File

@@ -291,51 +291,63 @@
touch $out
'';
network-endpoint-fleet-registry =
address-registry =
let
hostEndpointConfig =
hostAddressConfig =
lib.nixosSystem {
system = "x86_64-linux";
specialArgs.my = self.lib;
modules = [
./modules/network.nix
self.lib.registry.module
{
modules.network.endpoint.address = "10.23.50.146";
registry.address.neogaia.self = "10.23.50.146";
system.stateVersion = "26.11";
}
];
};
guestEndpointConfig =
guestAddressConfig =
lib.nixosSystem {
system = "x86_64-linux";
specialArgs.my = self.lib;
modules = [
inputs.sops-nix.nixosModules.sops
self.lib.registry.module
./modules/network.nix
./modules/reverse-proxy.nix
(self.lib.guest { name = "copyparty"; })
{
networking.hostName = "pikachu";
modules.network.vlans = [ 20 ];
guests.copyparty = {
enable = true;
vlan = 20;
endpoint.address = "10.23.20.126";
address = "10.23.20.126";
};
system.stateVersion = "26.11";
}
];
};
registry = self.lib.registry.collect {
hosts = {
neogaia = hostAddressConfig;
pikachu = guestAddressConfig;
};
};
fleetEndpoints = self.lib.networkEndpoints.collectFleetEndpoints {
neogaia = hostEndpointConfig;
pikachu = guestEndpointConfig;
neogaia = hostAddressConfig;
pikachu = guestAddressConfig;
};
in
pkgs.runCommand "network-endpoint-fleet-registry-check" { } ''
pkgs.runCommand "address-registry-check" { } ''
${
lib.optionalString (
!(
fleetEndpoints.neogaia.address == "10.23.50.146"
registry.address.neogaia.self == "10.23.50.146"
&& registry.address.pikachu.copyparty == "10.23.20.126"
&& fleetEndpoints.neogaia.address == "10.23.50.146"
&& fleetEndpoints."pikachu-copyparty".address == "10.23.20.126"
&& !(fleetEndpoints ? pikachu)
&& guestEndpointConfig.config.containers.copyparty.config.systemd.network.networks."20-eth0".networkConfig.DHCP == "yes"
&& guestAddressConfig.config.containers.copyparty.config.systemd.network.networks."20-eth0".networkConfig.DHCP == "yes"
)
) "exit 1"
}
@@ -393,9 +405,10 @@
system = "x86_64-linux";
specialArgs.my = self.lib;
modules = [
./modules/network.nix
self.lib.registry.module
{
modules.network.endpoint.address = "10.23.50.146";
registry.address.worker.self = "10.23.50.146";
system.stateVersion = "26.11";
}
];
};
@@ -420,6 +433,7 @@
specialArgs.my = self.lib;
modules = [
inputs.sops-nix.nixosModules.sops
self.lib.registry.module
./modules/network.nix
./modules/reverse-proxy.nix
(self.lib.guest { name = "files"; })
@@ -429,13 +443,14 @@
guests.files = {
enable = true;
vlan = 20;
endpoint.address = "10.23.20.126";
address = "10.23.20.126";
reverseProxy = {
enable = true;
host = "files.alexion.dev";
port = 3923;
};
};
system.stateVersion = "26.11";
}
];
};