mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 21:19:07 +01:00
94 lines
2.4 KiB
Nix
94 lines
2.4 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
allHosts,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.custom.networking.overlay;
|
|
in
|
|
{
|
|
options.custom.networking.overlay = {
|
|
networkCidr = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "10.254.250.0/24";
|
|
};
|
|
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;
|
|
readOnly = true;
|
|
};
|
|
domain = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "splitleaf.de";
|
|
};
|
|
fqdn = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "${config.custom.networking.hostName}.${cfg.domain}";
|
|
};
|
|
|
|
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 = "nebula";
|
|
};
|
|
systemdUnit = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "nebula@mesh.service";
|
|
};
|
|
|
|
isLighthouse = lib.mkEnableOption "";
|
|
|
|
advertise = {
|
|
address = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.nonEmptyStr;
|
|
default =
|
|
if config.custom.networking.underlay.isPublic then
|
|
config.custom.networking.underlay.address
|
|
else
|
|
null;
|
|
};
|
|
port = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.port;
|
|
default = if cfg.advertise.address != null then config.custom.services.nebula.listenPort else null;
|
|
};
|
|
};
|
|
|
|
role = lib.mkOption {
|
|
type = lib.types.enum [
|
|
"client"
|
|
"server"
|
|
];
|
|
};
|
|
|
|
dnsServers = lib.mkOption {
|
|
type = lib.types.anything;
|
|
default =
|
|
allHosts
|
|
|> lib.attrValues
|
|
|> lib.filter (host: host.config.custom.services.recursive-nameserver.enable)
|
|
|> lib.map (
|
|
host:
|
|
"${host.config.custom.networking.overlay.address}:${toString host.config.custom.services.recursive-nameserver.port}"
|
|
);
|
|
};
|
|
|
|
implementation = lib.mkOption {
|
|
type = lib.types.enum [ "nebula" ];
|
|
default = "nebula";
|
|
};
|
|
};
|
|
}
|