git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #24927 from Mic92/rustup

rustup: init at 1.2.0

commitc7ac0f39b56135cc47734c60d73b97688cae9071 authorJörg Thalheim <Mic92@users.noreply.github.com> dateMon 17 Apr 2017, 17:10 (10 years ago) parente9f1d8610eef8c
4 files changed+136−3
doc/languages-frameworks/rust.md+2−2 pkgs/development/tools/rust/rustup/0001-use-hardcoded-dynamic-linker.patch+75 pkgs/development/tools/rust/rustup/default.nix+55 pkgs/top-level/all-packages.nix+4−1
doc/languages-frameworks/rust.md+2−2
@@ -17,8 +17,8 @@ into the `environment.systemPackages` or bring them into scope with
1717`nix-shell -p rustStable.rustc -p rustStable.cargo`.
1818
1919There are also `rustBeta` and `rustNightly` package sets available.
20−These are not updated very regulary. For daily builds see
21−[Using the Rust nightlies overlay](#using-the-rust-nightlies-overlay)
20+These are not updated very regulary. For daily builds use either rustup from
21+nixpkgs or use the [Rust nightlies overlay](#using-the-rust-nightlies-overlay).
2222
2323## Packaging Rust applications
2424
pkgs/development/tools/rust/rustup/0001-use-hardcoded-dynamic-linker.patchnew file+75
@@ -0,0 +1,75 @@
1+From 36c053f37670c6003f9e8dc001741f7c49e9526a Mon Sep 17 00:00:00 2001
2+From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
3+Date: Sat, 15 Apr 2017 20:42:10 +0200
4+Subject: [PATCH] use hardcoded dynamic-linker
5+MIME-Version: 1.0
6+Content-Type: text/plain; charset=UTF-8
7+Content-Transfer-Encoding: 8bit
8+
9+Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
10+---
11+ src/rustup-cli/common.rs | 3 ++-
12+ src/rustup/toolchain.rs | 22 ++++++++++++++++++++--
13+ 2 files changed, 22 insertions(+), 3 deletions(-)
14+
15+diff --git a/src/rustup-cli/common.rs b/src/rustup-cli/common.rs
16+index 1abf345..21096e7 100644
17+--- a/src/rustup-cli/common.rs
18++++ b/src/rustup-cli/common.rs
19+@@ -220,7 +220,8 @@ pub fn rustc_version(toolchain: &Toolchain) -> String {
20+ if toolchain.exists() {
21+ let rustc_path = toolchain.binary_file("rustc");
22+ if utils::is_file(&rustc_path) {
23+- let mut cmd = Command::new(&rustc_path);
24++ let mut cmd = Command::new("@dynamicLinker@");
25++ cmd.arg(&rustc_path);
26+ cmd.arg("--version");
27+ toolchain.set_ldpath(&mut cmd);
28+
29+diff --git a/src/rustup/toolchain.rs b/src/rustup/toolchain.rs
30+index dc29c32..212a4ab 100644
31+--- a/src/rustup/toolchain.rs
32++++ b/src/rustup/toolchain.rs
33+@@ -315,7 +315,7 @@ impl<'a> Toolchain<'a> {
34+ }
35+ Path::new(&binary)
36+ };
37+- let mut cmd = Command::new(&path);
38++ let mut cmd = wrap_elf_interpreter(&path);
39+ self.set_env(&mut cmd);
40+ Ok(cmd)
41+ }
42+@@ -363,7 +363,7 @@ impl<'a> Toolchain<'a> {
43+ } else {
44+ src_file
45+ };
46+- let mut cmd = Command::new(exe_path);
47++ let mut cmd = wrap_elf_interpreter(exe_path);
48+ self.set_env(&mut cmd);
49+ cmd.env("RUSTUP_TOOLCHAIN", &primary_toolchain.name);
50+ Ok(cmd)
51+@@ -648,3 +648,21 @@ impl<'a> Toolchain<'a> {
52+ path
53+ }
54+ }
55++
56++fn wrap_elf_interpreter<S: AsRef<OsStr>>(p: S) -> Command {
57++ use std::fs::File;
58++ use std::io::Read;
59++ let path = Path::new(&p);
60++ let is_elf = File::open(path).map(|mut f| {
61++ let mut buf = [0; 4];
62++ let _ = f.read(&mut buf);
63++ buf == b"\x7fELF"[..]
64++ }).unwrap_or(false);
65++ if is_elf {
66++ let mut cmd = Command::new("@dynamicLinker@");
67++ cmd.arg(&path);
68++ cmd
69++ } else {
70++ Command::new(&path)
71++ }
72++}
73+--
74+2.12.2
75+
pkgs/development/tools/rust/rustup/default.nixnew file+55
@@ -0,0 +1,55 @@
1+{ stdenv, lib, runCommand
2+, fetchFromGitHub, rustPlatform
3+, pkgconfig, curl, Security }:
4+
5+rustPlatform.buildRustPackage rec {
6+ name = "rustup-${version}";
7+ version = "1.2.0";
8+
9+ depsSha256 = "06bfz5kyj3k0yxv55dq0s1arx34sy1jjfrpgd83rf99026vcm5x2";
10+
11+ src = fetchFromGitHub {
12+ owner = "rust-lang-nursery";
13+ repo = "rustup.rs";
14+ rev = version;
15+ sha256 = "0qwl27wh7j03h511bd8fq5fif5xcmkiyy9rm3hri7czjqr01mw0v";
16+ };
17+
18+ nativeBuildInputs = [ pkgconfig ];
19+
20+ buildInputs = [
21+ curl
22+ ] ++ stdenv.lib.optionals stdenv.isDarwin [ Security ];
23+
24+ cargoBuildFlags = [ "--features no-self-update" ];
25+
26+ patches = lib.optionals stdenv.isLinux [
27+ (runCommand "0001-use-hardcoded-dynamic-linker.patch" { CC=stdenv.cc; } ''
28+ export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
29+ substituteAll ${./0001-use-hardcoded-dynamic-linker.patch} $out
30+ '')
31+ ];
32+
33+ postInstall = ''
34+ pushd $out/bin
35+ mv rustup-init rustup
36+ for link in cargo rustc rustdoc rust-gdb rust-lldb; do
37+ ln -s rustup $link
38+ done
39+ popd
40+
41+ # tries to create .rustup
42+ export HOME=$(mktemp -d)
43+ mkdir -p "$out/share/"{bash-completion/completions,fish/completions,zsh/site-functions}
44+ $out/bin/rustup completions bash > "$out/share/bash-completion/completions/rustup"
45+ $out/bin/rustup completions fish > "$out/share/fish/completions/rustup.fish"
46+ $out/bin/rustup completions zsh > "$out/share/zsh/site-functions/_rustup"
47+ '';
48+
49+ meta = with stdenv.lib; {
50+ description = "The Rust toolchain installer";
51+ homepage = https://www.rustup.rs/;
52+ license = licenses.mit;
53+ maintainer = [ maintainers.mic92 ];
54+ };
55+}
pkgs/top-level/all-packages.nix+4−1
@@ -771,7 +771,7 @@ with pkgs;
771771 cfdyndns = callPackage ../applications/networking/dyndns/cfdyndns { };
772772
773773 ckbcomp = callPackage ../tools/X11/ckbcomp { };
774−
774+
775775 clac = callPackage ../tools/misc/clac {};
776776
777777 clasp = callPackage ../tools/misc/clasp { };
@@ -5614,6 +5614,9 @@ with pkgs;
56145614 rustracer = callPackage ../development/tools/rust/racer { };
56155615 rustracerd = callPackage ../development/tools/rust/racerd { };
56165616 rust-bindgen = callPackage ../development/tools/rust/bindgen { };
5617+ rustup = callPackage ../development/tools/rust/rustup {
5618+ inherit (darwin.apple_sdk.frameworks) Security;
5619+ };
56175620
56185621 sbclBootstrap = callPackage ../development/compilers/sbcl/bootstrap.nix {};
56195622 sbcl = callPackage ../development/compilers/sbcl {};