nixos/zfs: assert that pool names are not empty

a zfs fileSystems entry with an absolute (e.g. device) path rather than
a zfs dataser is parsed as an empty pool name, causing a doomed-to-fail
import job to be created as a boot dependency. Catch this as an assertion
This commit is contained in:
Daniel Carosone 2023-06-16 10:40:09 +10:00
parent 0eeebd64de
commit 2dcb1b3ed7

View file

@ -523,6 +523,15 @@ in
assertion = cfgZfs.allowHibernation -> !cfgZfs.forceImportRoot && !cfgZfs.forceImportAll;
message = "boot.zfs.allowHibernation while force importing is enabled will cause data corruption";
}
{
assertion = !(elem "" allPools);
message = ''
Automatic pool detection found an empty pool name, which can't be used.
Hint: for `fileSystems` entries with `fsType = zfs`, the `device` attribute
should be a zfs dataset name, like `device = "pool/data/set"`.
This error can be triggered by using an absolute path, such as `"/dev/disks/..."`.
'';
}
];
boot = {