{ lib, config, ... }: let btrfsopt = [ "compress=zstd" "noatime" ]; in { services.btrfs.autoScrub.enable = true; services.btrfs.autoScrub.fileSystems = [ "/nix" "/data" ]; disko.devices = { disk.disk1 = { type = "disk"; device = lib.mkDefault "/dev/nvme0n1"; content = { type = "gpt"; partitions = { boot = { name = "boot"; size = "1M"; type = "EF02"; }; esp = { size = "2G"; type = "EF00"; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; }; }; luks = { size = "100%"; content = { type = "luks"; name = "nixos"; passwordFile = "/tmp/disk.key"; settings.allowDiscards = true; content = { type = "btrfs"; extraArgs = [ "-f" ]; subvolumes = { "/root" = lib.mkIf (!config.ephemeralRoot) { mountpoint = "/"; mountOptions = btrfsopt; }; "/nix" = { mountpoint = "/nix"; mountOptions = btrfsopt; }; "/data" = { mountpoint = "/data"; mountOptions = btrfsopt; }; "/persist" = { mountpoint = "/persist"; mountOptions = btrfsopt; }; }; }; }; }; }; }; }; nodev."/" = lib.mkIf config.ephemeralRoot { fsType = "tmpfs"; mountOptions = [ "size=16G" "defaults" "mode=755" ]; }; }; fileSystems."/persist".neededForBoot = true; }