nixos-conf/shared/hardware/impermanence.nix

36 lines
692 B
Nix
Raw Normal View History

2025-06-29 12:39:15 +03:00
{ lib, ... }:
{
# Default set of directories we always want to persist
environment.persistence."/persist" = {
enable = true;
hideMounts = true;
files = [
"/etc/machine-id"
"/etc/ssh/ssh_host_rsa_key"
"/etc/ssh/ssh_host_ed25519_key"
];
directories = [
"/var/lib/systemd/timers"
"/var/lib/nixos"
"/var/log"
];
};
2025-06-29 15:25:07 +03:00
fileSystems."/persist".neededForBoot = true;
2025-06-29 12:39:15 +03:00
services.zfs = {
autoScrub.enable = true;
autoSnapshot = {
enable = true;
flags = "-k -p --utc";
};
};
boot.initrd.postResumeCommands = lib.mkAfter ''
zfs rollback -r zroot/root@blank
zfs rollback -r zroot/home@blank
'';
}