From 210452979adb21355f1a2c5dbcc16608713f9929 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 30 Jul 2014 06:00:56 +0200 Subject: [PATCH 1/6] rust: Prepare for more versions part 1: - Factor out some things that REALLY shouldn't change between versions --- pkgs/development/compilers/rust/common.nix | 32 ++++++++++++++++ pkgs/development/compilers/rust/default.nix | 42 ++++++++------------- 2 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 pkgs/development/compilers/rust/common.nix diff --git a/pkgs/development/compilers/rust/common.nix b/pkgs/development/compilers/rust/common.nix new file mode 100644 index 00000000000..4ba6f159b4c --- /dev/null +++ b/pkgs/development/compilers/rust/common.nix @@ -0,0 +1,32 @@ +{stdenv, version}: + +{ + inherit version; + + platform = if stdenv.system == "i686-linux" + then "linux-i386" + else if stdenv.system == "x86_64-linux" + then "linux-x86_64" + else if stdenv.system == "x86_64-darwin" + then "macos-x86_64" + else abort "no snapshot to boostrap for this platform (missing platform url suffix)"; + + target = if stdenv.system == "i686-linux" + then "i686-unknown-linux-gnu" + else if stdenv.system == "x86_64-linux" + then "x86_64-unknown-linux-gnu" + else if stdenv.system == "x86_64-darwin" + then "x86_64-apple-darwin" + else abort "no snapshot to boostrap for this platform (missing target triple"; + + meta = with stdenv.lib; { + homepage = http://www.rust-lang.org/; + description = "A safe, concurrent, practical language"; + maintainers = with maintainers; [ madjar cstrahan ]; + license = map (builtins.getAttr "shortName") [ licenses.mit licenses.asl20 ]; + # platforms as per http://static.rust-lang.org/doc/master/tutorial.html#getting-started + platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ]; + }; + + name = "rust-${version}"; +} diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix index 2c27cf778a1..c2696bae922 100644 --- a/pkgs/development/compilers/rust/default.nix +++ b/pkgs/development/compilers/rust/default.nix @@ -14,23 +14,23 @@ */ -with if stdenv.system == "i686-linux" then { - platform = "linux-i386"; - snapshot = "84339ea0f796ae468ef86797ef4587274bec19ea"; - target = "i686-unknown-linux-gnu"; -} else if stdenv.system == "x86_64-linux" then { - platform = "linux-x86_64"; - snapshot = "bd8a6bc1f28845b7f4b768f6bfa06e7fbdcfcaae"; - target = "x86_64-unknown-linux-gnu"; -} else if stdenv.system == "x86_64-darwin" then { - platform = "macos-x86_64"; - snapshot = "4a8c2e1b7634d73406bac32a1a97893ec3ed818d"; -} else {}; -let snapshotDate = "2014-06-21"; +with ((import ./common.nix) {inherit stdenv; version = "0.11.0"; }); + +let snapshot = if stdenv.system == "i686-linux" + then "84339ea0f796ae468ef86797ef4587274bec19ea" + else if stdenv.system == "x86_64-linux" + then "bd8a6bc1f28845b7f4b768f6bfa06e7fbdcfcaae" + else if stdenv.system == "x86_64-darwin" + then "4a8c2e1b7634d73406bac32a1a97893ec3ed818d" + else abort "no-snapshot for platform ${stdenv.system}"; + snapshotDate = "2014-06-21"; snapshotRev = "db9af1d"; - snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshot}.tar.bz2"; in -stdenv.mkDerivation { - name = "rust-0.11.0"; + snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshot}.tar.bz2"; + +in stdenv.mkDerivation { + inherit name; + inherit version; + inherit meta; src = fetchurl { url = http://static.rust-lang.org/dist/rust-0.11.0.tar.gz; @@ -67,14 +67,4 @@ stdenv.mkDerivation { buildInputs = [ which file perl curl python27 makeWrapper ]; enableParallelBuilding = true; - - meta = with stdenv.lib; { - homepage = http://www.rust-lang.org/; - description = "A safe, concurrent, practical language"; - maintainers = with maintainers; [ madjar cstrahan ]; - license = map (builtins.getAttr "shortName") [ licenses.mit licenses.asl20 ]; - # platforms as per http://static.rust-lang.org/doc/master/tutorial.html#getting-started - platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ]; - }; } - From 399f8b48f9935e18539cd3309c4eab3920ae22fa Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 30 Jul 2014 06:04:38 +0200 Subject: [PATCH 2/6] rust: Prepare for more versions part 2: - Default is now an alias for 0.11 --- pkgs/development/compilers/rust/0.11.nix | 70 ++++++++++++++++++++ pkgs/development/compilers/rust/default.nix | 71 +-------------------- 2 files changed, 71 insertions(+), 70 deletions(-) create mode 100644 pkgs/development/compilers/rust/0.11.nix diff --git a/pkgs/development/compilers/rust/0.11.nix b/pkgs/development/compilers/rust/0.11.nix new file mode 100644 index 00000000000..c2696bae922 --- /dev/null +++ b/pkgs/development/compilers/rust/0.11.nix @@ -0,0 +1,70 @@ +{stdenv, fetchurl, which, file, perl, curl, python27, makeWrapper}: + +/* Rust's build process has a few quirks : + +- It requires some patched in llvm that haven't landed upstream, so it + compiles its own llvm. This might change in the future, so at some + point we may be able to switch to nix's llvm. + +- The Rust compiler is written is Rust, so it requires a bootstrap + compiler, which is downloaded during the build. To make the build + pure, we download it ourself before and put it where it is + expected. Once the language is stable (1.0) , we might want to + switch it to use nix's packaged rust compiler. + +*/ + +with ((import ./common.nix) {inherit stdenv; version = "0.11.0"; }); + +let snapshot = if stdenv.system == "i686-linux" + then "84339ea0f796ae468ef86797ef4587274bec19ea" + else if stdenv.system == "x86_64-linux" + then "bd8a6bc1f28845b7f4b768f6bfa06e7fbdcfcaae" + else if stdenv.system == "x86_64-darwin" + then "4a8c2e1b7634d73406bac32a1a97893ec3ed818d" + else abort "no-snapshot for platform ${stdenv.system}"; + snapshotDate = "2014-06-21"; + snapshotRev = "db9af1d"; + snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshot}.tar.bz2"; + +in stdenv.mkDerivation { + inherit name; + inherit version; + inherit meta; + + src = fetchurl { + url = http://static.rust-lang.org/dist/rust-0.11.0.tar.gz; + sha256 = "1fhi8iiyyj5j48fpnp93sfv781z1dm0xy94h534vh4mz91jf7cyi"; + }; + + # We need rust to build rust. If we don't provide it, configure will try to download it. + snapshot = stdenv.mkDerivation { + name = "rust-stage0"; + src = fetchurl { + url = "http://static.rust-lang.org/stage0-snapshots/${snapshotName}"; + sha1 = snapshot; + }; + dontStrip = true; + installPhase = '' + mkdir -p "$out" + cp -r bin "$out/bin" + '' + (if stdenv.isLinux then '' + patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.gcc.dynamicLinker}" \ + --set-rpath "${stdenv.gcc.gcc}/lib/:${stdenv.gcc.gcc}/lib64/" \ + "$out/bin/rustc" + '' else ""); + }; + + configureFlags = [ "--enable-local-rust" "--local-rust-root=$snapshot" ]; + + # The compiler requires cc, so we patch the source to tell it where to find it + patches = [ ./hardcode_paths.patch ./local_stage0.patch ]; + postPatch = '' + substituteInPlace src/librustc/back/link.rs \ + --subst-var-by "ccPath" "${stdenv.gcc}/bin/cc" \ + --subst-var-by "arPath" "${stdenv.gcc.binutils}/bin/ar" + ''; + + buildInputs = [ which file perl curl python27 makeWrapper ]; + enableParallelBuilding = true; +} diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix index c2696bae922..6a02145c8f0 100644 --- a/pkgs/development/compilers/rust/default.nix +++ b/pkgs/development/compilers/rust/default.nix @@ -1,70 +1 @@ -{stdenv, fetchurl, which, file, perl, curl, python27, makeWrapper}: - -/* Rust's build process has a few quirks : - -- It requires some patched in llvm that haven't landed upstream, so it - compiles its own llvm. This might change in the future, so at some - point we may be able to switch to nix's llvm. - -- The Rust compiler is written is Rust, so it requires a bootstrap - compiler, which is downloaded during the build. To make the build - pure, we download it ourself before and put it where it is - expected. Once the language is stable (1.0) , we might want to - switch it to use nix's packaged rust compiler. - -*/ - -with ((import ./common.nix) {inherit stdenv; version = "0.11.0"; }); - -let snapshot = if stdenv.system == "i686-linux" - then "84339ea0f796ae468ef86797ef4587274bec19ea" - else if stdenv.system == "x86_64-linux" - then "bd8a6bc1f28845b7f4b768f6bfa06e7fbdcfcaae" - else if stdenv.system == "x86_64-darwin" - then "4a8c2e1b7634d73406bac32a1a97893ec3ed818d" - else abort "no-snapshot for platform ${stdenv.system}"; - snapshotDate = "2014-06-21"; - snapshotRev = "db9af1d"; - snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshot}.tar.bz2"; - -in stdenv.mkDerivation { - inherit name; - inherit version; - inherit meta; - - src = fetchurl { - url = http://static.rust-lang.org/dist/rust-0.11.0.tar.gz; - sha256 = "1fhi8iiyyj5j48fpnp93sfv781z1dm0xy94h534vh4mz91jf7cyi"; - }; - - # We need rust to build rust. If we don't provide it, configure will try to download it. - snapshot = stdenv.mkDerivation { - name = "rust-stage0"; - src = fetchurl { - url = "http://static.rust-lang.org/stage0-snapshots/${snapshotName}"; - sha1 = snapshot; - }; - dontStrip = true; - installPhase = '' - mkdir -p "$out" - cp -r bin "$out/bin" - '' + (if stdenv.isLinux then '' - patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.gcc.dynamicLinker}" \ - --set-rpath "${stdenv.gcc.gcc}/lib/:${stdenv.gcc.gcc}/lib64/" \ - "$out/bin/rustc" - '' else ""); - }; - - configureFlags = [ "--enable-local-rust" "--local-rust-root=$snapshot" ]; - - # The compiler requires cc, so we patch the source to tell it where to find it - patches = [ ./hardcode_paths.patch ./local_stage0.patch ]; - postPatch = '' - substituteInPlace src/librustc/back/link.rs \ - --subst-var-by "ccPath" "${stdenv.gcc}/bin/cc" \ - --subst-var-by "arPath" "${stdenv.gcc.binutils}/bin/ar" - ''; - - buildInputs = [ which file perl curl python27 makeWrapper ]; - enableParallelBuilding = true; -} +import ./0.11.nix From a510e024b6d3540ba4d8764631a642a94b52ee54 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 31 Jul 2014 00:12:16 +0200 Subject: [PATCH 3/6] rust: Add hashes for i686-darwin --- pkgs/development/compilers/rust/0.11.nix | 2 ++ pkgs/development/compilers/rust/common.nix | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/pkgs/development/compilers/rust/0.11.nix b/pkgs/development/compilers/rust/0.11.nix index c2696bae922..1c3b09b0985 100644 --- a/pkgs/development/compilers/rust/0.11.nix +++ b/pkgs/development/compilers/rust/0.11.nix @@ -20,6 +20,8 @@ let snapshot = if stdenv.system == "i686-linux" then "84339ea0f796ae468ef86797ef4587274bec19ea" else if stdenv.system == "x86_64-linux" then "bd8a6bc1f28845b7f4b768f6bfa06e7fbdcfcaae" + else if stdenv.system == "i686-darwin" + then "3f25b2680efbab16ad074477a19d49dcce475977" else if stdenv.system == "x86_64-darwin" then "4a8c2e1b7634d73406bac32a1a97893ec3ed818d" else abort "no-snapshot for platform ${stdenv.system}"; diff --git a/pkgs/development/compilers/rust/common.nix b/pkgs/development/compilers/rust/common.nix index 4ba6f159b4c..b190b937dda 100644 --- a/pkgs/development/compilers/rust/common.nix +++ b/pkgs/development/compilers/rust/common.nix @@ -7,6 +7,8 @@ then "linux-i386" else if stdenv.system == "x86_64-linux" then "linux-x86_64" + else if stdenv.system == "i686-darwin" + then "macos-i386" else if stdenv.system == "x86_64-darwin" then "macos-x86_64" else abort "no snapshot to boostrap for this platform (missing platform url suffix)"; @@ -15,6 +17,8 @@ then "i686-unknown-linux-gnu" else if stdenv.system == "x86_64-linux" then "x86_64-unknown-linux-gnu" + else if stdenv.system == "i686-darwin" + then "i686-apple-darwin" else if stdenv.system == "x86_64-darwin" then "x86_64-apple-darwin" else abort "no snapshot to boostrap for this platform (missing target triple"; From 584114b697dfb4fd3c248207f7a6e9c8cda3f81a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 31 Jul 2014 20:42:20 +0200 Subject: [PATCH 4/6] rust: Add an alternative package for the master tip based off of pull request #3084 --- pkgs/development/compilers/rust/head.nix | 73 ++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 3 +- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/compilers/rust/head.nix diff --git a/pkgs/development/compilers/rust/head.nix b/pkgs/development/compilers/rust/head.nix new file mode 100644 index 00000000000..ad33906ae6e --- /dev/null +++ b/pkgs/development/compilers/rust/head.nix @@ -0,0 +1,73 @@ +{stdenv, fetchurl, fetchgit, which, file, perl, curl, python27, makeWrapper}: + +/* Rust's build process has a few quirks : + +- It requires some patched in llvm that haven't landed upstream, so it + compiles its own llvm. This might change in the future, so at some + point we may be able to switch to nix's llvm. + +- The Rust compiler is written is Rust, so it requires a bootstrap + compiler, which is downloaded during the build. To make the build + pure, we download it ourself before and put it where it is + expected. Once the language is stable (1.0) , we might want to + switch it to use nix's packaged rust compiler. + +*/ + +with ((import ./common.nix) {inherit stdenv; version = "0.12.0-pre-7a25cf3f3"; }); + +let snapshot = if stdenv.system == "i686-linux" + then "a5e1bb723020ac35173d49600e76b0935e257a6a" + else if stdenv.system == "x86_64-linux" + then "1a2407df17442d93d1c34c916269a345658045d7" + else if stdenv.system == "i686-darwin" + then "6648fa88e41ad7c0991a085366e36d56005873ca" + else if stdenv.system == "x86_64-darwin" + then "71b2d1dfd0abe1052908dc091e098ed22cf272c6" + else abort "no-snapshot for platform ${stdenv.system}"; + snapshotDate = "2014-07-17"; + snapshotRev = "9fc8394"; + snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshot}.tar.bz2"; + +in stdenv.mkDerivation { + inherit name; + inherit version; + inherit meta; + + src = fetchgit { + url = https://github.com/rust-lang/rust; + rev = "7a25cf3f30fa5fae2e868fa910ecc850f5e9ee65"; + sha256 = "1hx8vd4gn5plbdvr0zvdvqyw9x9r2vbmh112h2f5d2xxsf9p7rf1"; + }; + + # We need rust to build rust. If we don't provide it, configure will try to download it. + snapshot = stdenv.mkDerivation { + name = "rust-stage0"; + src = fetchurl { + url = "http://static.rust-lang.org/stage0-snapshots/${snapshotName}"; + sha1 = snapshot; + }; + dontStrip = true; + installPhase = '' + mkdir -p "$out" + cp -r bin "$out/bin" + '' + (if stdenv.isLinux then '' + patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.gcc.dynamicLinker}" \ + --set-rpath "${stdenv.gcc.gcc}/lib/:${stdenv.gcc.gcc}/lib64/" \ + "$out/bin/rustc" + '' else ""); + }; + + configureFlags = [ "--enable-local-rust" "--local-rust-root=$snapshot" ]; + + # The compiler requires cc, so we patch the source to tell it where to find it + patches = [ ./hardcode_paths.patch ./local_stage0.patch ]; + postPatch = '' + substituteInPlace src/librustc/back/link.rs \ + --subst-var-by "ccPath" "${stdenv.gcc}/bin/cc" \ + --subst-var-by "arPath" "${stdenv.gcc.binutils}/bin/ar" + ''; + + buildInputs = [ which file perl curl python27 makeWrapper ]; + enableParallelBuilding = true; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2d321fd2d80..00335834aca 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3289,7 +3289,8 @@ let roadsend = callPackage ../development/compilers/roadsend { }; - rust = callPackage ../development/compilers/rust {}; + rust = callPackage ../development/compilers/rust {}; + rustMaster = callPackage ../development/compilers/rust/head.nix {}; sbclBootstrap = callPackage ../development/compilers/sbcl/bootstrap.nix {}; sbcl = callPackage ../development/compilers/sbcl { From 641ccec337a701d5236e67a12e97846e52a0e9a2 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 1 Aug 2014 04:28:54 +0200 Subject: [PATCH 5/6] rust: Refer to 0.11.nix directly in all-packages rather than use default.nix indirection --- pkgs/development/compilers/rust/default.nix | 1 - pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 pkgs/development/compilers/rust/default.nix diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix deleted file mode 100644 index 6a02145c8f0..00000000000 --- a/pkgs/development/compilers/rust/default.nix +++ /dev/null @@ -1 +0,0 @@ -import ./0.11.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 00335834aca..8a250815843 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3289,7 +3289,7 @@ let roadsend = callPackage ../development/compilers/roadsend { }; - rust = callPackage ../development/compilers/rust {}; + rust = callPackage ../development/compilers/rust/0.11.nix {}; rustMaster = callPackage ../development/compilers/rust/head.nix {}; sbclBootstrap = callPackage ../development/compilers/sbcl/bootstrap.nix {}; From 8f763d0539b1f39c6cf3e86f54b2661edeb74ea9 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 1 Aug 2014 04:37:07 +0200 Subject: [PATCH 6/6] rustc: rename rust to rustc, but keep rust attr name for backwards compat --- pkgs/development/compilers/{rust => rustc}/0.11.nix | 0 pkgs/development/compilers/{rust => rustc}/common.nix | 2 +- .../compilers/{rust => rustc}/hardcode_paths.patch | 0 pkgs/development/compilers/{rust => rustc}/head.nix | 0 .../compilers/{rust => rustc}/local_stage0.patch | 0 pkgs/top-level/all-packages.nix | 7 +++++-- 6 files changed, 6 insertions(+), 3 deletions(-) rename pkgs/development/compilers/{rust => rustc}/0.11.nix (100%) rename pkgs/development/compilers/{rust => rustc}/common.nix (97%) rename pkgs/development/compilers/{rust => rustc}/hardcode_paths.patch (100%) rename pkgs/development/compilers/{rust => rustc}/head.nix (100%) rename pkgs/development/compilers/{rust => rustc}/local_stage0.patch (100%) diff --git a/pkgs/development/compilers/rust/0.11.nix b/pkgs/development/compilers/rustc/0.11.nix similarity index 100% rename from pkgs/development/compilers/rust/0.11.nix rename to pkgs/development/compilers/rustc/0.11.nix diff --git a/pkgs/development/compilers/rust/common.nix b/pkgs/development/compilers/rustc/common.nix similarity index 97% rename from pkgs/development/compilers/rust/common.nix rename to pkgs/development/compilers/rustc/common.nix index b190b937dda..7af19a40c79 100644 --- a/pkgs/development/compilers/rust/common.nix +++ b/pkgs/development/compilers/rustc/common.nix @@ -32,5 +32,5 @@ platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ]; }; - name = "rust-${version}"; + name = "rustc-${version}"; } diff --git a/pkgs/development/compilers/rust/hardcode_paths.patch b/pkgs/development/compilers/rustc/hardcode_paths.patch similarity index 100% rename from pkgs/development/compilers/rust/hardcode_paths.patch rename to pkgs/development/compilers/rustc/hardcode_paths.patch diff --git a/pkgs/development/compilers/rust/head.nix b/pkgs/development/compilers/rustc/head.nix similarity index 100% rename from pkgs/development/compilers/rust/head.nix rename to pkgs/development/compilers/rustc/head.nix diff --git a/pkgs/development/compilers/rust/local_stage0.patch b/pkgs/development/compilers/rustc/local_stage0.patch similarity index 100% rename from pkgs/development/compilers/rust/local_stage0.patch rename to pkgs/development/compilers/rustc/local_stage0.patch diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8a250815843..20cb2cd1cfb 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3289,8 +3289,11 @@ let roadsend = callPackage ../development/compilers/roadsend { }; - rust = callPackage ../development/compilers/rust/0.11.nix {}; - rustMaster = callPackage ../development/compilers/rust/head.nix {}; + rustc = callPackage ../development/compilers/rustc/0.11.nix {}; + rustcMaster = callPackage ../development/compilers/rustc/head.nix {}; + + rust = rustc; + sbclBootstrap = callPackage ../development/compilers/sbcl/bootstrap.nix {}; sbcl = callPackage ../development/compilers/sbcl {