From 890cf0a79c936c49b06513e23cec7d375c456f7d Mon Sep 17 00:00:00 2001 From: Madoura Date: Sat, 18 Nov 2023 07:55:19 -0600 Subject: [PATCH] nixos/bcachefs: soft-deprecate 'linuxPackages_testing_bcachefs' 'bcachefs' is included in the linux kernel since 6.7-rc1 --- nixos/modules/tasks/filesystems/bcachefs.nix | 29 ++++++++++++++++++-- pkgs/top-level/all-packages.nix | 1 + pkgs/top-level/linux-kernels.nix | 2 ++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/nixos/modules/tasks/filesystems/bcachefs.nix b/nixos/modules/tasks/filesystems/bcachefs.nix index 8036da469bc0..d144ce62dc27 100644 --- a/nixos/modules/tasks/filesystems/bcachefs.nix +++ b/nixos/modules/tasks/filesystems/bcachefs.nix @@ -88,22 +88,45 @@ let }; }; + assertions = [ + { + assertion = let + kernel = config.boot.kernelPackages.kernel; + in ( + kernel.kernelAtLeast "6.7" || ( + lib.elem (kernel.structuredExtraConfig.BCACHEFS_FS or null) [ + lib.kernel.module + lib.kernel.yes + lib.kernel.option.yes + ] + ) + ); + + message = "Linux 6.7-rc1 at minimum or a custom linux kernel with bcachefs support is required"; + } + ]; in { config = lib.mkIf (lib.elem "bcachefs" config.boot.supportedFilesystems) (lib.mkMerge [ { + inherit assertions; # needed for systemd-remount-fs system.fsPackages = [ pkgs.bcachefs-tools ]; - # use kernel package with bcachefs support until it's in mainline - # TODO replace with requireKernelConfig - boot.kernelPackages = pkgs.linuxPackages_testing_bcachefs; + # FIXME: Replace this with `linuxPackages_testing` after NixOS 23.11 is released + # FIXME: Replace this with `linuxPackages_latest` when 6.7 is released, remove this line when the LTS version is at least 6.7 + boot.kernelPackages = lib.mkDefault ( + # FIXME: Remove warning after NixOS 23.11 is released + lib.warn "Please upgrade to Linux 6.7-rc1 or later: 'linuxPackages_testing_bcachefs' is deprecated. Use 'boot.kernelPackages = pkgs.linuxPackages_testing;' to silence this warning" + pkgs.linuxPackages_testing_bcachefs + ); systemd.services = lib.mapAttrs' (mkUnits "") (lib.filterAttrs (n: fs: (fs.fsType == "bcachefs") && (!utils.fsNeededForBoot fs)) config.fileSystems); } (lib.mkIf ((lib.elem "bcachefs" config.boot.initrd.supportedFilesystems) || (bootFs != {})) { + inherit assertions; # chacha20 and poly1305 are required only for decryption attempts boot.initrd.availableKernelModules = [ "bcachefs" "sha256" "chacha20" "poly1305" ]; boot.initrd.systemd.extraBin = { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fdbfc1081655..8548848a1ea4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -28107,6 +28107,7 @@ with pkgs; linuxPackages_testing = linuxKernel.packages.linux_testing; linux_testing = linuxKernel.kernels.linux_testing; + # FIXME: Remove and alias to `linux(Packages)_testing`` after 23.11 is released linuxPackages_testing_bcachefs = linuxKernel.packages.linux_testing_bcachefs; linux_testing_bcachefs = linuxKernel.kernels.linux_testing_bcachefs; diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix index 2cd4319e6650..12ad5a678f21 100644 --- a/pkgs/top-level/linux-kernels.nix +++ b/pkgs/top-level/linux-kernels.nix @@ -201,6 +201,7 @@ in { then latest else testing; + # FIXME: Remove after 23.11 is released linux_testing_bcachefs = callPackage ../os-specific/linux/kernel/linux-testing-bcachefs.nix { # Pinned on the last version which Kent's commits can be cleany rebased up. kernel = linux_6_5; @@ -612,6 +613,7 @@ in { # Intentionally lacks recurseIntoAttrs, as -rc kernels will quite likely break out-of-tree modules and cause failed Hydra builds. linux_testing = packagesFor kernels.linux_testing; + # FIXME: Remove after 23.11 is released linux_testing_bcachefs = recurseIntoAttrs (packagesFor kernels.linux_testing_bcachefs); linux_hardened = recurseIntoAttrs (packagesFor kernels.linux_hardened);