Created
December 11, 2015 17:47
-
-
Save et4te/55d2e9dd0ad5bcaa2729 to your computer and use it in GitHub Desktop.
Final variant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ stdenv, lib, fetchzip, zlib }: | |
# rustc and cargo nightly binaries | |
let | |
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 == "i686-darwin" | |
then "i686-apple-darwin" | |
else if stdenv.system == "x86_64-darwin" | |
then "x86_64-apple-darwin" | |
else abort "no snapshot to bootstrap for this platform (missing target triple)"; | |
generic = { pname, archive, exes}: { date, hash }: stdenv.mkDerivation rec { | |
name = "${pname}-${version}"; | |
version = "nightly-${date}"; | |
# TODO meta; | |
src = fetchzip { | |
url = "${archive}/${date}/${pname}-nightly-${target}.tar.gz"; | |
sha256 = hash; | |
}; | |
dontStrip = true; | |
installPhase = '' | |
./install.sh --prefix=$out | |
''; | |
preFixup = if stdenv.isLinux then let | |
# it's overkill, but fixup will prune | |
rpath = stdenv.lib.concatStringsSep ":" [ | |
"$out/lib" | |
(stdenv.lib.makeLibraryPath [ zlib ]) | |
''${stdenv.cc.cc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"}'' | |
]; | |
in '' | |
for executable in ${stdenv.lib.concatMapStringsSep " " (s: "$out/bin/" + s) exes}; do | |
patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.cc.dynamicLinker}" \ | |
--set-rpath "${rpath}" \ | |
"$executable" | |
done | |
for library in $out/lib/*.so; do | |
patchelf --set-rpath "${rpath}" "$library" | |
done | |
'' else ""; | |
}; | |
in rec { | |
rust = generic { | |
pname = "rust"; | |
archive = "https://static.rust-lang.org/dist"; | |
exes = [ "cargo" "rustc" "rustdoc" ]; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment