diff options
Diffstat (limited to 'nixos/modules/tasks/filesystems/zfs.nix')
-rw-r--r-- | nixos/modules/tasks/filesystems/zfs.nix | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index c5f41cc338c..045cbeb7cff 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -22,12 +22,18 @@ let kernel = config.boot.kernelPackages; - splKernelPkg = kernel.spl; - zfsKernelPkg = kernel.zfs; - zfsUserPkg = pkgs.zfs; + packages = if config.boot.zfs.enableUnstable then { + spl = kernel.splUnstable; + zfs = kernel.zfsUnstable; + zfsUser = pkgs.zfsUnstable; + } else { + spl = kernel.spl; + zfs = kernel.zfs; + zfsUser = pkgs.zfs; + }; autosnapPkg = pkgs.zfstools.override { - zfs = zfsUserPkg; + zfs = packages.zfsUser; }; zfsAutoSnap = "${autosnapPkg}/bin/zfs-auto-snapshot"; @@ -54,6 +60,18 @@ in options = { boot.zfs = { + enableUnstable = mkOption { + type = types.bool; + default = false; + description = '' + Use the unstable zfs package. This might be an option, if the latest + kernel is not yet supported by a published release of ZFS. Enabling + this option will install a development version of ZFS on Linux. The + version will have already passed an extensive test suite, but it is + more likely to hit an undiscovered bug compared to running a released + version of ZFS on Linux. + ''; + }; extraPools = mkOption { type = types.listOf types.str; @@ -218,16 +236,16 @@ in boot = { kernelModules = [ "spl" "zfs" ] ; - extraModulePackages = [ splKernelPkg zfsKernelPkg ]; + extraModulePackages = with packages; [ spl zfs ]; }; boot.initrd = mkIf inInitrd { kernelModules = [ "spl" "zfs" ]; extraUtilsCommands = '' - copy_bin_and_libs ${zfsUserPkg}/sbin/zfs - copy_bin_and_libs ${zfsUserPkg}/sbin/zdb - copy_bin_and_libs ${zfsUserPkg}/sbin/zpool + copy_bin_and_libs ${packages.zfsUser}/sbin/zfs + copy_bin_and_libs ${packages.zfsUser}/sbin/zdb + copy_bin_and_libs ${packages.zfsUser}/sbin/zpool ''; extraUtilsCommandsTest = mkIf inInitrd '' @@ -264,14 +282,14 @@ in zfsSupport = true; }; - environment.etc."zfs/zed.d".source = "${zfsUserPkg}/etc/zfs/zed.d/*"; + environment.etc."zfs/zed.d".source = "${packages.zfsUser}/etc/zfs/zed.d/*"; - system.fsPackages = [ zfsUserPkg ]; # XXX: needed? zfs doesn't have (need) a fsck - environment.systemPackages = [ zfsUserPkg ] - ++ optional enableAutoSnapshots autosnapPkg; # so the user can run the command to see flags + system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck + environment.systemPackages = [ packages.zfsUser ] + ++ optional enableAutoSnapshots autosnapPkg; # so the user can run the command to see flags - services.udev.packages = [ zfsUserPkg ]; # to hook zvol naming, etc. - systemd.packages = [ zfsUserPkg ]; + services.udev.packages = [ packages.zfsUser ]; # to hook zvol naming, etc. + systemd.packages = [ packages.zfsUser ]; systemd.services = let getPoolFilesystems = pool: @@ -298,7 +316,7 @@ in RemainAfterExit = true; }; script = '' - zpool_cmd="${zfsUserPkg}/sbin/zpool" + zpool_cmd="${packages.zfsUser}/sbin/zpool" ("$zpool_cmd" list "${pool}" >/dev/null) || "$zpool_cmd" import -d ${cfgZfs.devNodes} -N ${optionalString cfgZfs.forceImportAll "-f"} "${pool}" ''; }; @@ -314,7 +332,7 @@ in RemainAfterExit = true; }; script = '' - ${zfsUserPkg}/sbin/zfs set nixos:shutdown-time="$(date)" "${pool}" + ${packages.zfsUser}/sbin/zfs set nixos:shutdown-time="$(date)" "${pool}" ''; }; |