52 lines
1.2 KiB
Nix
52 lines
1.2 KiB
Nix
|
{ config, lib, ... }:
|
||
|
let
|
||
|
cfg = config.custom.platform.hetzner;
|
||
|
in
|
||
|
{
|
||
|
options.custom.platform.hetzner = {
|
||
|
enable = lib.mkOption {
|
||
|
type = lib.types.bool;
|
||
|
default = false;
|
||
|
};
|
||
|
ipv4Address = lib.mkOption {
|
||
|
type = with lib.types; nullOr (strMatching "^[0-9a-zA-Z:]+/32$");
|
||
|
default = null;
|
||
|
};
|
||
|
ipv6Address = lib.mkOption {
|
||
|
type = with lib.types; nullOr (strMatching "^[0-9a-zA-Z:]+/64$");
|
||
|
default = null;
|
||
|
};
|
||
|
interfaceName = lib.mkOption {
|
||
|
type = with lib.types; nullOr str;
|
||
|
default = "enp1s0";
|
||
|
};
|
||
|
};
|
||
|
|
||
|
config = lib.mkIf cfg.enable {
|
||
|
networking.networkmanager.enable = lib.mkForce false;
|
||
|
networking.useDHCP = false;
|
||
|
systemd.network.enable = true;
|
||
|
systemd.network.networks."30-wan" = {
|
||
|
matchConfig.Name = cfg.interfaceName;
|
||
|
networkConfig.DHCP = "no";
|
||
|
address = [
|
||
|
cfg.ipv4Address
|
||
|
cfg.ipv6Address
|
||
|
];
|
||
|
routes = [
|
||
|
{
|
||
|
Gateway = "172.31.1.1";
|
||
|
GatewayOnLink = true;
|
||
|
}
|
||
|
{ Gateway = "fe80::1"; }
|
||
|
];
|
||
|
};
|
||
|
|
||
|
boot.loader = {
|
||
|
efi.canTouchEfiVariables = false;
|
||
|
systemd-boot.enable = false;
|
||
|
grub.enable = true;
|
||
|
};
|
||
|
};
|
||
|
}
|