3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/compilers/nim/default.nix

70 lines
1.9 KiB
Nix
Raw Normal View History

# based on https://github.com/nim-lang/Nim/blob/v0.18.0/.travis.yml
{ 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";
2019-11-28 09:39:04 +00:00
version = "1.0.4";
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";
2019-11-28 09:39:04 +00:00
sha256 = "1q5fx9g40bk4ajghi856w5l34fmrl7avq5j6p0dr2xa4l52ib149";
2015-02-10 14:48:41 +00:00
};
enableParallelBuilding = true;
2019-10-30 11:34:47 +00:00
NIX_LDFLAGS = "-lcrypto -lpcre -lreadline -lgc -lsqlite3";
# 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
nativeBuildInputs = [
makeWrapper
];
buildInputs = [
openssl pcre readline boehmgc sfml sqlite
];
buildPhase = ''
runHook preBuild
# build.sh wants to write to $HOME/.cache
HOME=$TMPDIR
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
runHook postBuild
'';
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.
wrapProgram $out/bin/nim \
2019-09-24 16:21:48 +01:00
--run 'NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/}' \
--suffix PATH : ${lib.makeBinPath [ stdenv.cc ]}
runHook postInstall
'';
meta = with stdenv.lib; {
description = "Statically typed, imperative programming language";
2019-07-26 13:27:01 +01:00
homepage = "https://nim-lang.org/";
license = licenses.mit;
2019-09-24 16:21:48 +01:00
maintainers = with maintainers; [ ehmry ];
platforms = with platforms; linux ++ darwin; # arbitrary
};
2015-02-10 14:48:41 +00:00
}