{ inputs', pkgs, ... }: { nixpkgs.overlays = [ inputs'.self.overlays.show-files-to-be-deleted ]; environment.systemPackages = [ pkgs.show-files-to-be-deleted ]; environment.persistence."/nix/persist" = { hideMounts = true; directories = [ "/var/log" "/var/lib/bluetooth" "/var/lib/nixos" "/var/lib/systemd/coredump" "/var/lib/iwd" "/var/lib/syncthing" ]; files = [ "/etc/machine-id" "/etc/ssh/ssh_host_rsa_key" "/etc/ssh/ssh_host_rsa_key.pub" "/etc/ssh/ssh_host_ed25519_key" "/etc/ssh/ssh_host_ed25519_key.pub" ]; users.main = { directories = [ "sync" ".steam" ".local/share/Steam" ".emacs.d" "roam" "dotfiles" "Documents" { directory = ".gnupg"; mode = "0700"; } { directory = ".ssh"; mode = "0700"; } ".local/share/direnv" "repos" ".config/SchildiChat" ".config/matlab" ".matlab" "MATLAB" ".stack" ".cache/nix" ".cache/fontconfig" ".cache/mesa_shader_cache" ".cache/ghcide" ".local/share/pantalaimon" "Mail" ".cache/mu" ".gradle" ".password-store" ]; files = [ { file = ".config/wallpaper"; method = "symlink"; } ]; }; }; boot.initrd.systemd.storePaths = with pkgs; [ zfs busybox ]; boot.initrd.systemd.services.rollback = { description = "Rollback ZFS datasets to a pristine state"; wantedBy = [ "initrd.target" ]; after = [ "zfs-import-omen-ssd.service" ]; before = [ "sysroot.mount" ]; path = with pkgs; [ zfs busybox ]; unitConfig.DefaultDependencies = "no"; serviceConfig.Type = "oneshot"; script = '' generation="$(zfs get :generation omen-ssd/ephemeral/home -H -o value)" dataset="omen-ssd/ephemeral/home" generation="$(("$generation" + 1))" zfs set ":generation=$generation" "$dataset" zfs send "$dataset" | zfs recv "$dataset/$generation" zfs rollback "$dataset@blank" && echo "rollback complete" while IFS="\n" read gen do echo "$gen < $(("$generation" - 10))" if [ "$gen" -lt "$(("$generation" - 10))" ]; then zfs destroy -r "$dataset/$gen" echo "destroyed " fi done <<< "$(zfs list "omen-ssd/ephemeral/home" -t filesystem -r -H -o name | xargs -I {} ${pkgs.runtimeShell} -c 'echo "$1" | rev | cut -f 1 -d "/" | rev' sh {} | grep -v home)" ''; }; systemd.services."home-manager-main-pre.service" = { description = "Home Manager environment prestart for main"; wantedBy = [ "multi-user.target" ]; before = [ "home-manager-main.service" ]; script = '' set -e mkdir -p /home/main chown 1000:1000 /home/main ''; serviceConfig = { Type = "oneshot"; RemainAfterExit = "yes"; TimeoutStartSec = "5m"; }; }; }