2018-05-20 14:33:22 +01:00
|
|
|
# based on https://github.com/nim-lang/Nim/blob/v0.18.0/.travis.yml
|
|
|
|
|
2019-06-22 21:42:17 +01:00
|
|
|
{ stdenv, lib, fetchurl, makeWrapper, nodejs-slim-11_x, openssl, pcre, readline,
|
|
|
|
boehmgc, sfml, tzdata, coreutils, sqlite }:
|
2015-02-10 14:48:41 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-07-26 13:27:01 +01:00
|
|
|
pname = "nim";
|
|
|
|
version = "0.20.2";
|
2015-02-10 14:48:41 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-07-26 13:27:01 +01:00
|
|
|
url = "https://nim-lang.org/download/${pname}-${version}.tar.xz";
|
|
|
|
sha256 = "0pibil10x0c181kw705phlwk8bn8dy5ghqd9h9fm6i9afrz5ryp1";
|
2015-02-10 14:48:41 +00:00
|
|
|
};
|
|
|
|
|
2018-06-23 22:25:09 +01:00
|
|
|
doCheck = !stdenv.isDarwin;
|
2017-01-12 10:08:48 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
NIX_LDFLAGS = [
|
|
|
|
"-lcrypto"
|
|
|
|
"-lpcre"
|
|
|
|
"-lreadline"
|
2018-05-20 14:33:22 +01:00
|
|
|
"-lgc"
|
2019-06-22 21:42:17 +01:00
|
|
|
"-lsqlite3"
|
2017-01-12 10:08:48 +00: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
|
|
|
|
|
2019-06-22 21:42:17 +01:00
|
|
|
checkInputs = [
|
|
|
|
nodejs-slim-11_x tzdata coreutils
|
|
|
|
];
|
|
|
|
|
2018-10-31 09:37:38 +00:00
|
|
|
nativeBuildInputs = [
|
2019-06-22 21:42:17 +01:00
|
|
|
makeWrapper
|
2018-10-31 09:37:38 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2019-06-22 21:42:17 +01:00
|
|
|
openssl pcre readline boehmgc sfml sqlite
|
2017-01-12 10:08:48 +00:00
|
|
|
];
|
|
|
|
|
2018-05-20 14:33:22 +01:00
|
|
|
buildPhase = ''
|
2019-06-22 21:42:17 +01:00
|
|
|
runHook preBuild
|
|
|
|
|
2018-10-27 13:30:21 +01:00
|
|
|
# build.sh wants to write to $HOME/.cache
|
|
|
|
HOME=$TMPDIR
|
2017-01-12 10:08:48 +00: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
|
|
|
|
|
2019-06-22 21:42:17 +01:00
|
|
|
runHook postBuild
|
2017-01-12 10:08:48 +00:00
|
|
|
'';
|
|
|
|
|
2019-06-22 21:42:17 +01:00
|
|
|
prePatch =
|
2018-05-20 14:33:22 +01:00
|
|
|
let disableTest = ''sed -i '1i discard \"\"\"\n disabled: true\n\"\"\"\n\n' '';
|
2018-10-27 19:39:02 +01:00
|
|
|
disableStdLibTest = ''sed -i -e '/^when isMainModule/,/^END$/{s/^/#/}' '';
|
2019-06-22 21:42:17 +01:00
|
|
|
disableCompile = ''sed -i -e 's/^/#/' '';
|
2018-05-20 14:33:22 +01:00
|
|
|
in ''
|
|
|
|
substituteInPlace ./tests/osproc/tworkingdir.nim --replace "/usr/bin" "${coreutils}/bin"
|
|
|
|
substituteInPlace ./tests/stdlib/ttimes.nim --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
|
|
|
|
|
2019-06-22 21:42:17 +01:00
|
|
|
# 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)
|
2018-05-20 14:33:22 +01:00
|
|
|
${disableTest} ./tests/stdlib/thttpclient.nim
|
2018-10-27 19:39:02 +01:00
|
|
|
'' + lib.optionalString stdenv.isAarch64 ''
|
2019-06-22 21:42:17 +01:00
|
|
|
# supposedly broken on aarch64
|
2018-10-27 19:39:02 +01:00
|
|
|
${disableStdLibTest} ./lib/pure/stats.nim
|
2019-06-22 21:42:17 +01:00
|
|
|
|
|
|
|
# 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
|
2018-05-20 14:33:22 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = ''
|
2019-06-22 21:42:17 +01:00
|
|
|
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 ]}
|
|
|
|
|
|
|
|
runHook postInstall
|
2018-05-20 14:33:22 +01:00
|
|
|
'';
|
2017-01-12 10:08:48 +00:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Statically typed, imperative programming language";
|
2019-07-26 13:27:01 +01:00
|
|
|
homepage = "https://nim-lang.org/";
|
2017-01-12 10:08:48 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ ehmry peterhoeg ];
|
|
|
|
platforms = with platforms; linux ++ darwin; # arbitrary
|
|
|
|
};
|
2015-02-10 14:48:41 +00:00
|
|
|
}
|