refactor(nixos): modules: hetzner hardware

This commit is contained in:
2025-10-22 09:10:44 +00:00
parent 3bfc5799c7
commit fafc1c4664

View File

@@ -25,16 +25,16 @@ in {
# then will use "/dev/sda15" (default hetzner cloud boot device) # then will use "/dev/sda15" (default hetzner cloud boot device)
# ''; # '';
#}; #};
ip = lib.mkOption { ipv4 = lib.mkOption {
type = lib.types.strMatching "^([0-9]{1,3}\\.){3}[0-9]{1,3}$"; type = lib.types.strMatching "^([0-9]{1,3}\\.){3}[0-9]{1,3}$";
example = "188.243.124.246"; example = "188.243.124.246";
description = '' description = ''
''; '';
}; };
gatewayIp = lib.mkOption { ipv6 = lib.mkOption {
type = lib.types.strMatching "^([0-9]{1,3}\\.){3}[0-9]{1,3}$"; type = lib.types.strMatching "^([0-9a-fA-F]{1,4}:){3}[0-9a-fA-F]{1,4}$";
example = "188.243.124.246"; example = "2a01:4f8:1c1a:d883";
description = '' description = ''
''; '';
@@ -53,30 +53,42 @@ in {
}; };
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable (lib.mkMerge
boot.loader.grub.device = cfg.device; [
{
boot.initrd.availableKernelModules = [ boot.initrd.availableKernelModules = [
"ata_piix" "ata_piix"
"uhci_hcd" "uhci_hcd"
"xen_blkfront" "xen_blkfront"
] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []); ] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
boot.initrd.kernelModules = ["nvme"];
networking.useDHCP = false; systemd.network.enable = true;
networking.interfaces.ens3 = { systemd.network.networks."30-wan" = {
ipv4.addresses = [ matchConfig.Name = "ens3";
{ address = cfg.ip; prefixLength = 24; } networkConfig.DHCP = "no";
address = [
"${cfg.ipv4}/32"
"${cfg.ipv6}::/64"
];
routes = [
{ Gateway = "172.31.1.1"; GatewayOnLink = true; }
{ Gateway = "fe80::1"; }
]; ];
}; };
networking.defaultGateway = cfg.gatewayIp;
networking.nameservers = [ "1.1.1.1" "8.8.8.8" ];
disko.devices.disk.vda = { disko.devices = {
device = cfg.device; disk = {
main = {
type = "disk"; type = "disk";
device = cfg.device;
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
boot = {
size = "1M";
type = "EF02";
priority = 1;
};
ESP = { ESP = {
size = "512M"; size = "512M";
type = "EF00"; type = "EF00";
@@ -84,7 +96,6 @@ in {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
mountpoint = "/boot"; mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
}; };
}; };
root = { root = {
@@ -99,4 +110,11 @@ in {
}; };
}; };
}; };
};
}
(lib.mkIf (pkgs.system == "aarch64-linux") {
boot.initrd.kernelModules = [ "virtio_gpu" ];
boot.kernelParams = [ "console=tty" ];
})
]);
} }