feat: introduce awareness module for WAN addresses
Introduce a data-only module to perform abstraction on the deployment, we use it for WAN for now. The usecase is service discovery for simple cases. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
7df7eaeb9b
commit
6441a01ab1
|
@ -1,7 +1,7 @@
|
||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.bagel.hardware.raito-vm;
|
cfg = config.bagel.hardware.raito-vm;
|
||||||
inherit (lib) mkEnableOption mkIf mkOption types;
|
inherit (lib) mkEnableOption mkIf mkOption types split toIntBase10;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.bagel.hardware.raito-vm = {
|
options.bagel.hardware.raito-vm = {
|
||||||
|
@ -54,6 +54,17 @@ in
|
||||||
linkConfig.Name = "wan";
|
linkConfig.Name = "wan";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bagel.infra.self.wan =
|
||||||
|
let
|
||||||
|
parts = split "/" cfg.networking.wan.address;
|
||||||
|
address = builtins.elemAt parts 0;
|
||||||
|
prefixLength = toIntBase10 (builtins.elemAt 1 parts);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
family = "inet6";
|
||||||
|
inherit address prefixLength;
|
||||||
|
};
|
||||||
|
|
||||||
boot.loader.systemd-boot.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
|
||||||
boot.initrd.kernelModules = [
|
boot.initrd.kernelModules = [
|
||||||
|
|
|
@ -72,6 +72,12 @@
|
||||||
];
|
];
|
||||||
networking.defaultGateway6 = { interface = "uplink"; address = "2a01:584:11::1"; };
|
networking.defaultGateway6 = { interface = "uplink"; address = "2a01:584:11::1"; };
|
||||||
|
|
||||||
|
bagel.infra.self.wan = {
|
||||||
|
family = "inet6";
|
||||||
|
address = "2a01:584:11::1:11";
|
||||||
|
prefixLength = 64;
|
||||||
|
};
|
||||||
|
|
||||||
services.coredns = {
|
services.coredns = {
|
||||||
enable = true;
|
enable = true;
|
||||||
config = ''
|
config = ''
|
||||||
|
|
|
@ -135,6 +135,11 @@ in
|
||||||
{ address = "2a01:584:11::1:${toString cfg.num}"; prefixLength = 64; }
|
{ address = "2a01:584:11::1:${toString cfg.num}"; prefixLength = 64; }
|
||||||
];
|
];
|
||||||
networking.defaultGateway6 = { interface = "uplink"; address = "2a01:584:11::1"; };
|
networking.defaultGateway6 = { interface = "uplink"; address = "2a01:584:11::1"; };
|
||||||
|
bagel.infra.self.wan = {
|
||||||
|
family = "inet6";
|
||||||
|
address = "2a01:584:11::1:${toString cfg.num}";
|
||||||
|
prefixLength = 64;
|
||||||
|
};
|
||||||
deployment.targetHost = "2a01:584:11::1:${toString cfg.num}";
|
deployment.targetHost = "2a01:584:11::1:${toString cfg.num}";
|
||||||
deployment.tags = [ "builders" ];
|
deployment.tags = [ "builders" ];
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
./matrix
|
./matrix
|
||||||
./monitoring
|
./monitoring
|
||||||
./uptime-kuma
|
./uptime-kuma
|
||||||
|
./self
|
||||||
./netbox
|
./netbox
|
||||||
./ofborg
|
./ofborg
|
||||||
./postgres
|
./postgres
|
||||||
|
|
21
services/self/default.nix
Normal file
21
services/self/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# This is a data-only module for other modules consumption.
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.bagel.infra.self = {
|
||||||
|
wan = {
|
||||||
|
family = mkOption {
|
||||||
|
type = types.enum [ "inet" "inet6" ];
|
||||||
|
default = "inet6";
|
||||||
|
};
|
||||||
|
address = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
prefixLength = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue