From 43d37864dbd40625f8e994d71d512a38de420122 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 2 Feb 2026 15:33:26 +0900 Subject: [PATCH] hosts/xps16: use disko as source of truth for `fileSystems` --- flake.nix | 4 +- hosts/xps16/configuration.nix | 1 + hosts/xps16/disks.nix | 149 +++++++++++++++++++++++++ hosts/xps16/hardware-configuration.nix | 93 --------------- 4 files changed, 153 insertions(+), 94 deletions(-) create mode 100644 hosts/xps16/disks.nix diff --git a/flake.nix b/flake.nix index e6adc3b..fe3802f 100644 --- a/flake.nix +++ b/flake.nix @@ -12,7 +12,7 @@ }; disko = { - url = "github:nix-community/disko/v1.12.0"; + url = "github:nix-community/disko/v1.13.0"; inputs.nixpkgs.follows = "nixpkgs"; }; @@ -309,6 +309,8 @@ nixos-hardware.nixosModules.common-pc-laptop-ssd nixos-hardware.nixosModules.common-cpu-intel nixos-hardware.nixosModules.common-gpu-intel + + disko.nixosModules.default ]; }; tsuki = nixSys "tsuki" { diff --git a/hosts/xps16/configuration.nix b/hosts/xps16/configuration.nix index 4b96707..547f169 100644 --- a/hosts/xps16/configuration.nix +++ b/hosts/xps16/configuration.nix @@ -5,6 +5,7 @@ ./apparmor.nix ./ipu6.nix + ./disks.nix ./services/btrfs.nix ./services/docker.nix diff --git a/hosts/xps16/disks.nix b/hosts/xps16/disks.nix new file mode 100644 index 0000000..b5a2d17 --- /dev/null +++ b/hosts/xps16/disks.nix @@ -0,0 +1,149 @@ +{ lib, ... }: +{ + disko.devices = { + disk = { + sda = { + name = "KXG80ZN84T09 NVMe KIOXIA 4096GB"; + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + win-efi = { + uuid = "24d18ca3-d1c0-4fd5-a1f5-c2ef18c3414a"; + name = "EFI system partition"; + label = "ESP"; + start = "2048"; + size = "409600"; + }; + + win-reserved = { + uuid = "7502d3d7-6116-4d9f-afdc-4bb3507a4ae8"; + name = "Microsoft reserved partition"; + start = "411648"; + size = "262144"; + }; + + win-os = { + uuid = "5944d017-36ce-41c9-9b7c-d6b948a3cc3b"; + name = "Basic data partition"; + label = "OS"; + start = "673792"; + size = "1309978624"; + }; + + win-retools = { + uuid = "95b4cc0e-673f-496a-9ec8-425b089fad2e"; + label = "WINRETOOLS"; + start = "7946752000"; + size = "2027520"; + attributes = [ + 0 # Required Partition + 63 # Do Not Automount + ]; + }; + + win-image = { + uuid = "5e187978-7467-4f35-87bf-167cc23b9e43"; + label = "Image"; + start = "7948779520"; + size = "49674240"; + attributes = [ + 0 # Required Partition + 63 # Do Not Automount + ]; + }; + + win-dellsupport = { + uuid = "02f392b7-8a95-48ee-bd4f-2baad5b1595c"; + label = "DELLSUPPORT"; + start = "7998455808"; + size = "3084288"; + attributes = [ + 0 # Required Partition + 63 # Do Not Automount + ]; + }; + + # ----------------------------------------- # + # This is where the interesting part starts # + + boot = { + uuid = "56cc4363-d1be-4518-8bea-728a4f70464c"; + label = "nixos-boot"; + start = "1310652416"; + size = "2097152"; + + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "discard" "umask=0077" ]; + }; + }; + + nixos = { + uuid = "f6995107-19e2-476e-aab4-f414127d7303"; + label = "nixos"; + start = " 1312749568"; + size = "100%"; + + content = { + type = "luks"; + name = "crypted"; + + settings = { + + }; + + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; # Override existing partition + subvolumes = let + makeSnapshottable = subvolPath: mountOptions: let + # name = lib.replaceString "/" "-" subvolPath; + name = lib.removePrefix "/" subvolPath; + in { + "${name}/active" = { + mountpoint = subvolPath; + inherit mountOptions; + }; + "${name}/snapshots" = { + mountpoint = "${subvolPath}/.snapshots"; + inherit mountOptions; + }; + }; + in lib.foldl (x: y: x // y) { } [ + { + "@" = { }; + # "swap" = { + # mountpoint = "/.swapvol"; + # swap.swapfile.size = "8G"; + # }; + "root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "var/lib/docker" = { + mountpoint = "/var/lib/docker"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + } + (makeSnapshottable "/home/h7x4" [ "compress=zstd" "noatime" "nodev" ]) + (makeSnapshottable "/home/h7x4/git" [ "compress=zstd" "noatime" "nodev" ]) + (makeSnapshottable "/home/h7x4/ctf" [ "compress=zstd" "noatime" "nodev" ]) + (makeSnapshottable "/home/h7x4/downloads" [ "compress=zstd" "noatime" "nosuid" "nodev" ]) + (makeSnapshottable "/home/h7x4/pictures" [ "compress=zstd" "noatime" "noexec" "nosuid" "nodev" ]) + (makeSnapshottable "/home/h7x4/music" [ "compress=zstd" "noatime" "noexec" "nosuid" "nodev" ]) + (makeSnapshottable "/var/log" [ "compress=zstd" "noatime" "noexec" "nosuid" "nodev" ]) + (makeSnapshottable "/var/lib" [ "compress=zstd" "noatime" "nosuid" "nodev" ]) + ]; + }; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/xps16/hardware-configuration.nix b/hosts/xps16/hardware-configuration.nix index 17a4593..76198b5 100644 --- a/hosts/xps16/hardware-configuration.nix +++ b/hosts/xps16/hardware-configuration.nix @@ -13,99 +13,6 @@ boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=root" "compress=zstd" "noatime" ]; - }; - - boot.initrd.luks.devices."crypted".device = "/dev/disk/by-uuid/88bbd92a-88b5-4175-9d6f-c14033607b70"; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/34BA-6EA6"; - fsType = "vfat"; - }; - - fileSystems."/home/h7x4" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=home/h7x4/active" "compress=zstd" "noatime" ]; - }; - - fileSystems."/home/h7x4/.snapshots" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=home/h7x4/snapshots" "compress=zstd" "noatime" ]; - }; - - fileSystems."/home/h7x4/git" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=home/h7x4/git/active" "compress=zstd" "noatime" ]; - }; - - fileSystems."/home/h7x4/ctf" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=home/h7x4/ctf/active" "compress=zstd" "noatime" ]; - }; - - fileSystems."/home/h7x4/downloads" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=home/h7x4/downloads/active" "compress=zstd" "noatime" ]; - }; - - fileSystems."/home/h7x4/pictures" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=home/h7x4/pictures/active" "compress=zstd" "noatime" ]; - }; - - fileSystems."/home/h7x4/music" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=home/h7x4/music/active" "compress=zstd" "noatime" ]; - }; - - fileSystems."/home/h7x4/music/.snapshots" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=home/h7x4/music/snapshots" "compress=zstd" "noatime" ]; - }; - - fileSystems."/var/log" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=var/log/active" "compress=zstd" "noatime" ]; - }; - - fileSystems."/var/log/.snapshots" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=var/log/snapshots" "compress=zstd" "noatime" ]; - }; - - fileSystems."/var/lib" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=var/lib/active" "compress=zstd" "noatime" ]; - }; - - fileSystems."/var/lib/.snapshots" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=var/lib/snapshots" "compress=zstd" "noatime" ]; - }; - - fileSystems."/var/lib/docker" = - { device = "/dev/disk/by-uuid/178502e0-0481-47ed-842c-2d6b1cf81ac5"; - fsType = "btrfs"; - options = [ "subvol=var/lib/docker" "compress=zstd" "noatime" ]; - }; - - swapDevices = [ ]; - # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's # still possible to use this option, but it's recommended to use it in conjunction