mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 15:11:34 +01:00
90 lines
2.1 KiB
Nix
90 lines
2.1 KiB
Nix
{
|
|
config,
|
|
self,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.custom.networking;
|
|
in
|
|
{
|
|
options.custom.networking = {
|
|
hostname = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = config.networking.hostName;
|
|
readOnly = true;
|
|
};
|
|
isLighthouse = lib.mkEnableOption "";
|
|
isServer = lib.mkEnableOption "";
|
|
isClient = lib.mkEnableOption "";
|
|
|
|
overlay = {
|
|
networkAddress = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "10.254.250.0";
|
|
readOnly = true;
|
|
};
|
|
prefixLength = lib.mkOption {
|
|
type = lib.types.ints.between 0 32;
|
|
default = 24;
|
|
readOnly = true;
|
|
};
|
|
domain = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "splitleaf.de";
|
|
readOnly = true;
|
|
};
|
|
|
|
address = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "";
|
|
};
|
|
interface = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "nebula";
|
|
};
|
|
systemdUnit = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "nebula@mesh.service";
|
|
};
|
|
};
|
|
|
|
underlay = {
|
|
interface = lib.mkOption {
|
|
type = lib.types.nonEmptyStr;
|
|
default = "";
|
|
};
|
|
useDhcp = lib.mkEnableOption "";
|
|
isPublic = lib.mkEnableOption "";
|
|
address = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.nonEmptyStr;
|
|
default = null;
|
|
};
|
|
gateway = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.nonEmptyStr;
|
|
default = null;
|
|
};
|
|
};
|
|
|
|
nodes = lib.mkOption {
|
|
type = lib.types.anything;
|
|
default =
|
|
self.nixosConfigurations
|
|
|> lib.attrValues
|
|
|> lib.map (host: host.config.custom.networking)
|
|
|> lib.map (
|
|
node:
|
|
lib.removeAttrs node [
|
|
"nodes"
|
|
"peers"
|
|
]
|
|
);
|
|
readOnly = true;
|
|
};
|
|
peers = lib.mkOption {
|
|
type = lib.types.anything;
|
|
default = cfg.nodes |> lib.filter (node: node.hostname != cfg.hostname);
|
|
readOnly = true;
|
|
};
|
|
};
|
|
}
|