nim: 0.19.4 -> 0.20.0

- link sqlite (needed for the the stdlib sqlite module)
- update nodejs to 11.x
- use default phase order (fixes linker errors during test phase)
- substitution in ./test/async/tioselectors.nim not needed anymore
- two more tests need to be disabled
- LD=$CC workaround not needed anymore
- disable unsupported tests on aarch64
- trigger pre and post hooks
- use checkInputs instead of nativeBuildInputs
- don't override patchPhase
This commit is contained in:
royneary 2019-06-22 22:42:17 +02:00
parent d162165350
commit b0b64b3927
No known key found for this signature in database
GPG Key ID: 8241BE099775A097

View File

@ -1,14 +1,15 @@
# based on https://github.com/nim-lang/Nim/blob/v0.18.0/.travis.yml
{ stdenv, lib, fetchurl, makeWrapper, nodejs-slim-10_x, openssl, pcre, readline, boehmgc, sfml, tzdata, coreutils }:
{ stdenv, lib, fetchurl, makeWrapper, nodejs-slim-11_x, openssl, pcre, readline,
boehmgc, sfml, tzdata, coreutils, sqlite }:
stdenv.mkDerivation rec {
name = "nim-${version}";
version = "0.19.4";
version = "0.20.0";
src = fetchurl {
url = "https://nim-lang.org/download/${name}.tar.xz";
sha256 = "0k59dhfsg5wnkc3nxg5a336pjd9jnfxabns63bl9n28iwdg16hgl";
sha256 = "144sd7icg2p6qsrr29jdnl11hr34daxq4h16ywwrayz866w7kx2i";
};
doCheck = !stdenv.isDarwin;
@ -20,6 +21,7 @@ stdenv.mkDerivation rec {
"-lpcre"
"-lreadline"
"-lgc"
"-lsqlite3"
];
# 1. nodejs is only needed for tests
@ -27,19 +29,21 @@ stdenv.mkDerivation rec {
# used for bootstrapping, but koch insists on moving the nim compiler around
# as part of building it, so it cannot be read-only
checkInputs = [
nodejs-slim-11_x tzdata coreutils
];
nativeBuildInputs = [
makeWrapper nodejs-slim-10_x tzdata coreutils
makeWrapper
];
buildInputs = [
openssl pcre readline boehmgc sfml
openssl pcre readline boehmgc sfml sqlite
];
phases = [ "unpackPhase" "patchPhase" "buildPhase" "installPhase" "checkPhase" ];
buildPhase = ''
# use $CC to trigger the linker since calling ld in build.sh causes an error
LD=$CC
runHook preBuild
# build.sh wants to write to $HOME/.cache
HOME=$TMPDIR
sh build.sh
@ -48,35 +52,55 @@ stdenv.mkDerivation rec {
-d:useGnuReadline \
${lib.optionals (stdenv.isDarwin || stdenv.isLinux) "-d:nativeStacktrace"}
./koch tools -d:release
runHook postBuild
'';
prePatch =
let disableTest = ''sed -i '1i discard \"\"\"\n disabled: true\n\"\"\"\n\n' '';
disableStdLibTest = ''sed -i -e '/^when isMainModule/,/^END$/{s/^/#/}' '';
disableCompile = ''sed -i -e 's/^/#/' '';
in ''
substituteInPlace ./tests/osproc/tworkingdir.nim --replace "/usr/bin" "${coreutils}/bin"
substituteInPlace ./tests/stdlib/ttimes.nim --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
# reported upstream: https://github.com/nim-lang/Nim/issues/11435
${disableTest} ./tests/misc/tstrace.nim
# runs out of memory on a machine with 8GB RAM
${disableTest} ./tests/system/t7894.nim
# requires network access (not available in the build container)
${disableTest} ./tests/stdlib/thttpclient.nim
'' + lib.optionalString stdenv.isAarch64 ''
# supposedly broken on aarch64
${disableStdLibTest} ./lib/pure/stats.nim
# reported upstream: https://github.com/nim-lang/Nim/issues/11463
${disableCompile} ./lib/nimhcr.nim
${disableTest} ./tests/dll/nimhcr_unit.nim
${disableTest} ./tests/dll/nimhcr_integration.nim
'';
checkPhase = ''
runHook preCheck
./koch tests --nim:bin/nim all
runHook postCheck
'';
installPhase = ''
runHook preInstall
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 ]}
'';
patchPhase =
let disableTest = ''sed -i '1i discard \"\"\"\n disabled: true\n\"\"\"\n\n' '';
disableStdLibTest = ''sed -i -e '/^when isMainModule/,/^END$/{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
'' + lib.optionalString stdenv.isAarch64 ''
# disable test supposedly broken on aarch64
${disableStdLibTest} ./lib/pure/stats.nim
'';
checkPhase = ''
PATH=$PATH:$out/bin
./koch tests
runHook postInstall
'';
meta = with stdenv.lib; {