1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
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";
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
};
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
}