{ disko.devices = { disk = { main = { type = "disk"; device = "/dev/nvme0n1"; content = { type = "gpt"; partitions = { ESP = { label = "boot"; name = "ESP"; size = "512M"; type = "EF00"; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; mountOptions = [ "defaults" ]; }; }; luks = { size = "100%"; label = "luks"; content = { type = "luks"; name = "cryptroot"; extraOpenArgs = [ "--allow-discards" "--perf-no_read_workqueue" "--perf-no_write_workqueue" ]; # https://0pointer.net/blog/unlocking-luks2-volumes-with-tpm2-fido2-pkcs11-security-hardware-on-systemd-248.html # settings = {crypttabExtraOpts = ["fido2-device=auto" "token-timeout=10"];}; content = { type = "btrfs"; extraArgs = ["-L" "nixos" "-f"]; subvolumes = { # "/root" = { # mountpoint = "/"; # mountOptions = ["subvol=root" "compress=zstd" "noatime"]; # }; "/home" = { mountpoint = "/persist/home"; mountOptions = ["subvol=home" "compress=zstd" "noatime"]; }; "/nix" = { mountpoint = "/persist/nix"; mountOptions = ["subvol=nix" "compress=zstd" "noatime"]; }; "/persist" = { mountpoint = "/persist"; mountOptions = ["subvol=persist" "compress=zstd" "noatime"]; }; "/log" = { mountpoint = "/persist/var/log"; mountOptions = ["subvol=log" "compress=zstd" "noatime"]; }; "/music" = { mountpoint = "/persist/var/lib/Music"; mountOptions = ["subvol=music" "noatime"]; }; "/movies" = { mountpoint = "/persist/var/lib/movies"; mountOptions = ["subvol=movies" "noatime"]; }; "/swap" = { mountpoint = "/persist/swap"; swap.swapfile.size = "32G"; }; }; }; }; }; }; }; }; }; }; fileSystems."/" = { device = "none"; fsType = "tmpfs"; options = [ "defaults" "size=25%" "mode=755" ]; }; # fileSystems."/mnt/Backup" = { # device = "/dev/disk/by-label/Backup"; # fsType = "ext4"; # }; fileSystems."/persist".neededForBoot = true; fileSystems."/var/log".neededForBoot = true; # boot.initrd.postResumeCommands = lib.mkAfter '' # mkdir /btrfs_tmp # mount /dev/disk/by-label/luks /btrfs_tmp # if [[ -e /btrfs_tmp/root ]]; then # mkdir -p /btrfs_tmp/old_roots # timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S") # mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp" # fi # # delete_subvolume_recursively() { # IFS=$'\n' # for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do # delete_subvolume_recursively "/btrfs_tmp/$i" # done # btrfs subvolume delete "$1" # } # # for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do # delete_subvolume_recursively "$i" # done # btrfs subvolume create /btrfs_tmp/root # umount /btrfs_tmp # ''; }