diff options
author | Jörg Thalheim <joerg@higgsboson.tk> | 2017-01-02 07:46:46 +0100 |
---|---|---|
committer | Jörg Thalheim <joerg@higgsboson.tk> | 2017-01-05 08:40:50 +0100 |
commit | 4029470a6fa3c181b457debbf8f96e84de3f39e4 (patch) | |
tree | 98b76f0432b08d7017aadaaa0c34530a820874d3 /nixos/modules/tasks/filesystems | |
parent | 2c288548b93b657365c27a0132a43ba0080870cc (diff) | |
download | nixlib-4029470a6fa3c181b457debbf8f96e84de3f39e4.tar nixlib-4029470a6fa3c181b457debbf8f96e84de3f39e4.tar.gz nixlib-4029470a6fa3c181b457debbf8f96e84de3f39e4.tar.bz2 nixlib-4029470a6fa3c181b457debbf8f96e84de3f39e4.tar.lz nixlib-4029470a6fa3c181b457debbf8f96e84de3f39e4.tar.xz nixlib-4029470a6fa3c181b457debbf8f96e84de3f39e4.tar.zst nixlib-4029470a6fa3c181b457debbf8f96e84de3f39e4.zip |
zfs: add unstable variant
Until now nixos only delivered the latest zfs release. This release is often not compatible with the latest mainline kernel. Therefor an unstable variant is added, which might be based on testing releases or git revisions. fixes #21359
Diffstat (limited to 'nixos/modules/tasks/filesystems')
-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 c5f41cc338cf..045cbeb7cff8 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}" ''; }; |