summary refs log tree commit diff
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2023-05-13 13:23:19 +0200
committerJörg Thalheim <joerg@thalheim.io>2023-07-01 17:10:10 +0200
commit4d719f101c28bede334298c026a7fcb3e19553a5 (patch)
tree8e9fb42a0048a2401716dfcdec903bcbc88cd0e1
parent871e00591399d420154373f2a72cb681d996b570 (diff)
downloadnixpkgs-4d719f101c28bede334298c026a7fcb3e19553a5.tar
nixpkgs-4d719f101c28bede334298c026a7fcb3e19553a5.tar.gz
nixpkgs-4d719f101c28bede334298c026a7fcb3e19553a5.tar.bz2
nixpkgs-4d719f101c28bede334298c026a7fcb3e19553a5.tar.lz
nixpkgs-4d719f101c28bede334298c026a7fcb3e19553a5.tar.xz
nixpkgs-4d719f101c28bede334298c026a7fcb3e19553a5.tar.zst
nixpkgs-4d719f101c28bede334298c026a7fcb3e19553a5.zip
nixos/bcachefs: add new mount.bcachefs util
-rw-r--r--nixos/modules/tasks/filesystems/bcachefs.nix14
1 files changed, 11 insertions, 3 deletions
diff --git a/nixos/modules/tasks/filesystems/bcachefs.nix b/nixos/modules/tasks/filesystems/bcachefs.nix
index 851c0978133..19ef188ce78 100644
--- a/nixos/modules/tasks/filesystems/bcachefs.nix
+++ b/nixos/modules/tasks/filesystems/bcachefs.nix
@@ -6,6 +6,15 @@ let
 
   bootFs = filterAttrs (n: fs: (fs.fsType == "bcachefs") && (utils.fsNeededForBoot fs)) config.fileSystems;
 
+  mountCommand = pkgs.runCommand "mount.bcachefs" {} ''
+    mkdir -p $out/bin
+    cat > $out/bin/mount.bcachefs <<EOF
+    #!/bin/sh
+    exec "/bin/bcachefs" mount "\$@"
+    EOF
+    chmod +x $out/bin/mount.bcachefs
+  '';
+
   commonFunctions = ''
     prompt() {
         local name="$1"
@@ -58,13 +67,12 @@ in
 
       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
-        '';
+        "mount.bcachefs" = "${mountCommand}/bin/mount.bcachefs";
       };
 
       boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
         copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs
+        copy_bin_and_libs ${mountCommand}/bin/mount.bcachefs
       '';
       boot.initrd.extraUtilsCommandsTest = ''
         $out/bin/bcachefs version