Skip to content

Commit

Permalink
zfs: dynamically determine latestCompatibleLinuxPackages
Browse files Browse the repository at this point in the history
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 7fa05c7)
(cherry picked from commit 34e1748)
(cherry picked from commit d174eca)
  • Loading branch information
amarshall committed Sep 10, 2024
1 parent fe1ef01 commit 27b52ad
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
5 changes: 1 addition & 4 deletions pkgs/os-specific/linux/zfs/2_1.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ callPackage
, kernel ? null
, stdenv
, linuxKernel
, lib
, nixosTests
, ...
Expand All @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions pkgs/os-specific/linux/zfs/2_2.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
, kernel ? null
, stdenv
, lib
, linuxKernel
, nixosTests
, ...
} @ args:
Expand All @@ -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";
Expand Down
12 changes: 9 additions & 3 deletions pkgs/os-specific/linux/zfs/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ let
genericBuild =
{ pkgs, lib, stdenv, fetchFromGitHub, fetchpatch
, autoreconfHook269, util-linux, nukeReferences, coreutils
, linuxKernel
, perl
, configFile ? "all"

Expand All @@ -27,7 +28,6 @@ let
, kernelModuleAttribute
, extraPatches ? []
, rev ? "zfs-${version}"
, latestCompatibleLinuxPackages
, kernelCompatible ? null
, maintainers ? (with lib.maintainers; [ amarshall ])
, tests
Expand Down Expand Up @@ -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 // {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions pkgs/os-specific/linux/zfs/unstable.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ callPackage
, kernel ? null
, stdenv
, linuxKernel
, nixosTests
, ...
} @ args:
Expand All @@ -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
Expand Down

0 comments on commit 27b52ad

Please sign in to comment.