From 27b52adcb4c933be136b802af32765ca0dc4b75d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 14 Aug 2024 12:54:16 -0400 Subject: [PATCH] zfs: dynamically determine latestCompatibleLinuxPackages This removes the need to micromanage this value, instead we simply find the correct one based on the existing kernelCompatible attr (though that is now a function). This not only simplifies ZFS upgrades, but also whenever Kernel versions are removed due to EOL. (cherry picked from commit 7fa05c77b7d53652cdd6a12011bb78c63bd785c7) (cherry picked from commit 34e1748391b028788b14a30740309e1739293c77) (cherry picked from commit d174eca1faa532934280f9c826af2f0b77217404) --- pkgs/os-specific/linux/zfs/2_1.nix | 5 +---- pkgs/os-specific/linux/zfs/2_2.nix | 5 +---- pkgs/os-specific/linux/zfs/generic.nix | 12 +++++++++--- pkgs/os-specific/linux/zfs/unstable.nix | 5 +---- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/pkgs/os-specific/linux/zfs/2_1.nix b/pkgs/os-specific/linux/zfs/2_1.nix index 97173a5154a5..d950f5cac15d 100644 --- a/pkgs/os-specific/linux/zfs/2_1.nix +++ b/pkgs/os-specific/linux/zfs/2_1.nix @@ -1,7 +1,6 @@ { callPackage , kernel ? null , stdenv -, linuxKernel , lib , nixosTests , ... @@ -15,9 +14,7 @@ callPackage ./generic.nix args { # this attribute is the correct one for this package. kernelModuleAttribute = "zfs_2_1"; # check the release notes for compatible kernels - kernelCompatible = kernel.kernelOlder "6.8"; - - latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_6; + kernelCompatible = kernel: kernel.kernelOlder "6.8"; # This is a fixed version to the 2.1.x series, move only # if the 2.1.x series moves. diff --git a/pkgs/os-specific/linux/zfs/2_2.nix b/pkgs/os-specific/linux/zfs/2_2.nix index 9e3fde0780f0..469b1cca0968 100644 --- a/pkgs/os-specific/linux/zfs/2_2.nix +++ b/pkgs/os-specific/linux/zfs/2_2.nix @@ -2,7 +2,6 @@ , kernel ? null , stdenv , lib -, linuxKernel , nixosTests , ... } @ args: @@ -15,9 +14,7 @@ callPackage ./generic.nix args { # this attribute is the correct one for this package. kernelModuleAttribute = "zfs_2_2"; # check the release notes for compatible kernels - kernelCompatible = kernel.kernelOlder "6.10"; - - latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_6; + kernelCompatible = kernel: kernel.kernelOlder "6.10"; # this package should point to the latest release. version = "2.2.5"; diff --git a/pkgs/os-specific/linux/zfs/generic.nix b/pkgs/os-specific/linux/zfs/generic.nix index f4016e59db43..a379771636f8 100644 --- a/pkgs/os-specific/linux/zfs/generic.nix +++ b/pkgs/os-specific/linux/zfs/generic.nix @@ -2,6 +2,7 @@ let genericBuild = { pkgs, lib, stdenv, fetchFromGitHub, fetchpatch , autoreconfHook269, util-linux, nukeReferences, coreutils + , linuxKernel , perl , configFile ? "all" @@ -27,7 +28,6 @@ let , kernelModuleAttribute , extraPatches ? [] , rev ? "zfs-${version}" - , latestCompatibleLinuxPackages , kernelCompatible ? null , maintainers ? (with lib.maintainers; [ amarshall ]) , tests @@ -198,7 +198,13 @@ let outputs = [ "out" ] ++ optionals buildUser [ "dev" ]; passthru = { - inherit enableMail latestCompatibleLinuxPackages kernelModuleAttribute; + inherit enableMail kernelModuleAttribute; + latestCompatibleLinuxPackages = lib.pipe linuxKernel.packages [ + builtins.attrValues + (builtins.filter (kPkgs: (builtins.tryEval kPkgs).success && kPkgs ? kernel && kPkgs.kernel.pname == "linux" && kernelCompatible kPkgs.kernel)) + (builtins.sort (a: b: (lib.versionOlder a.kernel.version b.kernel.version))) + lib.last + ]; # The corresponding userspace tools to this instantiation # of the ZFS package set. userspaceTools = genericBuild (outerArgs // { @@ -235,7 +241,7 @@ let mainProgram = "zfs"; # If your Linux kernel version is not yet supported by zfs, try zfs_unstable. # On NixOS set the option `boot.zfs.package = pkgs.zfs_unstable`. - broken = buildKernel && (kernelCompatible != null) && !kernelCompatible; + broken = buildKernel && (kernelCompatible != null) && !(kernelCompatible kernel); }; }; in diff --git a/pkgs/os-specific/linux/zfs/unstable.nix b/pkgs/os-specific/linux/zfs/unstable.nix index 6109000ef0fd..8ec6ee792e23 100644 --- a/pkgs/os-specific/linux/zfs/unstable.nix +++ b/pkgs/os-specific/linux/zfs/unstable.nix @@ -1,7 +1,6 @@ { callPackage , kernel ? null , stdenv -, linuxKernel , nixosTests , ... } @ args: @@ -14,9 +13,7 @@ callPackage ./generic.nix args { # this attribute is the correct one for this package. kernelModuleAttribute = "zfs_unstable"; # check the release notes for compatible kernels - kernelCompatible = kernel.kernelOlder "6.11"; - - latestCompatibleLinuxPackages = linuxKernel.packages.linux_6_10; + kernelCompatible = kernel: kernel.kernelOlder "6.11"; # this package should point to a version / git revision compatible with the latest kernel release # IMPORTANT: Always use a tagged release candidate or commits from the