From 2c8bf3896cd8d2eb43ccc5422104b075d2165c0c Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Tue, 16 Sep 2025 14:35:13 -0400 Subject: [PATCH 1/4] bcachefs-tools: 1.31.0 -> 1.31.3 --- pkgs/by-name/bc/bcachefs-tools/package.nix | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/bc/bcachefs-tools/package.nix b/pkgs/by-name/bc/bcachefs-tools/package.nix index 3e1aa6f6fdb4..c6162bffa49d 100644 --- a/pkgs/by-name/bc/bcachefs-tools/package.nix +++ b/pkgs/by-name/bc/bcachefs-tools/package.nix @@ -29,13 +29,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "bcachefs-tools"; - version = "1.31.0"; + version = "1.31.3"; src = fetchFromGitHub { owner = "koverstreet"; repo = "bcachefs-tools"; tag = "v${finalAttrs.version}"; - hash = "sha256-wYlfU4PTcVSPSHbIIDbl8pBOJsBAAl44XBapwFZ528U="; + hash = "sha256-sXv6YFM91T08WF5dPU7iQNqWbB/QiL2kMaXm6ZtIDqI="; }; nativeBuildInputs = [ @@ -66,7 +66,7 @@ stdenv.mkDerivation (finalAttrs: { cargoDeps = rustPlatform.fetchCargoVendor { src = finalAttrs.src; - hash = "sha256-ZCzw3cDpQ8fb2jLYdIWrmlNTPStikIs09jx6jzzC2vM="; + hash = "sha256-04YrgYfhZ5NfA2BcF2H6Np1SXRiH6CJpkgc9hzlbMAo="; }; makeFlags = [ @@ -100,11 +100,7 @@ stdenv.mkDerivation (finalAttrs: { ''; checkFlags = [ "BCACHEFS_TEST_USE_VALGRIND=no" ]; - postInstall = '' - substituteInPlace $out/libexec/bcachefsck_all \ - --replace-fail "/usr/bin/python3" "${python3.interpreter}" - '' - + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' installShellCompletion --cmd bcachefs \ --bash <($out/sbin/bcachefs completions bash) \ --zsh <($out/sbin/bcachefs completions zsh) \ From 7582c9166d53e749f859604c56445781e27a749f Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Tue, 16 Sep 2025 14:35:13 -0400 Subject: [PATCH 2/4] bcachefs-kernel-module: init at 1.31.3 --- pkgs/by-name/bc/bcachefs-tools/package.nix | 10 ++++ .../linux/bcachefs-kernel-module/default.nix | 48 +++++++++++++++++++ pkgs/top-level/linux-kernels.nix | 2 + 3 files changed, 60 insertions(+) create mode 100644 pkgs/os-specific/linux/bcachefs-kernel-module/default.nix diff --git a/pkgs/by-name/bc/bcachefs-tools/package.nix b/pkgs/by-name/bc/bcachefs-tools/package.nix index c6162bffa49d..4314f299e0b2 100644 --- a/pkgs/by-name/bc/bcachefs-tools/package.nix +++ b/pkgs/by-name/bc/bcachefs-tools/package.nix @@ -69,16 +69,26 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-04YrgYfhZ5NfA2BcF2H6Np1SXRiH6CJpkgc9hzlbMAo="; }; + outputs = [ + "out" + "dkms" + ]; + makeFlags = [ "PREFIX=${placeholder "out"}" "VERSION=${finalAttrs.version}" "INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools" + "DKMSDIR=${placeholder "dkms"}" # Tries to install to the 'systemd-minimal' and 'udev' nix installation paths "PKGCONFIG_SERVICEDIR=$(out)/lib/systemd/system" "PKGCONFIG_UDEVDIR=$(out)/lib/udev" ] ++ lib.optional fuseSupport "BCACHEFS_FUSE=1"; + installFlags = [ + "install" + "install_dkms" + ]; env = { CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec; diff --git a/pkgs/os-specific/linux/bcachefs-kernel-module/default.nix b/pkgs/os-specific/linux/bcachefs-kernel-module/default.nix new file mode 100644 index 000000000000..a43e55225681 --- /dev/null +++ b/pkgs/os-specific/linux/bcachefs-kernel-module/default.nix @@ -0,0 +1,48 @@ +{ + lib, + stdenv, + bcachefs-tools, + kernelModuleMakeFlags, + kernel, +}: + +stdenv.mkDerivation { + pname = "bcachefs"; + version = "${kernel.version}-${bcachefs-tools.version}"; + + __structuredAttrs = true; + + src = bcachefs-tools.dkms; + + nativeBuildInputs = kernel.moduleBuildDependencies; + + enableParallelBuilding = true; + + makeFlags = kernelModuleMakeFlags ++ [ + "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" + "INSTALL_MOD_PATH=${placeholder "out"}" + ]; + + installPhase = '' + runHook preInstall + make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build M=$(pwd) modules_install "''${makeFlags[@]}" "''${installFlags[@]}" + runHook postInstall + ''; + + passthru = { + inherit (bcachefs-tools.passthru) tests; + }; + + meta = { + description = "out-of-tree bcachefs kernel module"; + + inherit (bcachefs-tools.meta) + homepage + license + maintainers + platforms + ; + + broken = !(lib.versionAtLeast kernel.version "6.16" && lib.versionOlder kernel.version "6.18"); + }; +} diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix index b84c20d1a1b4..0369355da714 100644 --- a/pkgs/top-level/linux-kernels.nix +++ b/pkgs/top-level/linux-kernels.nix @@ -375,6 +375,8 @@ in bbswitch = callPackage ../os-specific/linux/bbswitch { }; + bcachefs = callPackage ../os-specific/linux/bcachefs-kernel-module { }; + ch9344 = callPackage ../os-specific/linux/ch9344 { }; chipsec = callPackage ../tools/security/chipsec { From 25d56c5a3448624716453590a3eca5b7ef298469 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Mon, 22 Sep 2025 19:09:06 -0400 Subject: [PATCH 3/4] nixos/bcachefs: Don't duplicate assertions. The first instance is unconditional. No need to have it twice. --- nixos/modules/tasks/filesystems/bcachefs.nix | 39 +++++++++----------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/nixos/modules/tasks/filesystems/bcachefs.nix b/nixos/modules/tasks/filesystems/bcachefs.nix index 20324a144362..9fb78deb9e32 100644 --- a/nixos/modules/tasks/filesystems/bcachefs.nix +++ b/nixos/modules/tasks/filesystems/bcachefs.nix @@ -175,25 +175,6 @@ 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 lib.kernel.yes) - ]) - ); - - message = "Linux 6.7-rc1 at minimum or a custom linux kernel with bcachefs support is required"; - } - ]; in { @@ -230,7 +211,24 @@ in config = lib.mkIf (config.boot.supportedFilesystems.bcachefs or false) ( lib.mkMerge [ { - inherit assertions; + 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 lib.kernel.yes) + ]) + ); + + message = "Linux 6.7-rc1 at minimum or a custom linux kernel with bcachefs support is required"; + } + ]; # Bcachefs upstream recommends using the latest kernel boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; @@ -248,7 +246,6 @@ in } (lib.mkIf ((config.boot.initrd.supportedFilesystems.bcachefs or false) || (bootFs != { })) { - inherit assertions; boot.initrd.availableKernelModules = [ "bcachefs" "sha256" From 89e7815828309ca77cfa37930f9d1998048f65f6 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Thu, 18 Sep 2025 19:57:07 -0400 Subject: [PATCH 4/4] nixos/bcachefs: Use out-of-tree module when possible. --- nixos/doc/manual/release-notes/rl-2511.section.md | 2 ++ nixos/modules/tasks/filesystems/bcachefs.nix | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index 78571c3646d8..fc07232b6119 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -262,6 +262,8 @@ - Due to [deprecation of gnome-session X11 support](https://blogs.gnome.org/alatiera/2025/06/08/the-x11-session-removal/), `services.desktopManager.pantheon` now defaults to pantheon-wayland session. The X11 session has been removed, see [this issue](https://github.com/elementary/session-settings/issues/91) for details. +- `bcachefs` file systems will now use the out-of-tree module for supported kernels. The in-tree module is unmaintained and users are strongly recommended to switch to kernels that support the out-of-tree module. + - `services.gitea` supports sending notifications with sendmail again. To do this, activate the parameter `services.gitea.mailerUseSendmail` and configure SMTP server. - `networking.wireless.networks.` now has an option to specify SSID, hence allowing duplicated SSID setup. The BSSID option is added along side with this. diff --git a/nixos/modules/tasks/filesystems/bcachefs.nix b/nixos/modules/tasks/filesystems/bcachefs.nix index 9fb78deb9e32..6ac728bfaeba 100644 --- a/nixos/modules/tasks/filesystems/bcachefs.nix +++ b/nixos/modules/tasks/filesystems/bcachefs.nix @@ -230,6 +230,14 @@ in } ]; + warnings = lib.mkIf config.boot.kernelPackages.bcachefs.meta.broken [ + '' + Using unmaintained in-tree bcachefs kernel module. This + will be removed in 26.05. Please use a kernel supported + by the out-of-tree module package. + '' + ]; + # Bcachefs upstream recommends using the latest kernel boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; @@ -237,6 +245,10 @@ in system.fsPackages = [ cfg.package ]; services.udev.packages = [ cfg.package ]; + boot.extraModulePackages = lib.optionals (!config.boot.kernelPackages.bcachefs.meta.broken) [ + config.boot.kernelPackages.bcachefs + ]; + systemd = { packages = [ cfg.package ]; services = lib.mapAttrs' (mkUnits "") (