mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
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
This commit is contained in:
parent
2c288548b9
commit
4029470a6f
5 changed files with 245 additions and 301 deletions
|
@ -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}"
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue