From fd97c33c5613570e682f76b040f1e199fee3ba23 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Tue, 24 Dec 2024 21:17:36 +0800 Subject: [PATCH] treewide: dedup disko configuration --- nixos/hosts/flandre-m5p/disko-fs.nix | 72 ------------------- .../flandre-m5p/hardware-configuration.nix | 32 ++++++--- nixos/hosts/kanako-hkg0/disko-fs.nix | 56 --------------- .../kanako-hkg0/hardware-configuration.nix | 10 ++- nixos/hosts/marisa-7d76/disko-fs.nix | 69 ------------------ .../marisa-7d76/hardware-configuration.nix | 11 ++- nixos/hosts/marisa-a7s/disko-fs.nix | 69 ------------------ .../marisa-a7s/hardware-configuration.nix | 11 ++- nixos/hosts/reisen-fra0/disko-fs.nix | 57 --------------- .../reisen-fra0/hardware-configuration.nix | 10 ++- nixos/hosts/reisen-nrt0/disko-fs.nix | 57 --------------- .../reisen-nrt0/hardware-configuration.nix | 10 ++- nixos/hosts/reisen-sea0/disko-fs.nix | 57 --------------- .../reisen-sea0/hardware-configuration.nix | 10 ++- nixos/hosts/reisen-sin0/disko-fs.nix | 57 --------------- .../reisen-sin0/hardware-configuration.nix | 10 ++- nixos/hosts/suwako-vie0/disko-fs.nix | 56 --------------- .../suwako-vie0/hardware-configuration.nix | 10 ++- .../system/disko/btrfs-bios-compat.nix | 56 +++++++++++++++ nixos/profiles/system/disko/btrfs-common.nix | 57 +++++++++++++++ .../system/disko/luks-btrfs-common.nix | 69 ++++++++++++++++++ 21 files changed, 274 insertions(+), 572 deletions(-) create mode 100644 nixos/profiles/system/disko/btrfs-bios-compat.nix create mode 100644 nixos/profiles/system/disko/btrfs-common.nix create mode 100644 nixos/profiles/system/disko/luks-btrfs-common.nix diff --git a/nixos/hosts/flandre-m5p/disko-fs.nix b/nixos/hosts/flandre-m5p/disko-fs.nix index 7f0ea09..3c1c84d 100644 --- a/nixos/hosts/flandre-m5p/disko-fs.nix +++ b/nixos/hosts/flandre-m5p/disko-fs.nix @@ -1,76 +1,4 @@ { - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=8G" - "mode=755" - "nosuid" - "nodev" - ]; - }; - }; - disk = { - main = { - type = "disk"; - device = "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"; - content = { - type = "gpt"; - partitions = { - esp = { - label = "ESP"; - size = "2G"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - cryptroot = { - label = "CRYPTROOT"; - size = "100%"; - content = { - type = "luks"; - name = "cryptroot"; - settings = { - allowDiscards = true; - bypassWorkqueues = true; - crypttabExtraOpts = [ - "same-cpu-crypt" - "submit-from-crypt-cpus" - ]; - # unattended boot via usb - keyFile = "/dev/disk/by-id/usb-aigo_U330_80101016-0:0"; - keyFileSize = 512 * 64; - }; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "/persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = [ "compress=zstd" ]; - }; - }; - }; - }; - }; - }; - }; - }; - }; - }; - - fileSystems."/persist".neededForBoot = true; - environment.globalPersistence = { enable = true; root = "/persist"; diff --git a/nixos/hosts/flandre-m5p/hardware-configuration.nix b/nixos/hosts/flandre-m5p/hardware-configuration.nix index d67d029..c18afde 100644 --- a/nixos/hosts/flandre-m5p/hardware-configuration.nix +++ b/nixos/hosts/flandre-m5p/hardware-configuration.nix @@ -1,13 +1,29 @@ -{ ... }: +{ profiles, ... }: { + imports = with profiles; [ + system.disko.luks-btrfs-common + ]; + + disko.devices = { + nodev."/".mountOptions = [ "size=16G" ]; + disk.main.device = "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"; + }; + boot = { - initrd.availableKernelModules = [ - "xhci_pci" - "ahci" - "usbhid" - "usb_storage" - "sd_mod" - ]; + initrd = { + availableKernelModules = [ + "xhci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + # workaround for https://github.com/nix-community/disko/issues/678 + luks.devices.cryptroot = { + keyFile = "/dev/disk/by-id/usb-aigo_U330_80101016-0:0"; + keyFileSize = 512 * 64; + }; + }; kernelModules = [ "kvm-amd" ]; loader = { efi.canTouchEfiVariables = false; diff --git a/nixos/hosts/kanako-hkg0/disko-fs.nix b/nixos/hosts/kanako-hkg0/disko-fs.nix index f39b29a..3c1c84d 100644 --- a/nixos/hosts/kanako-hkg0/disko-fs.nix +++ b/nixos/hosts/kanako-hkg0/disko-fs.nix @@ -1,60 +1,4 @@ { - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=2G" - "mode=755" - "nosuid" - "nodev" - ]; - }; - }; - disk = { - main = { - type = "disk"; - device = "/dev/vda"; - content = { - type = "gpt"; - partitions = { - boot = { - type = "EF02"; - label = "BOOT"; - start = "0"; - end = "+1M"; - }; - root = { - label = "ROOT"; - end = "-0"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "boot" = { - mountpoint = "/boot"; - mountOptions = [ "compress=zstd" ]; - }; - "nix" = { - mountpoint = "/nix"; - mountOptions = [ "compress=zstd" ]; - }; - "persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; - }; - }; - }; - }; - }; - }; - }; - }; - - fileSystems."/persist".neededForBoot = true; - environment.globalPersistence = { enable = true; root = "/persist"; diff --git a/nixos/hosts/kanako-hkg0/hardware-configuration.nix b/nixos/hosts/kanako-hkg0/hardware-configuration.nix index 7243c37..5918654 100644 --- a/nixos/hosts/kanako-hkg0/hardware-configuration.nix +++ b/nixos/hosts/kanako-hkg0/hardware-configuration.nix @@ -1,9 +1,15 @@ -{ modulesPath, ... }: +{ modulesPath, profiles, ... }: { - imports = [ + imports = with profiles; [ (modulesPath + "/profiles/qemu-guest.nix") + system.disko.btrfs-bios-compat ]; + disko.devices = { + nodev."/".mountOptions = [ "size=2G" ]; + disk.main.device = "/dev/vda"; + }; + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" diff --git a/nixos/hosts/marisa-7d76/disko-fs.nix b/nixos/hosts/marisa-7d76/disko-fs.nix index 6ebeccf..3c1c84d 100644 --- a/nixos/hosts/marisa-7d76/disko-fs.nix +++ b/nixos/hosts/marisa-7d76/disko-fs.nix @@ -1,73 +1,4 @@ { - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=8G" - "mode=755" - "nosuid" - "nodev" - ]; - }; - }; - disk = { - main = { - type = "disk"; - device = "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"; - content = { - type = "gpt"; - partitions = { - esp = { - label = "ESP"; - size = "2G"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - cryptroot = { - label = "CRYPTROOT"; - size = "100%"; - content = { - type = "luks"; - name = "cryptroot"; - settings = { - allowDiscards = true; - bypassWorkqueues = true; - crypttabExtraOpts = [ - "same-cpu-crypt" - "submit-from-crypt-cpus" - ]; - }; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "/persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = [ "compress=zstd" ]; - }; - }; - }; - }; - }; - }; - }; - }; - }; - }; - - fileSystems."/persist".neededForBoot = true; - environment.globalPersistence = { enable = true; root = "/persist"; diff --git a/nixos/hosts/marisa-7d76/hardware-configuration.nix b/nixos/hosts/marisa-7d76/hardware-configuration.nix index 2fdd50c..80d1b15 100644 --- a/nixos/hosts/marisa-7d76/hardware-configuration.nix +++ b/nixos/hosts/marisa-7d76/hardware-configuration.nix @@ -1,5 +1,14 @@ -{ lib, ... }: +{ profiles, lib, ... }: { + imports = with profiles; [ + system.disko.luks-btrfs-common + ]; + + disko.devices = { + nodev."/".mountOptions = [ "size=8G" ]; + disk.main.device = "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"; + }; + boot = { initrd.availableKernelModules = [ "nvme" diff --git a/nixos/hosts/marisa-a7s/disko-fs.nix b/nixos/hosts/marisa-a7s/disko-fs.nix index 6ebeccf..3c1c84d 100644 --- a/nixos/hosts/marisa-a7s/disko-fs.nix +++ b/nixos/hosts/marisa-a7s/disko-fs.nix @@ -1,73 +1,4 @@ { - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=8G" - "mode=755" - "nosuid" - "nodev" - ]; - }; - }; - disk = { - main = { - type = "disk"; - device = "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"; - content = { - type = "gpt"; - partitions = { - esp = { - label = "ESP"; - size = "2G"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - cryptroot = { - label = "CRYPTROOT"; - size = "100%"; - content = { - type = "luks"; - name = "cryptroot"; - settings = { - allowDiscards = true; - bypassWorkqueues = true; - crypttabExtraOpts = [ - "same-cpu-crypt" - "submit-from-crypt-cpus" - ]; - }; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "/persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = [ "compress=zstd" ]; - }; - }; - }; - }; - }; - }; - }; - }; - }; - }; - - fileSystems."/persist".neededForBoot = true; - environment.globalPersistence = { enable = true; root = "/persist"; diff --git a/nixos/hosts/marisa-a7s/hardware-configuration.nix b/nixos/hosts/marisa-a7s/hardware-configuration.nix index f6bd14b..b47be6b 100644 --- a/nixos/hosts/marisa-a7s/hardware-configuration.nix +++ b/nixos/hosts/marisa-a7s/hardware-configuration.nix @@ -1,5 +1,14 @@ -{ lib, ... }: +{ profiles, lib, ... }: { + imports = with profiles; [ + system.disko.luks-btrfs-common + ]; + + disko.devices = { + nodev."/".mountOptions = [ "size=8G" ]; + disk.main.device = "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"; + }; + boot = { initrd.availableKernelModules = [ "nvme" diff --git a/nixos/hosts/reisen-fra0/disko-fs.nix b/nixos/hosts/reisen-fra0/disko-fs.nix index a7dfff3..3c1c84d 100644 --- a/nixos/hosts/reisen-fra0/disko-fs.nix +++ b/nixos/hosts/reisen-fra0/disko-fs.nix @@ -1,61 +1,4 @@ { - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=1G" - "mode=755" - "nosuid" - "nodev" - ]; - }; - }; - disk = { - main = { - type = "disk"; - device = "/dev/vda"; - content = { - type = "gpt"; - partitions = { - esp = { - label = "ESP"; - size = "2G"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - root = { - label = "ROOT"; - size = "100%"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "/persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = [ "compress=zstd" ]; - }; - }; - }; - }; - }; - }; - }; - }; - }; - - fileSystems."/persist".neededForBoot = true; - environment.globalPersistence = { enable = true; root = "/persist"; diff --git a/nixos/hosts/reisen-fra0/hardware-configuration.nix b/nixos/hosts/reisen-fra0/hardware-configuration.nix index 01e71d7..9057695 100644 --- a/nixos/hosts/reisen-fra0/hardware-configuration.nix +++ b/nixos/hosts/reisen-fra0/hardware-configuration.nix @@ -1,9 +1,15 @@ -{ modulesPath, ... }: +{ modulesPath, profiles, ... }: { - imports = [ + imports = with profiles; [ (modulesPath + "/profiles/qemu-guest.nix") + system.disko.btrfs-common ]; + disko.devices = { + nodev."/".mountOptions = [ "size=1G" ]; + disk.main.device = "/dev/vda"; + }; + boot = { loader = { efi.canTouchEfiVariables = true; diff --git a/nixos/hosts/reisen-nrt0/disko-fs.nix b/nixos/hosts/reisen-nrt0/disko-fs.nix index a7dfff3..3c1c84d 100644 --- a/nixos/hosts/reisen-nrt0/disko-fs.nix +++ b/nixos/hosts/reisen-nrt0/disko-fs.nix @@ -1,61 +1,4 @@ { - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=1G" - "mode=755" - "nosuid" - "nodev" - ]; - }; - }; - disk = { - main = { - type = "disk"; - device = "/dev/vda"; - content = { - type = "gpt"; - partitions = { - esp = { - label = "ESP"; - size = "2G"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - root = { - label = "ROOT"; - size = "100%"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "/persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = [ "compress=zstd" ]; - }; - }; - }; - }; - }; - }; - }; - }; - }; - - fileSystems."/persist".neededForBoot = true; - environment.globalPersistence = { enable = true; root = "/persist"; diff --git a/nixos/hosts/reisen-nrt0/hardware-configuration.nix b/nixos/hosts/reisen-nrt0/hardware-configuration.nix index 01e71d7..9057695 100644 --- a/nixos/hosts/reisen-nrt0/hardware-configuration.nix +++ b/nixos/hosts/reisen-nrt0/hardware-configuration.nix @@ -1,9 +1,15 @@ -{ modulesPath, ... }: +{ modulesPath, profiles, ... }: { - imports = [ + imports = with profiles; [ (modulesPath + "/profiles/qemu-guest.nix") + system.disko.btrfs-common ]; + disko.devices = { + nodev."/".mountOptions = [ "size=1G" ]; + disk.main.device = "/dev/vda"; + }; + boot = { loader = { efi.canTouchEfiVariables = true; diff --git a/nixos/hosts/reisen-sea0/disko-fs.nix b/nixos/hosts/reisen-sea0/disko-fs.nix index a7dfff3..3c1c84d 100644 --- a/nixos/hosts/reisen-sea0/disko-fs.nix +++ b/nixos/hosts/reisen-sea0/disko-fs.nix @@ -1,61 +1,4 @@ { - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=1G" - "mode=755" - "nosuid" - "nodev" - ]; - }; - }; - disk = { - main = { - type = "disk"; - device = "/dev/vda"; - content = { - type = "gpt"; - partitions = { - esp = { - label = "ESP"; - size = "2G"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - root = { - label = "ROOT"; - size = "100%"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "/persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = [ "compress=zstd" ]; - }; - }; - }; - }; - }; - }; - }; - }; - }; - - fileSystems."/persist".neededForBoot = true; - environment.globalPersistence = { enable = true; root = "/persist"; diff --git a/nixos/hosts/reisen-sea0/hardware-configuration.nix b/nixos/hosts/reisen-sea0/hardware-configuration.nix index 01e71d7..9057695 100644 --- a/nixos/hosts/reisen-sea0/hardware-configuration.nix +++ b/nixos/hosts/reisen-sea0/hardware-configuration.nix @@ -1,9 +1,15 @@ -{ modulesPath, ... }: +{ modulesPath, profiles, ... }: { - imports = [ + imports = with profiles; [ (modulesPath + "/profiles/qemu-guest.nix") + system.disko.btrfs-common ]; + disko.devices = { + nodev."/".mountOptions = [ "size=1G" ]; + disk.main.device = "/dev/vda"; + }; + boot = { loader = { efi.canTouchEfiVariables = true; diff --git a/nixos/hosts/reisen-sin0/disko-fs.nix b/nixos/hosts/reisen-sin0/disko-fs.nix index a7dfff3..3c1c84d 100644 --- a/nixos/hosts/reisen-sin0/disko-fs.nix +++ b/nixos/hosts/reisen-sin0/disko-fs.nix @@ -1,61 +1,4 @@ { - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=1G" - "mode=755" - "nosuid" - "nodev" - ]; - }; - }; - disk = { - main = { - type = "disk"; - device = "/dev/vda"; - content = { - type = "gpt"; - partitions = { - esp = { - label = "ESP"; - size = "2G"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - root = { - label = "ROOT"; - size = "100%"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "/persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = [ "compress=zstd" ]; - }; - }; - }; - }; - }; - }; - }; - }; - }; - - fileSystems."/persist".neededForBoot = true; - environment.globalPersistence = { enable = true; root = "/persist"; diff --git a/nixos/hosts/reisen-sin0/hardware-configuration.nix b/nixos/hosts/reisen-sin0/hardware-configuration.nix index 01e71d7..9057695 100644 --- a/nixos/hosts/reisen-sin0/hardware-configuration.nix +++ b/nixos/hosts/reisen-sin0/hardware-configuration.nix @@ -1,9 +1,15 @@ -{ modulesPath, ... }: +{ modulesPath, profiles, ... }: { - imports = [ + imports = with profiles; [ (modulesPath + "/profiles/qemu-guest.nix") + system.disko.btrfs-common ]; + disko.devices = { + nodev."/".mountOptions = [ "size=1G" ]; + disk.main.device = "/dev/vda"; + }; + boot = { loader = { efi.canTouchEfiVariables = true; diff --git a/nixos/hosts/suwako-vie0/disko-fs.nix b/nixos/hosts/suwako-vie0/disko-fs.nix index 6a86320..3c1c84d 100644 --- a/nixos/hosts/suwako-vie0/disko-fs.nix +++ b/nixos/hosts/suwako-vie0/disko-fs.nix @@ -1,60 +1,4 @@ { - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=4G" - "mode=755" - "nosuid" - "nodev" - ]; - }; - }; - disk = { - main = { - type = "disk"; - device = "/dev/sda"; - content = { - type = "gpt"; - partitions = { - boot = { - type = "EF02"; - label = "BOOT"; - start = "0"; - end = "+1M"; - }; - root = { - label = "ROOT"; - end = "-0"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "boot" = { - mountpoint = "/boot"; - mountOptions = [ "compress=zstd" ]; - }; - "nix" = { - mountpoint = "/nix"; - mountOptions = [ "compress=zstd" ]; - }; - "persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; - }; - }; - }; - }; - }; - }; - }; - }; - - fileSystems."/persist".neededForBoot = true; - environment.globalPersistence = { enable = true; root = "/persist"; diff --git a/nixos/hosts/suwako-vie0/hardware-configuration.nix b/nixos/hosts/suwako-vie0/hardware-configuration.nix index f497a46..7580870 100644 --- a/nixos/hosts/suwako-vie0/hardware-configuration.nix +++ b/nixos/hosts/suwako-vie0/hardware-configuration.nix @@ -1,9 +1,15 @@ -{ modulesPath, ... }: +{ modulesPath, profiles, ... }: { - imports = [ + imports = with profiles; [ (modulesPath + "/profiles/qemu-guest.nix") + system.disko.btrfs-bios-compat ]; + disko.devices = { + nodev."/".mountOptions = [ "size=4G" ]; + disk.main.device = "/dev/sda"; + }; + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" diff --git a/nixos/profiles/system/disko/btrfs-bios-compat.nix b/nixos/profiles/system/disko/btrfs-bios-compat.nix new file mode 100644 index 0000000..57aecdc --- /dev/null +++ b/nixos/profiles/system/disko/btrfs-bios-compat.nix @@ -0,0 +1,56 @@ +{ ... }: +{ + disko.devices = { + nodev = { + "/" = { + fsType = "tmpfs"; + mountOptions = [ + "defaults" + "mode=755" + "nosuid" + "nodev" + ]; + }; + }; + disk = { + main = { + type = "disk"; + content = { + type = "gpt"; + partitions = { + boot = { + type = "EF02"; + label = "BOOT"; + start = "0"; + end = "+1M"; + }; + root = { + label = "ROOT"; + end = "-0"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/boot" = { + mountpoint = "/boot"; + mountOptions = [ "compress=zstd" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" ]; + }; + "/persist" = { + mountpoint = "/persist"; + mountOptions = [ "compress=zstd" ]; + }; + }; + }; + }; + }; + }; + }; + }; + }; + + fileSystems."/persist".neededForBoot = true; +} diff --git a/nixos/profiles/system/disko/btrfs-common.nix b/nixos/profiles/system/disko/btrfs-common.nix new file mode 100644 index 0000000..21bd808 --- /dev/null +++ b/nixos/profiles/system/disko/btrfs-common.nix @@ -0,0 +1,57 @@ +{ ... }: +{ + disko.devices = { + nodev = { + "/" = { + fsType = "tmpfs"; + mountOptions = [ + "defaults" + "mode=755" + "nosuid" + "nodev" + ]; + }; + }; + disk = { + main = { + type = "disk"; + content = { + type = "gpt"; + partitions = { + esp = { + label = "ESP"; + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + root = { + label = "ROOT"; + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" ]; + }; + "/persist" = { + mountpoint = "/persist"; + mountOptions = [ "compress=zstd" ]; + }; + }; + }; + }; + }; + }; + }; + }; + }; + + fileSystems."/persist".neededForBoot = true; +} diff --git a/nixos/profiles/system/disko/luks-btrfs-common.nix b/nixos/profiles/system/disko/luks-btrfs-common.nix new file mode 100644 index 0000000..5fc9f16 --- /dev/null +++ b/nixos/profiles/system/disko/luks-btrfs-common.nix @@ -0,0 +1,69 @@ +{ ... }: +{ + disko.devices = { + nodev = { + "/" = { + fsType = "tmpfs"; + mountOptions = [ + "defaults" + "mode=755" + "nosuid" + "nodev" + ]; + }; + }; + disk = { + main = { + type = "disk"; + content = { + type = "gpt"; + partitions = { + esp = { + label = "ESP"; + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + cryptroot = { + label = "CRYPTROOT"; + size = "100%"; + content = { + type = "luks"; + name = "cryptroot"; + settings = { + allowDiscards = true; + bypassWorkqueues = true; + crypttabExtraOpts = [ + "same-cpu-crypt" + "submit-from-crypt-cpus" + ]; + }; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" ]; + }; + "/persist" = { + mountpoint = "/persist"; + mountOptions = [ "compress=zstd" ]; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + + fileSystems."/persist".neededForBoot = true; +}