From 4ed27101c608458967053d2b601a4dd281f80365 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 13 Dec 2024 18:57:17 -0500 Subject: [PATCH] nixos/zfs: fix not auto-importing pools without any `fileSystems` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `lib.all (_: false) [ ]` is `true`, which is not the semantics we want here, and interacts poorly with `boot.zfs.extraPools` where `getPoolFilesystems` may return `[]`. So explicitly handle this case. This does mean there isn’t a straightforward way to disable auto-import with `extraPools` and no associated `fileSystems` while keeping the unit around, but that’s probably okay for now. See https://github.com/NixOS/nixpkgs/issues/364995. Broken in 7f8278a2640dd74794550ba4c99e851f4b74c5a2. --- nixos/modules/tasks/filesystems/zfs.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index 27f2028a175d..b95dc09af6bf 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -129,7 +129,8 @@ let "systemd-ask-password-console.service" ] ++ lib.optional (config.boot.initrd.clevis.useTang) "network-online.target"; requiredBy = let - noauto = lib.all (fs: lib.elem "noauto" fs.options) (getPoolFilesystems pool); + poolFilesystems = getPoolFilesystems pool; + noauto = poolFilesystems != [ ] && lib.all (fs: lib.elem "noauto" fs.options) poolFilesystems; in getPoolMounts prefix pool ++ lib.optional (!noauto) "zfs-import.target"; before = getPoolMounts prefix pool ++ [ "shutdown.target" "zfs-import.target" ]; conflicts = [ "shutdown.target" ];