fix zfs latest again

This commit is contained in:
Jörg Thalheim
2024-09-24 11:37:48 +02:00
parent afbac7f08c
commit 44e17e9ee6
3 changed files with 29 additions and 4 deletions

View File

@@ -1,15 +1,11 @@
{ {
lib, lib,
pkgs, pkgs,
config,
... ...
}: }:
{ {
# If we also need zfs, we can use the unstable version as we otherwise don't have a new enough kernel version # If we also need zfs, we can use the unstable version as we otherwise don't have a new enough kernel version
boot.zfs.package = pkgs.zfsUnstable; boot.zfs.package = pkgs.zfsUnstable;
boot.kernelPackages = lib.mkIf config.boot.zfs.enabled (
lib.mkForce config.boot.zfs.package.latestCompatibleLinuxPackages
);
# Enable bcachefs support # Enable bcachefs support
boot.supportedFilesystems.bcachefs = lib.mkDefault true; boot.supportedFilesystems.bcachefs = lib.mkDefault true;

View File

@@ -47,6 +47,7 @@ in
(modulesPath + "/profiles/installation-device.nix") (modulesPath + "/profiles/installation-device.nix")
(modulesPath + "/profiles/all-hardware.nix") (modulesPath + "/profiles/all-hardware.nix")
(modulesPath + "/profiles/base.nix") (modulesPath + "/profiles/base.nix")
./zfs-latest.nix
]; ];
environment.systemPackages = [ pkgs.nixos-facter ]; environment.systemPackages = [ pkgs.nixos-facter ];

View File

@@ -0,0 +1,28 @@
{
lib,
pkgs,
config,
...
}:
let
isUnstable = config.boot.zfs.package == pkgs.zfsUnstable;
zfsCompatibleKernelPackages = lib.filterAttrs (
name: kernelPackages:
(builtins.match "linux_[0-9]+_[0-9]+" name) != null
&& (builtins.tryEval kernelPackages).success
&& (
(!isUnstable && !kernelPackages.zfs.meta.broken)
|| (isUnstable && !kernelPackages.zfs_unstable.meta.broken)
)
) pkgs.linuxKernel.packages;
latestKernelPackage = lib.last (
lib.sort (a: b: (lib.versionOlder a.kernel.version b.kernel.version)) (
builtins.attrValues zfsCompatibleKernelPackages
)
);
in
{
# Note this might jump back and worth as kernel get added or removed.
boot.kernelPackages = latestKernelPackage;
}