-
Notifications
You must be signed in to change notification settings - Fork 2
/
hardware.nix
88 lines (78 loc) · 2.28 KB
/
hardware.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Storage deployment is defined in ./deployment/2-format-storage.sh
{ config, lib, pkgs, modulesPath, ... }:
let
hetznerDedicated = {
nixbitcoinorg.hardware = {
numCPUs = 12;
memorySizeGiB = 64;
};
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" ];
boot.kernelModules = [ "kvm-amd" ];
powerManagement.cpuFreqGovernor = "powersave";
hardware.cpu.amd.updateMicrocode = true;
};
hetznerCloud = {
nixbitcoinorg.hardware = {
numCPUs = 2;
memorySizeGiB = 2;
};
boot.initrd.availableKernelModules = [ "ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod" ];
};
# When a device marked with `nonessentialDevice` is unavailable,
# booting succeeds and systemd marks the system as degraded.
# This allows the system to boot when one device fails.
nonessentialDevice = [
"nofail"
"x-systemd.device-timeout=10s"
];
bindMount = srcPath: {
device = srcPath;
options = [ "bind" ];
# Silence warning:
# systemd-fstab-generator: Checking was requested for "<srcPath>", but it is not a device.
noCheck = true;
};
in
{
imports = [
hetznerDedicated
# hetznerCloud
];
boot.supportedFilesystems = [ "zfs" ];
# TODO-EXTERNAL:
# The filesystem definitions below can be replaced with zfs `mountpoint` attributes when
# https://github.com/NixOS/nixpkgs/issues/62644 has been implemented
fileSystems = {
"/" = {
device = "rpool/root";
fsType = "zfs";
};
"/nix" = {
device = "rpool/nix";
fsType = "zfs";
};
"/boot1" = {
device = "/dev/disk/by-label/boot1";
fsType = "vfat";
options = nonessentialDevice;
};
"/boot2" = {
device = "/dev/disk/by-label/boot2";
fsType = "vfat";
options = nonessentialDevice;
};
};
# Auto-mounting is not needed due to the manual mount settings (`fileSystems.*`)
systemd.services.zfs-mount.enable = false;
swapDevices = [
{ device = "/dev/disk/by-label/swap1"; options = nonessentialDevice; }
{ device = "/dev/disk/by-label/swap2"; options = nonessentialDevice; }
];
boot.loader.grub = {
enable = true;
mirroredBoots = [
{ path = "/boot1"; devices = [ "/dev/sda" ]; }
{ path = "/boot2"; devices = [ "/dev/sdb" ]; }
];
};
}