103 lines
2.6 KiB
Nix
103 lines
2.6 KiB
Nix
{
|
|
inputs,
|
|
flake,
|
|
self,
|
|
}:
|
|
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}: let
|
|
cfg = config.hectic.hardware.hetzner-cloud;
|
|
in {
|
|
options.hectic.hardware.hetzner-cloud = {
|
|
enable = lib.mkEnableOption "Enable hetzner-cloud hardware configurations";
|
|
#bootParUuid = lib.mkOption {
|
|
# type = with lib.types; nullOr oneOf [
|
|
# (lib.types.strMatching "^[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}$")
|
|
# (lib.types.strMatching "^[0-9a-fA-F-]{36}$")
|
|
# ];
|
|
# default = null;
|
|
# example = "5628-19B6";
|
|
# description = ''
|
|
# boot partition uuid if it is null
|
|
# then will use "/dev/sda15" (default hetzner cloud boot device)
|
|
# '';
|
|
#};
|
|
ip = 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";
|
|
description = ''
|
|
|
|
'';
|
|
};
|
|
device = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "/dev/sda";
|
|
example = "/dev/disk/by-uuid/f184a16b-6eca-41cb-b48a-ff37cdce1d79";
|
|
description = ''
|
|
boot device uuid
|
|
if it is null then will use "/dev/sda"
|
|
/dev/sda - default hetzner cloud device
|
|
!! But can changes on reboot if server have volumes
|
|
!! So use IDs
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
boot.loader.grub.device = cfg.device;
|
|
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; }
|
|
];
|
|
};
|
|
networking.defaultGateway = cfg.gatewayIp;
|
|
networking.nameservers = [ "1.1.1.1" "8.8.8.8" ];
|
|
|
|
disko.devices.disk.vda = {
|
|
device = cfg.device;
|
|
type = "disk";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
ESP = {
|
|
size = "512M";
|
|
type = "EF00";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = "/boot";
|
|
mountOptions = [ "umask=0077" ];
|
|
};
|
|
};
|
|
root = {
|
|
size = "100%";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "ext4";
|
|
mountpoint = "/";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|