refactor(nixos): modules: hetzner hardware
This commit is contained in:
@@ -25,16 +25,16 @@ in {
|
||||
# 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}$";
|
||||
example = "188.243.124.246";
|
||||
description = ''
|
||||
|
||||
'';
|
||||
};
|
||||
gatewayIp = lib.mkOption {
|
||||
type = lib.types.strMatching "^([0-9]{1,3}\\.){3}[0-9]{1,3}$";
|
||||
example = "188.243.124.246";
|
||||
ipv6 = lib.mkOption {
|
||||
type = lib.types.strMatching "^([0-9a-fA-F]{1,4}:){3}[0-9a-fA-F]{1,4}$";
|
||||
example = "2a01:4f8:1c1a:d883";
|
||||
description = ''
|
||||
|
||||
'';
|
||||
@@ -53,30 +53,42 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.loader.grub.device = cfg.device;
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge
|
||||
[
|
||||
{
|
||||
boot.initrd.availableKernelModules = [
|
||||
"ata_piix"
|
||||
"uhci_hcd"
|
||||
"xen_blkfront"
|
||||
] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
|
||||
boot.initrd.kernelModules = ["nvme"];
|
||||
|
||||
networking.useDHCP = false;
|
||||
networking.interfaces.ens3 = {
|
||||
ipv4.addresses = [
|
||||
{ address = cfg.ip; prefixLength = 24; }
|
||||
systemd.network.enable = true;
|
||||
systemd.network.networks."30-wan" = {
|
||||
matchConfig.Name = "ens3";
|
||||
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 = {
|
||||
device = cfg.device;
|
||||
disko.devices = {
|
||||
disk = {
|
||||
main = {
|
||||
type = "disk";
|
||||
device = cfg.device;
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
size = "1M";
|
||||
type = "EF02";
|
||||
priority = 1;
|
||||
};
|
||||
ESP = {
|
||||
size = "512M";
|
||||
type = "EF00";
|
||||
@@ -84,7 +96,6 @@ in {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = [ "umask=0077" ];
|
||||
};
|
||||
};
|
||||
root = {
|
||||
@@ -99,4 +110,11 @@ in {
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
(lib.mkIf (pkgs.system == "aarch64-linux") {
|
||||
boot.initrd.kernelModules = [ "virtio_gpu" ];
|
||||
boot.kernelParams = [ "console=tty" ];
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user