{ flake, config, lib, ... }: let inherit (flake.config.people) user0; rootDevice = "/dev/disk/by-uuid/df9868a4-2dd1-40d5-9f5f-c56ceac62216"; in { fileSystems = { "/" = { device = rootDevice; fsType = "btrfs"; options = [ "subvol=root" ]; }; "/nix" = { device = rootDevice; fsType = "btrfs"; options = [ "subvol=nix" ]; }; "/persistent" = { device = rootDevice; fsType = "btrfs"; neededForBoot = true; options = [ "subvol=persistent" ]; }; "/boot" = { device = "/dev/disk/by-uuid/DF19-AD99"; fsType = "vfat"; options = [ "fmask=0077" "dmask=0077" ]; }; "/mnt/storage" = { device = "/dev/disk/by-label/storage"; fsType = "ext4"; }; }; boot.initrd.postResumeCommands = lib.mkAfter '' mkdir /btrfs_tmp mount -o subvolid=5 ${rootDevice} /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 ''; environment.persistence."/persistent" = { directories = [ "/var/cache" "/var/lib" { directory = "/etc/ssh"; mode = "u=rwx,g=rx,o=rx"; user = "root"; } ]; hideMounts = true; users.${user0} = { directories = [ ".cache" ".config" ".local/share/direnv" ".local/state/nix" { directory = ".ssh"; mode = "u=rwx,g=,o="; } ]; }; }; systemd.tmpfiles.rules = [ "Z ${config.home-manager.users.${user0}.home.homeDirectory} 0755 ${user0} users -" "Z /mnt/storage 2775 root root -" ]; services.udisks2.enable = true; }