2018-05-20 15:33:22 +02:00
|
|
|
# based on https://github.com/nim-lang/Nim/blob/v0.18.0/.travis.yml
|
|
|
|
|
2018-10-27 14:30:21 +02:00
|
|
|
{ stdenv, lib, fetchurl, makeWrapper, nodejs-slim-8_x, openssl, pcre, readline, boehmgc, sfml, tzdata, coreutils }:
|
2015-02-10 15:48:41 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2016-12-30 08:27:28 +01:00
|
|
|
name = "nim-${version}";
|
2018-10-27 14:30:21 +02:00
|
|
|
version = "0.19.0";
|
2015-02-10 15:48:41 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2018-01-05 20:42:46 +01:00
|
|
|
url = "https://nim-lang.org/download/${name}.tar.xz";
|
2018-10-27 14:30:21 +02:00
|
|
|
sha256 = "0biwvw1gividp5lkf0daq1wp9v6ms4xy6dkf5zj0sn9w4m3n76d1";
|
2015-02-10 15:48:41 +01:00
|
|
|
};
|
|
|
|
|
2018-06-23 23:25:09 +02:00
|
|
|
doCheck = !stdenv.isDarwin;
|
2017-01-12 11:08:48 +01:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
NIX_LDFLAGS = [
|
|
|
|
"-lcrypto"
|
|
|
|
"-lpcre"
|
|
|
|
"-lreadline"
|
2018-05-20 15:33:22 +02:00
|
|
|
"-lgc"
|
2017-01-12 11:08:48 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
# 1. nodejs is only needed for tests
|
|
|
|
# 2. we could create a separate derivation for the "written in c" version of nim
|
|
|
|
# used for bootstrapping, but koch insists on moving the nim compiler around
|
|
|
|
# as part of building it, so it cannot be read-only
|
|
|
|
|
2018-05-20 15:33:22 +02:00
|
|
|
buildInputs = [
|
|
|
|
makeWrapper nodejs-slim-8_x tzdata coreutils
|
2018-10-27 14:30:21 +02:00
|
|
|
openssl pcre readline boehmgc sfml
|
2017-01-12 11:08:48 +01:00
|
|
|
];
|
|
|
|
|
2018-10-27 14:30:21 +02:00
|
|
|
phases = [ "unpackPhase" "patchPhase" "buildPhase" "installPhase" "checkPhase" ];
|
|
|
|
|
2018-05-20 15:33:22 +02:00
|
|
|
buildPhase = ''
|
2018-10-27 14:30:21 +02:00
|
|
|
# use gcc to trigger the linker since calling ld in build.sh causes an error
|
|
|
|
LD=gcc
|
|
|
|
# build.sh wants to write to $HOME/.cache
|
|
|
|
HOME=$TMPDIR
|
2017-01-12 11:08:48 +01:00
|
|
|
sh build.sh
|
|
|
|
./bin/nim c koch
|
|
|
|
./koch boot -d:release \
|
|
|
|
-d:useGnuReadline \
|
|
|
|
${lib.optionals (stdenv.isDarwin || stdenv.isLinux) "-d:nativeStacktrace"}
|
|
|
|
./koch tools -d:release
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dt $out/bin bin/* koch
|
|
|
|
./koch install $out
|
|
|
|
mv $out/nim/bin/* $out/bin/ && rmdir $out/nim/bin
|
|
|
|
mv $out/nim/* $out/ && rmdir $out/nim
|
|
|
|
wrapProgram $out/bin/nim \
|
|
|
|
--suffix PATH : ${lib.makeBinPath [ stdenv.cc ]}
|
|
|
|
'';
|
|
|
|
|
2018-10-27 14:30:21 +02:00
|
|
|
patchPhase =
|
2018-05-20 15:33:22 +02:00
|
|
|
let disableTest = ''sed -i '1i discard \"\"\"\n disabled: true\n\"\"\"\n\n' '';
|
|
|
|
disableCompile = ''sed -i -e 's/^/#/' '';
|
|
|
|
in ''
|
|
|
|
substituteInPlace ./tests/async/tioselectors.nim --replace "/bin/sleep" "sleep"
|
|
|
|
substituteInPlace ./tests/osproc/tworkingdir.nim --replace "/usr/bin" "${coreutils}/bin"
|
|
|
|
substituteInPlace ./tests/stdlib/ttimes.nim --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
|
|
|
|
|
|
|
|
# disable tests requiring network access (not available in the build container)
|
|
|
|
${disableTest} ./tests/stdlib/thttpclient.nim
|
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = ''
|
2018-10-27 14:30:21 +02:00
|
|
|
PATH=$PATH:$out/bin
|
2018-05-20 15:33:22 +02:00
|
|
|
./koch tests
|
|
|
|
'';
|
2017-01-12 11:08:48 +01:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Statically typed, imperative programming language";
|
2018-01-05 20:42:46 +01:00
|
|
|
homepage = https://nim-lang.org/;
|
2017-01-12 11:08:48 +01:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ ehmry peterhoeg ];
|
|
|
|
platforms = with platforms; linux ++ darwin; # arbitrary
|
|
|
|
};
|
2015-02-10 15:48:41 +01:00
|
|
|
}
|