I set up NixOS using disko with ZFS root and a root, nix and persisted data set. My problem is that rolling back to zroot@blank changes nothing in the filesystem. It actually worked at some point, but now it fails to erase newly written files.
The only thing I can imagine, is that somehow the creation of that snapshot at install time simply happens every reboot and as such includes all newly written files. But is this the thing I am missing?
I have impermanence set up too in my NixOS flake, but it does only persist the files I want it to and the files I want it to erase are not declaratively persisted.
{ lib, ... }:
let
mountOptions = {
mountpoint = "legacy";
atime = "off";
"com.sun:auto-snapshot" = builtins.toString false;
};
in
{
disko.devices = {
disk = {
main = {
type = "disk";
device = lib.mkDefault "/dev/nvme0n1";
content = {
type = "gpt";
partitions = {
boot = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
swap = {
size = "16G";
content = {
type = "swap";
randomEncryption = true;
priority = 100;
};
};
root = {
size = "100%";
content = {
name = "luks";
type = "luks";
passwordFile = "/tmp/passwordFile";
settings.allowDiscards = true;
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
};
};
zpool = {
zroot = {
type = "zpool";
rootFsOptions = {
compression = "zstd";
"com.sun:auto-snapshot" = builtins.toString false;
mountpoint = "none";
};
mountpoint = "/";
postCreateHook = ''
zfs list -t snapshot -H -o name | grep -E '^zroot@blank$' || zfs snapshot zroot@blank
'';
datasets = {
root = {
type = "zfs_fs";
options = mountOptions;
mountpoint = "/";
};
nix = {
type = "zfs_fs";
options = mountOptions;
mountpoint = "/nix";
};
persist = {
type = "zfs_fs";
options = mountOptions;
mountpoint = "/persist";
};
};
};
};
};
fileSystems."/persist".neededForBoot = true;
}
If this is not enough of the configuration to point out my mistakes, let me know and I will provide more.