-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrust-esp.nix
75 lines (68 loc) · 2.16 KB
/
rust-esp.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{ lib
, stdenv
, fetchurl
}:
let
platform = {
x86_64-linux = "x86_64-unknown-linux-gnu";
aarch64-linux = "aarch64-unknown-linux-gnu";
x86_64-darwin = "x86_64-apple-darwin";
aarch64-darwin = "aarch64-apple-darwin";
}.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation rec {
pname = "rust-esp";
version = "1.78.0.0";
src = fetchurl {
url = "https://github.com/esp-rs/rust-build/releases/download/v${version}/rust-${version}-${platform}.tar.xz";
sha256 = {
aarch64-linux = lib.fakeSha256;
x86_64-linux = lib.fakeSha256;
x86_64-darwin = lib.fakeSha256;
aarch64-darwin = "sha256-iWnzDk2wXh0DH6o/a2vEjQgebC8Dkoqo2H0Vsoxwupw=";
}.${stdenv.hostPlatform.system};
};
installPhase = ''
patchShebangs install.sh
CFG_DISABLE_LDCONFIG=1 ./install.sh --prefix=$out
rm $out/lib/rustlib/{components,install.log,manifest-*,rust-installer-version,uninstall.sh} || true
${lib.optionalString stdenv.isLinux ''
if [ -d $out/bin ]; then
for file in $(find $out/bin -type f); do
if isELF "$file"; then
patchelf \
--set-interpreter ${stdenv.cc.bintools.dynamicLinker} \
--set-rpath ${lib.rpath} \
"$file" || true
fi
done
fi
if [ -d $out/lib ]; then
for file in $(find $out/lib -type f); do
if isELF "$file"; then
patchelf --set-rpath ${lib.rpath} "$file" || true
fi
done
fi
if [ -d $out/libexec ]; then
for file in $(find $out/libexec -type f); do
if isELF "$file"; then
patchelf \
--set-interpreter ${stdenv.cc.bintools.dynamicLinker} \
--set-rpath ${lib.rpath} \
"$file" || true
fi
done
fi
for file in $(find $out/lib/rustlib/*/bin -type f); do
if isELF "$file"; then
patchelf \
--set-interpreter ${stdenv.cc.bintools.dynamicLinker} \
--set-rpath ${stdenv.cc.cc.lib}/lib:${lib.rpath} \
"$file" || true
fi
done
''}
'';
dontStrip = true;
}