ZFS: Difference between revisions

Tboston (talk | contribs)
mNo edit summary
Line 9: Line 9:
==== Latest kernel compatible with ZFS ====
==== Latest kernel compatible with ZFS ====


Newer kernels might not be supported by ZFS yet. If you are running a kernel which is not officially supported by zfs, the module will refuse to evaluate and show an error. Use <code>boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;</code> to use the latest kernel compatible with zfs.
Newer kernels might not be supported by ZFS yet. If you are running a kernel which is not officially supported by zfs, the module will refuse to evaluate and show an error.
 
This snippet will configure the latest compatible kernel:
 
<syntaxHighlight lang=nix>
{ lib, pkgs, ... }:
let
  latestZfsCompatibleLinuxPackages = lib.pipe pkgs.linuxKernel.packages [
    builtins.attrValues
    (builtins.filter (
      kPkgs:
      (builtins.tryEval kPkgs).success
      && kPkgs ? kernel
      && kPkgs.kernel.pname == "linux"
      && !kPkgs.zfs.meta.broken
    ))
    (builtins.sort (a: b: (lib.versionOlder a.kernel.version b.kernel.version)))
    lib.last
  ];
in
{
  # Note this might jump back and worth as kernel get added or removed.
  boot.kernelPackages = latestZfsCompatibleLinuxPackages;
}
</syntaxHighlight>


==== Partial support for SWAP on ZFS ====
==== Partial support for SWAP on ZFS ====