2018-05-20 14:33:22 +01:00
|
|
|
# based on https://github.com/nim-lang/Nim/blob/v0.18.0/.travis.yml
|
|
|
|
|
2019-11-02 14:09:50 +00:00
|
|
|
{ stdenv, lib, fetchurl, makeWrapper, openssl, pcre, readline,
|
|
|
|
boehmgc, sfml, sqlite }:
|
2015-02-10 14:48:41 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-07-26 13:27:01 +01:00
|
|
|
pname = "nim";
|
2020-08-06 15:48:16 +01:00
|
|
|
version = "1.2.6";
|
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";
|
2020-08-06 15:48:16 +01:00
|
|
|
sha256 = "0zk5qzxayqjw7kq6p92j4008g9bbyilyymhdc5xq9sln5rqym26z";
|
2015-02-10 14:48:41 +00:00
|
|
|
};
|
|
|
|
|
2017-01-12 10:08:48 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2019-10-30 11:34:47 +00:00
|
|
|
NIX_LDFLAGS = "-lcrypto -lpcre -lreadline -lgc -lsqlite3";
|
2017-01-12 10:08:48 +00:00
|
|
|
|
2019-11-02 14:09:50 +00: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 21:42:17 +01:00
|
|
|
|
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
|
|
|
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 16:21:48 +01:00
|
|
|
|
|
|
|
# Fortify hardening appends -O2 to gcc flags which is unwanted for unoptimized nim builds.
|
2019-06-22 21:42:17 +01:00
|
|
|
wrapProgram $out/bin/nim \
|
2019-09-24 16:21:48 +01:00
|
|
|
--run 'NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/}' \
|
2019-06-22 21:42:17 +01:00
|
|
|
--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;
|
2019-09-24 16:21:48 +01:00
|
|
|
maintainers = with maintainers; [ ehmry ];
|
2017-01-12 10:08:48 +00:00
|
|
|
platforms = with platforms; linux ++ darwin; # arbitrary
|
|
|
|
};
|
2015-02-10 14:48:41 +00:00
|
|
|
}
|