1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 runCommand,
6 stdenv,
7 patchelf,
8 zlib,
9 pkg-config,
10 openssl,
11 xz,
12}:
13
14rustPlatform.buildRustPackage rec {
15 pname = "rustup-toolchain-install-master";
16 version = "1.7.3";
17
18 src = fetchFromGitHub {
19 owner = "kennytm";
20 repo = pname;
21 rev = "v${version}";
22 hash = "sha256-J25ER/g8Kylw/oTIEl4Gl8i1xmhR+4JM5M5EHpl1ras=";
23 };
24
25 cargoLock = {
26 lockFile = ./Cargo.lock;
27 };
28
29 patches =
30 let
31 patchelfPatch =
32 runCommand "0001-dynamically-patchelf-binaries.patch"
33 {
34 CC = stdenv.cc;
35 patchelf = patchelf;
36 libPath = "$ORIGIN/../lib:${lib.makeLibraryPath [ zlib ]}";
37 }
38 ''
39 export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
40 substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
41 --subst-var patchelf \
42 --subst-var dynamicLinker \
43 --subst-var libPath
44 '';
45 in
46 lib.optionals stdenv.hostPlatform.isLinux [ patchelfPatch ];
47
48 nativeBuildInputs = [ pkg-config ];
49 buildInputs = [
50 openssl
51 xz
52 ];
53
54 # update Cargo.lock to work with openssl 3
55 postPatch = ''
56 ln -sf ${./Cargo.lock} Cargo.lock
57 '';
58
59 meta = with lib; {
60 description = "Install a rustc master toolchain usable from rustup";
61 mainProgram = "rustup-toolchain-install-master";
62 homepage = "https://github.com/kennytm/rustup-toolchain-install-master";
63 license = licenses.mit;
64 maintainers = [ ];
65 };
66}