Advertisement
Guest User

nim.nix

a guest
May 12th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. # based on https://github.com/nim-lang/Nim/blob/v0.18.0/.travis.yml
  2. # install with: nix-build --keep-failed --expr 'with import <nixpkgs> {}; callPackage ./nim.nix {}'
  3.  
  4. { stdenv, lib, fetchurl, makeWrapper, nodejs-slim-8_x, openssl, pcre, readline, sqlite, boehmgc, sfml, tzdata, coreutils, ... }:
  5.  
  6. stdenv.mkDerivation rec {
  7. name = "nim-${version}";
  8. version = "0.19.6";
  9.  
  10. src = fetchurl {
  11. url = "https://nim-lang.org/download/${name}.tar.xz";
  12. sha256 = "45c74adb35f08dfa9add1112ae17330e5d902ebb4a36e7046caee8b79e6f3bd0";
  13. };
  14.  
  15. doCheck = !stdenv.isDarwin;
  16.  
  17. enableParallelBuilding = true;
  18.  
  19. NIX_LDFLAGS = [
  20. "-lcrypto"
  21. "-lpcre"
  22. "-lreadline"
  23. "-lsqlite3"
  24. "-lgc"
  25. ];
  26.  
  27. # 1. nodejs is only needed for tests
  28. # 2. we could create a separate derivation for the "written in c" version of nim
  29. # used for bootstrapping, but koch insists on moving the nim compiler around
  30. # as part of building it, so it cannot be read-only
  31.  
  32. buildInputs = [
  33. makeWrapper nodejs-slim-8_x tzdata coreutils
  34. openssl pcre readline sqlite boehmgc sfml
  35. ];
  36.  
  37. buildPhase = ''
  38. sh build.sh
  39. ./bin/nim c koch
  40. ./koch boot -d:release \
  41. -d:useGnuReadline \
  42. ${lib.optionals (stdenv.isDarwin || stdenv.isLinux) "-d:nativeStacktrace"}
  43. ./koch tools -d:release
  44. '';
  45.  
  46. installPhase = ''
  47. install -Dt $out/bin bin/* koch
  48. ./koch install $out
  49. mv $out/nim/bin/* $out/bin/ && rmdir $out/nim/bin
  50. mv $out/nim/* $out/ && rmdir $out/nim
  51. wrapProgram $out/bin/nim \
  52. --suffix PATH : ${lib.makeBinPath [ stdenv.cc ]}
  53. '';
  54.  
  55. # postPatch =
  56. # let disableTest = ''sed -i '1i discard \"\"\"\n disabled: true\n\"\"\"\n\n' '';
  57. # disableCompile = ''sed -i -e 's/^/#/' '';
  58. # in ''
  59. # substituteInPlace ./tests/async/tioselectors.nim --replace "/bin/sleep" "sleep"
  60. # substituteInPlace ./tests/osproc/tworkingdir.nim --replace "/usr/bin" "${coreutils}/bin"
  61. # substituteInPlace ./tests/stdlib/ttimes.nim --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
  62. # # disable supposedly broken tests
  63. # ${disableTest} ./tests/errmsgs/tproper_stacktrace2.nim
  64. # ${disableTest} ./tests/vm/trgba.nim
  65. # # disable tests requiring network access (not available in the build container)
  66. # ${disableTest} ./tests/stdlib/thttpclient.nim
  67. # ${disableTest} ./tests/cpp/tasync_cpp.nim
  68. # ${disableTest} ./tests/niminaction/Chapter7/Tweeter/src/tweeter.nim
  69. # # disable tests requiring un-downloadable dependencies (using nimble, which isn't available in the fetch phase)
  70. # ${disableCompile} ./tests/manyloc/keineschweine/keineschweine.nim
  71. # ${disableTest} ./tests/manyloc/keineschweine/keineschweine.nim
  72. # ${disableCompile} ./tests/manyloc/nake/nakefile.nim
  73. # ${disableTest} ./tests/manyloc/nake/nakefile.nim
  74. # ${disableCompile} ./tests/manyloc/named_argument_bug/main.nim
  75. # ${disableTest} ./tests/manyloc/named_argument_bug/main.nim
  76. # '';
  77.  
  78. # checkPhase = ''
  79. # ./koch tests
  80. # '';
  81.  
  82. meta = with stdenv.lib; {
  83. description = "Statically typed, imperative programming language";
  84. homepage = https://nim-lang.org/;
  85. license = licenses.mit;
  86. maintainers = with maintainers; [ ehmry peterhoeg ];
  87. platforms = with platforms; linux ++ darwin; # arbitrary
  88. };
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement