From 2dcb1b3ed7defffd8cc418a94d33d32807f8fcf8 Mon Sep 17 00:00:00 2001 From: Daniel Carosone Date: Fri, 16 Jun 2023 10:40:09 +1000 Subject: [PATCH] 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 --- nixos/modules/tasks/filesystems/zfs.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index 16dc0c44c18d..c214e277db4b 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -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 = {