Skip to content

Instantly share code, notes, and snippets.

@Tobba
Last active August 29, 2015 14:21
Show Gist options
  • Save Tobba/44e004f97ddfa119cb27 to your computer and use it in GitHub Desktop.
Save Tobba/44e004f97ddfa119cb27 to your computer and use it in GitHub Desktop.
{date, hash}:
let
pkgs = import <nixpkgs> {};
stdenv = pkgs.stdenv;
in stdenv.mkDerivation rec {
name = "rust-nightly-${date}";
src = pkgs.fetchurl {
url = "http://static.rust-lang.org/dist/${date}/rust-nightly-x86_64-unknown-linux-gnu.tar.gz";
sha256 = hash;
};
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/lib
mkdir -p $out/share
mkdir -p $out/etc
cp -t $out/bin -r -- rustc/bin/*
cp -t $out/lib -r -- rustc/lib/*
cp -t $out/share -r -- rustc/share/*
cp -t $out/bin -r -- cargo/bin/*
cp -t $out/lib -r -- cargo/lib/*
cp -t $out/share -r -- cargo/share/*
cp -t $out/etc -r -- cargo/etc/*
# why doesn't this get fixed in patchPhase?
for file in "$out/bin/rustc $out/bin/rustdoc $out/bin/cargo"
do
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath $out/lib:${stdenv.cc.cc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"} $file
done
for file in $(find $out/lib -name "*.so")
do
patchelf --set-rpath $out/lib $file
done
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment