2022-10-02 21:39:37 +02:00
|
|
|
{ lib, config, checks, utils, ... }:
|
2022-09-29 19:46:23 +02:00
|
|
|
let
|
|
|
|
cfg = config.deployment-dvb.net;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.deployment-dvb.net = with lib; {
|
|
|
|
iface.uplink = {
|
|
|
|
name = mkOption {
|
2022-10-02 21:39:37 +02:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2022-09-29 19:46:23 +02:00
|
|
|
};
|
|
|
|
useDHCP = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
addr4 = mkOption {
|
2022-10-02 21:39:37 +02:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2022-09-29 19:46:23 +02:00
|
|
|
description = "address with prefix in CIDR notation";
|
|
|
|
};
|
|
|
|
routes =
|
|
|
|
with utils.systemdUtils.unitOptions;
|
|
|
|
with utils.systemdUtils.lib;
|
|
|
|
with lib;
|
|
|
|
mkOption {
|
2022-10-02 21:39:37 +02:00
|
|
|
#type = with types; listOf (submodule routeOptions);
|
|
|
|
type = types.listOf (types.attrsOf unitOption);
|
2022-09-29 19:46:23 +02:00
|
|
|
default = [ ];
|
|
|
|
description = "default gateway";
|
|
|
|
};
|
|
|
|
dns = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ "9.9.9.9" "1.1.1.1" "8.8.8.8" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = let
|
|
|
|
upname = "30-${cfg.iface.uplink.name}";
|
|
|
|
upconf = if cfg.iface.uplink.useDHCP == false then {
|
2022-10-02 21:39:37 +02:00
|
|
|
matchConfig = { Name = "${cfg.iface.uplink.name}"; };
|
2022-09-29 19:46:23 +02:00
|
|
|
networkConfig = {
|
|
|
|
DHCP = "no";
|
|
|
|
Address = cfg.iface.uplink.addr4;
|
2022-10-02 21:39:37 +02:00
|
|
|
DNS = cfg.iface.uplink.dns;
|
2022-09-29 19:46:23 +02:00
|
|
|
};
|
|
|
|
routes = cfg.iface.uplink.routes;
|
|
|
|
} else {
|
2022-10-02 21:39:37 +02:00
|
|
|
matchConfig = { Name = "${cfg.iface.uplink.name}"; };
|
2022-09-29 19:46:23 +02:00
|
|
|
networkConfig = {
|
|
|
|
DHCP = "yes";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2022-10-02 21:39:37 +02:00
|
|
|
systemd.network.networks."${upname}" = upconf;
|
2022-09-29 19:46:23 +02:00
|
|
|
};
|
|
|
|
}
|