nixpkgs-suyu/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 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
};
enableParallelBuilding = true;
2019-10-30 12:34:47 +01: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 17:21:48 +02:00
# Fortify hardening appends -O2 to gcc flags which is unwanted for unoptimized nim builds.
wrapProgram $out/bin/nim \
2019-09-24 17:21:48 +02: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 14:27:01 +02:00
homepage = "https://nim-lang.org/";
license = licenses.mit;
2019-09-24 17:21:48 +02:00
maintainers = with maintainers; [ ehmry ];
platforms = with platforms; linux ++ darwin; # arbitrary
};
2015-02-10 15:48:41 +01:00
}