2017-06-30 00:24:36 +02:00
|
|
|
{ stdenv, fetchurl, boehmgc, libatomic_ops, pcre, libevent, libiconv, llvm_4, makeWrapper }:
|
2016-12-21 09:21:31 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2017-06-30 00:24:36 +02:00
|
|
|
version = "0.23.0";
|
2016-12-21 09:21:31 +01:00
|
|
|
name = "crystal-${version}-1";
|
|
|
|
arch =
|
|
|
|
{
|
|
|
|
"x86_64-linux" = "linux-x86_64";
|
|
|
|
"i686-linux" = "linux-i686";
|
|
|
|
"x86_64-darwin" = "darwin-x86_64";
|
|
|
|
}."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
|
|
|
|
|
|
|
|
prebuiltBinary = fetchurl {
|
|
|
|
url = "https://github.com/crystal-lang/crystal/releases/download/${version}/crystal-${version}-1-${arch}.tar.gz";
|
|
|
|
sha256 =
|
|
|
|
{
|
2017-06-30 00:24:36 +02:00
|
|
|
"x86_64-linux" = "0nhs7swbll8hrk15kmmywngkhij80x62axiskb1gjmiwvzhlh0qx";
|
|
|
|
"i686-linux" = "03xp8d3lqflzzm26lpdn4yavj87qzgd6xyrqxp2pn9ybwrq8fx8a";
|
|
|
|
"x86_64-darwin" = "1prz6c1gs8z7dgpdy2id2mjn1c8f5p2bf9b39985bav448njbyjz";
|
2016-12-21 09:21:31 +01:00
|
|
|
}."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
|
|
|
|
};
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/crystal-lang/crystal/archive/${version}.tar.gz";
|
2017-06-30 00:24:36 +02:00
|
|
|
sha256 = "05ymwmjkl1b4m888p725kybpiap5ag2vj8l07d59j02inm5r0rcv";
|
2016-12-21 09:21:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# crystal on Darwin needs libiconv to build
|
|
|
|
buildInputs = [
|
2017-06-30 00:24:36 +02:00
|
|
|
boehmgc libatomic_ops pcre libevent llvm_4 makeWrapper
|
2016-12-21 09:21:31 +01:00
|
|
|
] ++ stdenv.lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
|
|
|
];
|
|
|
|
|
|
|
|
libPath = stdenv.lib.makeLibraryPath ([
|
|
|
|
boehmgc libatomic_ops pcre libevent
|
|
|
|
] ++ stdenv.lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
|
|
|
]);
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
tar zxf ${src}
|
|
|
|
tar zxf ${prebuiltBinary}
|
|
|
|
'';
|
|
|
|
|
|
|
|
sourceRoot = ".";
|
|
|
|
|
|
|
|
fixPrebuiltBinary = if stdenv.isDarwin then ''
|
|
|
|
wrapProgram $(pwd)/crystal-${version}-1/embedded/bin/crystal \
|
|
|
|
--suffix DYLD_LIBRARY_PATH : $libPath
|
|
|
|
''
|
|
|
|
else ''
|
|
|
|
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
|
|
|
crystal-${version}-1/embedded/bin/crystal
|
|
|
|
patchelf --set-rpath ${ stdenv.lib.makeLibraryPath [ stdenv.cc.cc ] } \
|
|
|
|
crystal-${version}-1/embedded/bin/crystal
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
2016-12-26 17:28:51 +01:00
|
|
|
# patch the script which launches the prebuilt compiler
|
|
|
|
substituteInPlace $(pwd)/crystal-${version}-1/bin/crystal --replace \
|
|
|
|
"/usr/bin/env bash" "${stdenv.shell}"
|
2016-12-27 18:05:45 +01:00
|
|
|
substituteInPlace $(pwd)/crystal-${version}/bin/crystal --replace \
|
|
|
|
"/usr/bin/env bash" "${stdenv.shell}"
|
|
|
|
|
2016-12-21 09:21:31 +01:00
|
|
|
${fixPrebuiltBinary}
|
|
|
|
|
|
|
|
cd crystal-${version}
|
|
|
|
make release=1 PATH="../crystal-${version}-1/bin:$PATH"
|
|
|
|
make doc
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm755 .build/crystal $out/bin/crystal
|
|
|
|
wrapProgram $out/bin/crystal \
|
|
|
|
--suffix CRYSTAL_PATH : $out/lib/crystal \
|
|
|
|
--suffix LIBRARY_PATH : $libPath
|
|
|
|
|
|
|
|
install -dm755 $out/lib/crystal
|
|
|
|
cp -r src/* $out/lib/crystal/
|
|
|
|
|
|
|
|
install -dm755 $out/share/doc/crystal/api
|
|
|
|
cp -r doc/* $out/share/doc/crystal/api/
|
|
|
|
cp -r samples $out/share/doc/crystal/
|
|
|
|
|
|
|
|
install -Dm644 etc/completion.bash $out/share/bash-completion/completions/crystal
|
|
|
|
install -Dm644 etc/completion.zsh $out/share/zsh/site-functions/_crystal
|
|
|
|
|
2017-06-30 00:24:36 +02:00
|
|
|
install -Dm644 man/crystal.1 $out/share/man/man1/crystal.1
|
|
|
|
|
2016-12-21 09:21:31 +01:00
|
|
|
install -Dm644 LICENSE $out/share/licenses/crystal/LICENSE
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "A compiled language with Ruby like syntax and type inference";
|
2017-08-01 22:03:30 +02:00
|
|
|
homepage = https://crystal-lang.org/;
|
2016-12-21 09:21:31 +01:00
|
|
|
license = stdenv.lib.licenses.asl20;
|
2017-10-03 14:07:12 +02:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ sifmelcara ];
|
2016-12-21 09:21:31 +01:00
|
|
|
platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|