diff options
author | Jörg Thalheim <joerg@higgsboson.tk> | 2017-01-05 12:52:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-05 12:52:56 +0100 |
commit | ca0d747d6d370175a41c37c0900513324d16ed04 (patch) | |
tree | b67ac6da2c22e4d7bf61e5398eda73249b8179f9 /nixos | |
parent | 1ba9a3cd9bc745f76ea79928e02687105cb38dd0 (diff) | |
parent | 4029470a6fa3c181b457debbf8f96e84de3f39e4 (diff) |
Merge pull request #21578 from Mic92/zfs
zfs: add unstable variant
Diffstat (limited to 'nixos')
-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 c5f41cc338cf5..045cbeb7cff84 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}" ''; }; |