nixfiles/presets/nixos/serverHetzner.nix

87 lines
1.6 KiB
Nix
Raw Normal View History

2023-09-18 03:56:58 +01:00
{
self,
config,
modulesPath,
2023-09-20 15:46:20 +01:00
pkgs,
2023-09-18 03:56:58 +01:00
lib,
...
}: let
2023-09-20 15:46:20 +01:00
inherit (lib.lists) optionals;
2023-09-18 03:56:58 +01:00
inherit (lib.modules) mkForce;
2023-09-20 15:46:20 +01:00
system = pkgs.system;
2023-09-18 03:56:58 +01:00
container-ips = import "${self}/data/serverIPs.nix";
hostName = config.networking.hostName;
serverIPs = container-ips.${hostName};
2023-09-20 15:46:20 +01:00
gateway = "172.31.1.1";
netmask = "255.255.255.255";
2023-09-18 03:56:58 +01:00
in {
imports = [
2023-09-20 16:37:10 +01:00
(modulesPath + "/installer/scan/not-detected.nix")
2023-09-18 03:56:58 +01:00
(modulesPath + "/profiles/qemu-guest.nix")
];
systemd.services = {
systemd-networkd-wait-online.enable = mkForce false;
};
networking = {
usePredictableInterfaceNames = false;
dhcpcd.enable = false;
};
2023-09-20 16:18:44 +01:00
boot.initrd.kernelModules = [
"virtio_gpu"
"virtio_pci"
"virtio_net"
"virtio_scsi"
];
2023-09-20 15:46:20 +01:00
boot.kernelParams =
[
"console=tty0"
"ip=${serverIPs.ipv4}::${gateway}:${netmask}:${hostName}:enp1s0:any"
2023-09-20 16:18:44 +01:00
"boot.shell_on_fail"
"nohibernate"
"loglevel=4"
2023-09-20 15:46:20 +01:00
]
2023-09-20 16:59:45 +01:00
++ (lib.optionals (system == "aarch64-linux") ["console=tty" "console=ttyAMA0,115200" "console=ttyS0,115200"]);
2023-09-20 15:46:20 +01:00
2023-09-18 03:56:58 +01:00
systemd.network = {
enable = true;
2023-09-20 16:18:44 +01:00
networks."enp1s0" = {
name = "enp1s0";
2023-09-18 03:56:58 +01:00
networkConfig.DHCP = "no";
address = [
# v4
"${serverIPs.ipv4}/32"
# v6
"${serverIPs.ipv6}/64"
];
routes = [
# v4
{
routeConfig = {
Destination = "172.31.1.1";
};
}
{
routeConfig = {
Gateway = "172.31.1.1";
GatewayOnLink = true;
};
}
# v6
{
routeConfig.Gateway = "fe80::1";
}
];
};
};
}