mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 16:39:07 +01:00
networking: Unify underlay config across hosts
This commit is contained in:
parent
1d1709e1ba
commit
27b5c57023
19 changed files with 240 additions and 258 deletions
65
modules/system/networking/overlay.nix
Normal file
65
modules/system/networking/overlay.nix
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
config,
|
||||
self,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.networking.overlay;
|
||||
in
|
||||
{
|
||||
options.custom.networking.overlay = {
|
||||
networkCidr = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
networkAddress = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = cfg.networkCidr |> lib.splitString "/" |> lib.head;
|
||||
readOnly = true;
|
||||
};
|
||||
prefixLength = lib.mkOption {
|
||||
type = lib.types.ints.between 0 32;
|
||||
default = cfg.networkCidr |> lib.splitString "/" |> lib.last |> lib.toInt;
|
||||
};
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
|
||||
address = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
cidr = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "${cfg.address}/${toString cfg.prefixLength}";
|
||||
readOnly = true;
|
||||
};
|
||||
interface = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
systemdUnit = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
|
||||
isLighthouse = lib.mkEnableOption "";
|
||||
role = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"client"
|
||||
"server"
|
||||
];
|
||||
};
|
||||
|
||||
dnsServers = lib.mkOption {
|
||||
type = lib.types.anything;
|
||||
default =
|
||||
self.nixosConfigurations
|
||||
|> lib.attrValues
|
||||
|> lib.filter (host: host.config.custom.services.dns.enable)
|
||||
|> lib.map (host: host.config.custom.networking.overlay.address);
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue