Skip to content

Commit 37e7356

Browse files
authored
rustfmt: fix on darwin (#237)
fixes #235
2 parents 26a5e59 + 2c25236 commit 37e7356

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lib/mk-toolchain.nix

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
{ callPackage, fetchurl, lib, stdenv, zlib, curl }:
1+
{ callPackage, fetchurl, lib, stdenv, zlib, curl, makeBinaryWrapper }:
22

33
suffix:
44
{ date, components }:
55

66
let
77
inherit (builtins) attrValues mapAttrs;
88
inherit (lib)
9-
attrVals maintainers mapAttrs' nameValuePair optionalAttrs optionalString
9+
attrVals maintainers mapAttrs' nameValuePair optionals optionalAttrs optionalString
1010
platforms removeSuffix;
1111

1212
combine = callPackage ./combine.nix { };
@@ -18,6 +18,11 @@ let
1818
pname = "${component}${suffix}";
1919
version = source.date or date;
2020
src = fetchurl { inherit (source) url sha256; };
21+
22+
nativeBuildInputs = optionals (component == "rustfmt-preview" && stdenv.isDarwin) [
23+
makeBinaryWrapper
24+
];
25+
2126
installPhase = ''
2227
patchShebangs install.sh
2328
CFG_DISABLE_LDCONFIG=1 ./install.sh --prefix=$out
@@ -109,10 +114,14 @@ let
109114
patchelf \
110115
--set-rpath ${toolchain.rustc}/lib $out/bin/rustfmt || true
111116
''}
112-
${optionalString stdenv.isDarwin ''
113-
install_name_tool \
114-
-add_rpath ${toolchain.rustc}/lib $out/bin/rustfmt || true
115-
''}
117+
${
118+
# error: install_name_tool: changing install names or rpaths can't be redone
119+
# because larger updated load commands do not fit (the program must be relinked)
120+
optionalString stdenv.isDarwin ''
121+
wrapProgram $out/bin/rustfmt \
122+
--prefix DYLD_LIBRARY_PATH : ${toolchain.rustc}/lib
123+
''
124+
}
116125
''}
117126
118127
${optionalString (component == "rust-analyzer-preview") ''

0 commit comments

Comments
 (0)