git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #122558 from davidtwco/rustup-toolchain-install-master-init

rustup-toolchain-install-master: init at 1.7.3

commit594fbfe27905f2fd98d9431038814e497b4fcad1 authorSandro <sandro.jaeckel@gmail.com> dateTue 18 May 2021, 03:19 (6 years ago) parente34309bd9a4bb1
3 files changed+120
pkgs/development/tools/rust/rustup-toolchain-install-master/0001-dynamically-patchelf-binaries.patch+61 pkgs/development/tools/rust/rustup-toolchain-install-master/default.nix+56 pkgs/top-level/all-packages.nix+3
pkgs/development/tools/rust/rustup-toolchain-install-master/0001-dynamically-patchelf-binaries.patchnew file+61
@@ -0,0 +1,61 @@
1+diff --git a/src/main.rs b/src/main.rs
2+index 3cb6896..7f070e0 100644
3+--- a/src/main.rs
4++++ b/src/main.rs
5+@@ -275,7 +275,9 @@ fn install_single_toolchain(
6+
7+ // install
8+ if maybe_dry_client.is_some() {
9+- rename(&toolchain.dest, toolchain_path)?;
10++ rename(&toolchain.dest, toolchain_path.clone())?;
11++ nix_patchelf(toolchain_path)
12++ .expect("failed to patch toolchain for NixOS");
13+ eprintln!(
14+ "toolchain `{}` is successfully installed!",
15+ toolchain.dest.display()
16+@@ -291,6 +293,45 @@ fn install_single_toolchain(
17+ Ok(())
18+ }
19+
20++fn nix_patchelf(mut toolchain_path: PathBuf) -> Result<(), Error> {
21++ toolchain_path.push("bin");
22++
23++ for entry in toolchain_path.read_dir()? {
24++ let entry = entry?;
25++ if !entry.file_type()?.is_file() {
26++ continue;
27++ }
28++
29++ eprintln!("info: you seem to be running NixOS. Attempting to patch {}",
30++ entry.path().to_str().unwrap());
31++ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
32++ .arg("--set-interpreter")
33++ .arg("@dynamicLinker@")
34++ .arg(entry.path())
35++ .output();
36++ }
37++
38++ toolchain_path.pop();
39++ toolchain_path.push("lib");
40++
41++ for entry in toolchain_path.read_dir()? {
42++ let entry = entry?;
43++ if !entry.file_type()?.is_file() {
44++ continue;
45++ }
46++
47++ eprintln!("info: you seem to be running NixOS. Attempting to patch {}",
48++ entry.path().to_str().unwrap());
49++ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
50++ .arg("--set-rpath")
51++ .arg("@libPath@")
52++ .arg(entry.path())
53++ .output();
54++ }
55++
56++ Ok(())
57++}
58++
59+ fn fetch_master_commit(client: &Client, github_token: Option<&str>) -> Result<String, Error> {
60+ eprintln!("fetching master commit hash... ");
61+ fetch_master_commit_via_git()
pkgs/development/tools/rust/rustup-toolchain-install-master/default.nixnew file+56
@@ -0,0 +1,56 @@
1+{ stdenv
2+, lib
3+, fetchFromGitHub
4+, rustPlatform
5+, pkg-config
6+, openssl
7+, runCommand
8+, patchelf
9+, zlib
10+, Security
11+}:
12+
13+rustPlatform.buildRustPackage rec {
14+ pname = "rustup-toolchain-install-master";
15+ version = "1.7.3";
16+
17+ src = fetchFromGitHub {
18+ owner = "kennytm";
19+ repo = pname;
20+ rev = "v${version}";
21+ hash = "sha256-J25ER/g8Kylw/oTIEl4Gl8i1xmhR+4JM5M5EHpl1ras=";
22+ };
23+
24+ patches =
25+ let
26+ patchelfPatch = runCommand "0001-dynamically-patchelf-binaries.patch" {
27+ CC = stdenv.cc;
28+ patchelf = patchelf;
29+ libPath = "$ORIGIN/../lib:${lib.makeLibraryPath [ zlib ]}";
30+ }
31+ ''
32+ export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
33+ substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
34+ --subst-var patchelf \
35+ --subst-var dynamicLinker \
36+ --subst-var libPath
37+ '';
38+ in
39+ lib.optionals stdenv.isLinux [ patchelfPatch ];
40+
41+ nativeBuildInputs = [ pkg-config ];
42+ buildInputs = [
43+ openssl
44+ ] ++ lib.optionals stdenv.isDarwin [
45+ Security
46+ ];
47+
48+ cargoSha256 = "n7t8Ap9hdhrjmtKjfdyozf26J7yhu57pedm19CunLF4=";
49+
50+ meta = with lib; {
51+ description = "Install a rustc master toolchain usable from rustup";
52+ homepage = "https://github.com/kennytm/rustup-toolchain-install-master";
53+ license = licenses.mit;
54+ maintainers = with maintainers; [ davidtwco ];
55+ };
56+}
pkgs/top-level/all-packages.nix+3
@@ -11658,6 +11658,9 @@ in
1165811658 rustup = callPackage ../development/tools/rust/rustup {
1165911659 inherit (darwin.apple_sdk.frameworks) CoreServices Security;
1166011660 };
11661+ rustup-toolchain-install-master = callPackage ../development/tools/rust/rustup-toolchain-install-master {
11662+ inherit (darwin.apple_sdk.frameworks) Security;
11663+ };
1166111664
1166211665 sagittarius-scheme = callPackage ../development/compilers/sagittarius-scheme {};
1166311666