about summary refs log tree commit diff
path: root/pkgs/by-name/bc
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2024-06-25 22:35:48 +0300
committerArtturin <Artturin@artturin.com>2024-06-25 22:39:23 +0300
commit4b0b8ae5c35b2ea20b099bd6a2b9bafff88c8d53 (patch)
treee41a62724f9709365c1c305fbb6d3c0e373ae94b /pkgs/by-name/bc
parentdee7e6f519de4c4a6b897097a7f6a58f8033024f (diff)
bcachefs-tools: Fix cross
The substitute would be good to transfer upstream but I don't know of a
way to do it in the makefile
Diffstat (limited to 'pkgs/by-name/bc')
-rw-r--r--pkgs/by-name/bc/bcachefs-tools/package.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/pkgs/by-name/bc/bcachefs-tools/package.nix b/pkgs/by-name/bc/bcachefs-tools/package.nix
index 14f668bf5b675..f6f06296ac922 100644
--- a/pkgs/by-name/bc/bcachefs-tools/package.nix
+++ b/pkgs/by-name/bc/bcachefs-tools/package.nix
@@ -21,6 +21,7 @@
   makeWrapper,
   nix-update-script,
   python3,
+  fetchpatch,
   fuseSupport ? false,
 }:
 
@@ -71,6 +72,11 @@ stdenv.mkDerivation (finalAttrs: {
     "INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools"
   ] ++ lib.optional fuseSupport "BCACHEFS_FUSE=1";
 
+  env = {
+    CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec;
+    "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" = "${stdenv.cc.targetPrefix}cc";
+  };
+
   # FIXME: Try enabling this once the default linux kernel is at least 6.7
   doCheck = false; # needs bcachefs module loaded on builder
 
@@ -78,8 +84,19 @@ stdenv.mkDerivation (finalAttrs: {
     # code refactoring of bcachefs-tools broke reading passphrases from stdin (vs. terminal)
     # upstream issue https://github.com/koverstreet/bcachefs-tools/issues/261
     ./fix-encrypted-boot.patch
+    # https://github.com/koverstreet/bcachefs-tools/pull/305
+    (fetchpatch {
+      name = "use-ar-var-in-makefile.patch";
+      url = "https://github.com/koverstreet/bcachefs-tools/commit/91e67ab2bd48fa135a1f5109b23899a4f1019a03.patch";
+      sha256 = "sha256-nB4Tgcwa8eeasIDQ4rrYORie/X8LMuCSRi+WJNw+R/U=";
+    })
   ];
 
+  postPatch = ''
+    substituteInPlace Makefile \
+      --replace-fail "target/release/bcachefs" "target/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/bcachefs"
+  '';
+
   preCheck = lib.optionalString (!fuseSupport) ''
     rm tests/test_fuse.py
   '';