summary refs log tree commit diff
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2022-12-29 23:17:27 +0100
committerJörg Thalheim <joerg@thalheim.io>2023-01-01 19:58:16 +0100
commit655e07253340c2fcc2dbbd894f12362dc7950800 (patch)
tree81eb5ed9283c2b7eb3763ebba961344a97e8c634
parent1e6cf6f3dc967dbf1f20a5a7f3515dcaa316c22d (diff)
downloadnixpkgs-655e07253340c2fcc2dbbd894f12362dc7950800.tar
nixpkgs-655e07253340c2fcc2dbbd894f12362dc7950800.tar.gz
nixpkgs-655e07253340c2fcc2dbbd894f12362dc7950800.tar.bz2
nixpkgs-655e07253340c2fcc2dbbd894f12362dc7950800.tar.lz
nixpkgs-655e07253340c2fcc2dbbd894f12362dc7950800.tar.xz
nixpkgs-655e07253340c2fcc2dbbd894f12362dc7950800.tar.zst
nixpkgs-655e07253340c2fcc2dbbd894f12362dc7950800.zip
nixos/bcachefs: fix boot with systemd enabled initrd
-rw-r--r--nixos/modules/tasks/filesystems/bcachefs.nix15
1 files changed, 13 insertions, 2 deletions
diff --git a/nixos/modules/tasks/filesystems/bcachefs.nix b/nixos/modules/tasks/filesystems/bcachefs.nix
index ac41ba5f93a..e3ad52a7b05 100644
--- a/nixos/modules/tasks/filesystems/bcachefs.nix
+++ b/nixos/modules/tasks/filesystems/bcachefs.nix
@@ -42,7 +42,11 @@ in
 {
   config = mkIf (elem "bcachefs" config.boot.supportedFilesystems) (mkMerge [
     {
-      system.fsPackages = [ pkgs.bcachefs-tools ];
+      # We do not want to include bachefs in the fsPackages for systemd-initrd
+      # because we provide the unwrapped version of mount.bcachefs
+      # through the extraBin option, which will make it available for use.
+      system.fsPackages = lib.optional (!config.boot.initrd.systemd.enable) pkgs.bcachefs-tools;
+      environment.systemPackages = lib.optional (config.boot.initrd.systemd.enable) pkgs.bcachefs-tools;
 
       # use kernel package with bcachefs support until it's in mainline
       boot.kernelPackages = pkgs.linuxPackages_testing_bcachefs;
@@ -52,7 +56,14 @@ in
       # chacha20 and poly1305 are required only for decryption attempts
       boot.initrd.availableKernelModules = [ "bcachefs" "sha256" "chacha20" "poly1305" ];
 
-      boot.initrd.extraUtilsCommands = ''
+      boot.initrd.systemd.extraBin = {
+        "bcachefs" = "${pkgs.bcachefs-tools}/bin/bcachefs";
+        "mount.bcachefs" = pkgs.runCommand "mount.bcachefs" {} ''
+          cp -pdv ${pkgs.bcachefs-tools}/bin/.mount.bcachefs.sh-wrapped $out
+        '';
+      };
+
+      boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
         copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs
       '';
       boot.initrd.extraUtilsCommandsTest = ''