From 1d153522415a90b7fe50a63485540b624a27bc97 Mon Sep 17 00:00:00 2001 From: janis Date: Fri, 5 Sep 2025 15:00:10 +0200 Subject: [PATCH] disk config for desktop with nvme-raid --- hosts/desktop/default.nix | 109 +++++++++++++++++++++++++++++++----- hosts/desktop/nvme-raid.nix | 108 +++++++++++++++++++++++++++++++++++ 2 files changed, 203 insertions(+), 14 deletions(-) create mode 100644 hosts/desktop/nvme-raid.nix diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index ca7e3d1..1f76edd 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -1,6 +1,6 @@ {lib, pkgs, config, modulesPath, ...}: { imports = [ - ./disks.nix + # ./nvme-raid.nix ../../options.nix (modulesPath + "/installer/scan/not-detected.nix") ]; @@ -14,38 +14,119 @@ "HDMI-A-1" = { pos = "1920 0"; }; }; - boot = { + fileSystems = { + "/boot" = { + device = "/dev/disk/by-uuid/EF81-FDEB"; + fsType = "vfat"; + options = [ "uid=0" "gid=0" "fmask=0077" "dmask=0077" ]; + }; + "/" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "subvol=@root" "noatime" "compress=zstd" ]; + }; + "/mnt/rootfs" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "noatime" "compress=zstd" ]; + }; + "/home" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "subvol=@home" "noatime" "compress=zstd" ]; + }; + "/var/games" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "subvol=@games" "noatime" "compress=zstd" ]; + }; + "/var/code" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "subvol=@code" "noatime" "compress=zstd" ]; + }; + "/var/log" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "subvol=@log" "noatime" "compress=zstd" ]; + }; + "/persist" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "subvol=@persist" "noatime" "compress=zstd" ]; + }; + "/nix" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "subvol=@nix" "noatime" "compress=zstd" ]; + }; + "/var/.snapshots" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "subvol=@snapshots" "noatime" "compress=zstd" ]; + }; + "/swap" = { + device = "/dev/mapper/crypt0"; + fsType = "btrfs"; + options = [ "subvol=@swap" ]; + }; + }; + + swapDevices = [ + { + device = "/swap/swapfile"; + } + ]; + + boot = { kernelParams = [ "quiet" "splash" "boot.shell_on_fail" "udev.log_priority=3" "rd.systemd.show_status=auto" + "mem_sleep_default=deep" + "resume_offset=533760" ]; + resumeDevice = "/dev/disk/by-uuid/c6442c5b-119b-4eba-82b3-0b9b89aab03f"; kernelModules = [ "kvm-intel" ]; extraModulePackages = [ ]; consoleLogLevel = 3; initrd = { + systemd.enable = true; + luks = { + devices = { + "crypt0" = { + device = "/dev/disk/by-uuid/7b5d31a2-0cc9-41a4-8ce4-d6b3a4c83f6a"; + allowDiscards = true; + }; + "crypt1" = { + device = "/dev/disk/by-uuid/bf7f6c09-ee13-4cb6-b56c-defd910b8265"; + allowDiscards = true; + }; + }; + }; + verbose = false; - - kernelModules = ["amdgpu" ]; availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" ]; + # kernelModules = ["amdgpu" ]; }; - plymouth = { - enable = true; - theme = "rings"; - themePackages = with pkgs; [ - (adi1090x-plymouth-themes.override { - selected_themes = ["rings"]; - } - ) - ]; - }; + plymouth.enable = true; + # plymouth = { + # enable = true; + # theme = "rings"; + # themePackages = with pkgs; [ + # (adi1090x-plymouth-themes.override { + # selected_themes = ["rings"]; + # } + # ) + # ]; + # }; }; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking diff --git a/hosts/desktop/nvme-raid.nix b/hosts/desktop/nvme-raid.nix new file mode 100644 index 0000000..cefdf74 --- /dev/null +++ b/hosts/desktop/nvme-raid.nix @@ -0,0 +1,108 @@ +{ + disko.devices = { + disk = { + nvme1 = { + type = "disk"; + device = "/dev/nvme1n1"; + content = { + type = "gpt"; + partitions = { + crypt0 = { + size = "100%"; + content = { + type = "luks"; + name = "crypt1"; + extraOpenArgs = [ + "--allow-discards" + ]; + settings = {crypttabExtraOpts = ["tpm2-device=auto" "token-timeout=10"];}; + }; + }; + }; + }; + }; + + nvme0 = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + label = "nixboot"; + name = "ESP"; + type = "EF00"; + size = "1G"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + + crypt0 = { + size = "100%"; + content = { + type = "luks"; + name = "crypt0"; + extraOpenArgs = [ + "--allow-discards" + ]; + settings = {crypttabExtraOpts = ["tpm2-device=auto" "token-timeout=10"];}; + content = { + type = "btrfs"; + extraArgs = [ + "-L" "nixos" "-f" + "-d single -m raid1" + "/dev/mapper/crypt1" + ]; + mountpoint = "/mnt/rootfs"; + mountOptions = ["compress=zstd" "noatime"]; + subvolumes = { + "@root" = { + mountpoint = "/"; + mountOptions = ["subvol=@root" "compress=zstd" "noatime"]; + }; + "@home" = { + mountpoint = "/home"; + mountOptions = ["subvol=@home" "compress=zstd" "noatime"]; + }; + "@games" = { + mountpoint = "/var/games"; + mountOptions = ["subvol=@games" "compress=zstd" "noatime"]; + }; + "@code" = { + mountpoint = "/var/code"; + mountOptions = ["subvol=@code" "compress=zstd" "noatime"]; + }; + "@nix" = { + mountpoint = "/nix"; + mountOptions = ["subvol=@nix" "compress=zstd" "noatime"]; + }; + "@persist" = { + mountpoint = "/persist"; + mountOptions = ["subvol=@persist" "compress=zstd" "noatime"]; + }; + "@log" = { + mountpoint = "/var/log"; + mountOptions = ["subvol=@log" "compress=zstd" "noatime"]; + }; + "@snapshots" = { + mountpoint = "/var/.snapshots"; + mountOptions = ["subvol=@snapshots" "compress=zstd" "noatime"]; + }; + "@swap" = { + mountpoint = "/swap"; + swap.swapfile.size = "64G"; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +}