summary refs log tree commit diff
path: root/pkgs/development/compilers
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2017-01-13 17:49:25 +0000
committerGitHub <noreply@github.com>2017-01-13 17:49:25 +0000
commit94b0ad124e7084de3e5bd8450f52558519ab06ee (patch)
treebac5958ce1353c6a4ee129ae476587c553134e9b /pkgs/development/compilers
parentf30a854844b24b9c2ece4fa9cca6956c6a14e1cd (diff)
parent4e0a5e7602bd437e5c6be3f2405f49bfb3ff4f5a (diff)
downloadnixlib-94b0ad124e7084de3e5bd8450f52558519ab06ee.tar
nixlib-94b0ad124e7084de3e5bd8450f52558519ab06ee.tar.gz
nixlib-94b0ad124e7084de3e5bd8450f52558519ab06ee.tar.bz2
nixlib-94b0ad124e7084de3e5bd8450f52558519ab06ee.tar.lz
nixlib-94b0ad124e7084de3e5bd8450f52558519ab06ee.tar.xz
nixlib-94b0ad124e7084de3e5bd8450f52558519ab06ee.tar.zst
nixlib-94b0ad124e7084de3e5bd8450f52558519ab06ee.zip
Merge pull request #21846 from peterhoeg/f/nim
nim: include all supporting tools
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r--pkgs/development/compilers/nim/default.nix70
1 files changed, 49 insertions, 21 deletions
diff --git a/pkgs/development/compilers/nim/default.nix b/pkgs/development/compilers/nim/default.nix
index eed702f85128..0cebd40afdba 100644
--- a/pkgs/development/compilers/nim/default.nix
+++ b/pkgs/development/compilers/nim/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, makeWrapper, gcc }:
+{ stdenv, lib, fetchurl, makeWrapper, nodejs, openssl, pcre, readline, sqlite }:
 
 stdenv.mkDerivation rec {
   name = "nim-${version}";
@@ -9,24 +9,52 @@ stdenv.mkDerivation rec {
     sha256 = "0rsibhkc5n548bn9yyb9ycrdgaph5kq84sfxc9gabjs7pqirh6cy";
   };
 
-  buildInputs  = [ makeWrapper ];
-
-  buildPhase   = "sh build.sh";
-
-  installPhase =
-    ''
-      install -Dt "$out/bin" bin/nim
-      substituteInPlace install.sh --replace '$1/nim' "$out"
-      sh install.sh $out
-      wrapProgram $out/bin/nim \
-        --suffix PATH : ${lib.makeBinPath [ gcc ]}
-    '';
-
-  meta = with stdenv.lib;
-    { description = "Statically typed, imperative programming language";
-      homepage = http://nim-lang.org/;
-      license = licenses.mit;
-      maintainers = with maintainers; [ ehmry peterhoeg ];
-      platforms = platforms.linux ++ platforms.darwin; # arbitrary
-    };
+  doCheck = true;
+
+  enableParallelBuilding = true;
+
+  NIX_LDFLAGS = [
+    "-lcrypto"
+    "-lpcre"
+    "-lreadline"
+    "-lsqlite3"
+  ];
+
+  # 1. nodejs is only needed for tests
+  # 2. 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
+
+  buildInputs  = [
+    makeWrapper nodejs
+    openssl pcre readline sqlite
+  ];
+
+  buildPhase   = ''
+    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
+  '';
+
+  installPhase = ''
+    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
+    wrapProgram $out/bin/nim \
+      --suffix PATH : ${lib.makeBinPath [ stdenv.cc ]}
+  '';
+
+  checkPhase = "./koch tests";
+
+  meta = with stdenv.lib; {
+    description = "Statically typed, imperative programming language";
+    homepage = http://nim-lang.org/;
+    license = licenses.mit;
+    maintainers = with maintainers; [ ehmry peterhoeg ];
+    platforms = with platforms; linux ++ darwin; # arbitrary
+  };
 }