nixos-conf/shared/hardware/impermanence.nix

35 lines
692 B
Nix

{ 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"
];
};
fileSystems."/persist".neededForBoot = true;
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
'';
}