2018-05-20 15:33:22 +02:00
|
|
|
# based on https://github.com/nim-lang/Nim/blob/v0.18.0/.travis.yml
|
|
|
|
|
2019-11-02 15:09:50 +01:00
|
|
|
{ stdenv, lib, fetchurl, makeWrapper, openssl, pcre, readline,
|
|
|
|
boehmgc, sfml, sqlite }:
|
2015-02-10 15:48:41 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-07-26 14:27:01 +02:00
|
|
|
pname = "nim";
|
2020-04-03 20:28:59 +02:00
|
|
|
version = "1.2.0";
|
2015-02-10 15:48:41 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-07-26 14:27:01 +02:00
|
|
|
url = "https://nim-lang.org/download/${pname}-${version}.tar.xz";
|
2020-04-03 20:28:59 +02:00
|
|
|
sha256 = "TpRYOjc5ZYIYBeZl4KBfUvthCRZnbtsJFIlBQVY3xXU=";
|
2015-02-10 15:48:41 +01:00
|
|
|
};
|
|
|
|
|
2017-01-12 11:08:48 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2019-10-30 12:34:47 +01:00
|
|
|
NIX_LDFLAGS = "-lcrypto -lpcre -lreadline -lgc -lsqlite3";
|
2017-01-12 11:08:48 +01:00
|
|
|
|
2019-11-02 15:09:50 +01:00
|
|
|
# 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 22:42:17 +02:00
|
|
|
|
2018-10-31 10:37:38 +01:00
|
|
|
nativeBuildInputs = [
|
2019-06-22 22:42:17 +02:00
|
|
|
makeWrapper
|
2018-10-31 10:37:38 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2019-06-22 22:42:17 +02:00
|
|
|
openssl pcre readline boehmgc sfml sqlite
|
2017-01-12 11:08:48 +01:00
|
|
|
];
|
|
|
|
|
2018-05-20 15:33:22 +02:00
|
|
|
buildPhase = ''
|
2019-06-22 22:42:17 +02:00
|
|
|
runHook preBuild
|
|
|
|
|
2018-10-27 14:30:21 +02:00
|
|
|
# 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
|
|
|
|
|
2019-06-22 22:42:17 +02:00
|
|
|
runHook postBuild
|
2017-01-12 11:08:48 +01:00
|
|
|
'';
|
|
|
|
|
2019-06-22 22:42:17 +02:00
|
|
|
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
|
2019-09-24 17:21:48 +02:00
|
|
|
|
|
|
|
# Fortify hardening appends -O2 to gcc flags which is unwanted for unoptimized nim builds.
|
2019-06-22 22:42:17 +02:00
|
|
|
wrapProgram $out/bin/nim \
|
2019-09-24 17:21:48 +02:00
|
|
|
--run 'NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/}' \
|
2019-06-22 22:42:17 +02:00
|
|
|
--suffix PATH : ${lib.makeBinPath [ stdenv.cc ]}
|
|
|
|
|
|
|
|
runHook postInstall
|
2018-05-20 15:33:22 +02:00
|
|
|
'';
|
2017-01-12 11:08:48 +01:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Statically typed, imperative programming language";
|
2019-07-26 14:27:01 +02:00
|
|
|
homepage = "https://nim-lang.org/";
|
2017-01-12 11:08:48 +01:00
|
|
|
license = licenses.mit;
|
2019-09-24 17:21:48 +02:00
|
|
|
maintainers = with maintainers; [ ehmry ];
|
2017-01-12 11:08:48 +01:00
|
|
|
platforms = with platforms; linux ++ darwin; # arbitrary
|
|
|
|
};
|
2015-02-10 15:48:41 +01:00
|
|
|
}
|