2018-06-17 12:03:32 +01:00
|
|
|
{ stdenv, fetchurl, makeWrapper
|
|
|
|
, boehmgc, libatomic_ops, pcre, libevent, libiconv, llvm, clang }:
|
2016-12-21 08:21:31 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2017-10-03 19:29:47 +01:00
|
|
|
name = "crystal-${version}";
|
2018-07-31 15:54:37 +01:00
|
|
|
version = "0.25.1";
|
2016-12-21 08:21:31 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/crystal-lang/crystal/archive/${version}.tar.gz";
|
2018-07-31 15:54:37 +01:00
|
|
|
sha256 = "1ikzly6vs28ilqvqm4kxzhqs8mp6l4l344rhak63dav7vv97nnlv";
|
2016-12-21 08:21:31 +00:00
|
|
|
};
|
|
|
|
|
2018-07-31 15:54:37 +01:00
|
|
|
prebuiltName = "crystal-0.25.1-1";
|
2017-10-03 19:29:47 +01:00
|
|
|
prebuiltSrc = let 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");
|
|
|
|
in fetchurl {
|
2018-07-31 15:54:37 +01:00
|
|
|
url = "https://github.com/crystal-lang/crystal/releases/download/0.25.1/${prebuiltName}-${arch}.tar.gz";
|
2017-10-03 19:29:47 +01:00
|
|
|
sha256 = {
|
2018-07-31 15:54:37 +01:00
|
|
|
"x86_64-linux" = "0zjmbvbhi11p7s99jmvb3pac6zzsr792bxcfanrx503fjxxafgll";
|
|
|
|
"i686-linux" = "0i0hgsq7xa53594blqw5qi6jrqja18spifmalg7df2mj3h13h3pz";
|
|
|
|
"x86_64-darwin" = "1h369hzis1cigxbb6fgpahyq4d13gfgjc6adf300zc38yh8rvyy0";
|
2017-10-03 19:29:47 +01:00
|
|
|
}."${stdenv.system}";
|
|
|
|
};
|
|
|
|
|
2017-12-24 03:29:51 +00:00
|
|
|
unpackPhase = ''
|
|
|
|
mkdir ${prebuiltName}
|
|
|
|
tar --strip-components=1 -C ${prebuiltName} -xf ${prebuiltSrc}
|
|
|
|
tar xf ${src}
|
|
|
|
'';
|
2017-10-03 19:29:47 +01:00
|
|
|
|
2016-12-21 08:21:31 +00:00
|
|
|
# crystal on Darwin needs libiconv to build
|
2017-10-03 19:29:47 +01:00
|
|
|
libs = [
|
|
|
|
boehmgc libatomic_ops pcre libevent
|
2016-12-21 08:21:31 +00:00
|
|
|
] ++ stdenv.lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
|
|
|
];
|
|
|
|
|
2017-10-03 19:29:47 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2016-12-21 08:21:31 +00:00
|
|
|
|
2017-10-03 19:29:47 +01:00
|
|
|
buildInputs = libs ++ [ llvm ];
|
2016-12-21 08:21:31 +00:00
|
|
|
|
2017-10-03 19:29:47 +01:00
|
|
|
libPath = stdenv.lib.makeLibraryPath libs;
|
|
|
|
|
|
|
|
sourceRoot = "${name}";
|
2016-12-21 08:21:31 +00:00
|
|
|
|
2017-10-03 19:29:47 +01:00
|
|
|
preBuild = ''
|
|
|
|
patchShebangs bin/crystal
|
|
|
|
patchShebangs ../${prebuiltName}/bin/crystal
|
|
|
|
export PATH="$(pwd)/../${prebuiltName}/bin:$PATH"
|
2016-12-21 08:21:31 +00:00
|
|
|
'';
|
|
|
|
|
2017-12-24 03:29:51 +00:00
|
|
|
makeFlags = [ "CRYSTAL_CONFIG_VERSION=${version}"
|
|
|
|
"FLAGS=--no-debug"
|
|
|
|
"release=1"
|
|
|
|
"all" "docs"
|
|
|
|
];
|
2017-10-03 19:29:47 +01:00
|
|
|
|
2016-12-21 08:21:31 +00:00
|
|
|
installPhase = ''
|
|
|
|
install -Dm755 .build/crystal $out/bin/crystal
|
|
|
|
wrapProgram $out/bin/crystal \
|
2018-06-17 12:03:32 +01:00
|
|
|
--suffix PATH : ${clang}/bin \
|
2017-11-22 07:21:39 +00:00
|
|
|
--suffix CRYSTAL_PATH : lib:$out/lib/crystal \
|
2016-12-21 08:21:31 +00:00
|
|
|
--suffix LIBRARY_PATH : $libPath
|
|
|
|
install -dm755 $out/lib/crystal
|
|
|
|
cp -r src/* $out/lib/crystal/
|
|
|
|
|
|
|
|
install -dm755 $out/share/doc/crystal/api
|
2017-12-24 03:29:51 +00:00
|
|
|
cp -r docs/* $out/share/doc/crystal/api/
|
2016-12-21 08:21:31 +00:00
|
|
|
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-29 23:24:36 +01:00
|
|
|
install -Dm644 man/crystal.1 $out/share/man/man1/crystal.1
|
|
|
|
|
2016-12-21 08:21:31 +00:00
|
|
|
install -Dm644 LICENSE $out/share/licenses/crystal/LICENSE
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
2018-06-17 12:03:32 +01:00
|
|
|
enableParallelBuilding = false;
|
2017-10-03 19:29:47 +01:00
|
|
|
|
2016-12-21 08:21:31 +00:00
|
|
|
meta = {
|
|
|
|
description = "A compiled language with Ruby like syntax and type inference";
|
2017-08-01 21:03:30 +01:00
|
|
|
homepage = https://crystal-lang.org/;
|
2016-12-21 08:21:31 +00:00
|
|
|
license = stdenv.lib.licenses.asl20;
|
2017-09-30 19:44:39 +01:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ sifmelcara david50407 ];
|
2016-12-21 08:21:31 +00:00
|
|
|
platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
|
|
|
|
};
|
|
|
|
}
|