1 { lib, stdenv, fetchFromGitHub, fetchurl, makeWrapper, pcre2, coreutils, which, openssl, libxml2, cmake, z3, substituteAll,
2 cc ? stdenv.cc, lto ? !stdenv.isDarwin }:
4 stdenv.mkDerivation (rec {
8 src = fetchFromGitHub {
12 sha256 = "14kivmyphi7gbd7mgd4cnsiwl4cl7wih8kwzh7n79s2s4c5hj4ak";
14 # Due to a bug in LLVM 9.x, ponyc has to include its own vendored patched
15 # LLVM. (The submodule is a specific tag in the LLVM source tree).
17 # The pony developers are currently working to get off 9.x as quickly
18 # as possible so hopefully in a few revisions this package build will
19 # become a lot simpler.
21 # https://reviews.llvm.org/rG9f4f237e29e7150dfcf04ae78fa287d2dc8d48e2
23 fetchSubmodules = true;
26 ponygbenchmark = fetchurl {
27 url = "https://github.com/google/benchmark/archive/v1.5.0.tar.gz";
28 sha256 = "06i2cr4rj126m1zfz0x1rbxv1mw1l7a11mzal5kqk56cdrdicsiw";
29 name = "v1.5.0.tar.gz";
32 nativeBuildInputs = [ cmake makeWrapper which ];
33 buildInputs = [ libxml2 z3 ];
34 propagatedBuildInputs = [ cc ];
36 # Sandbox disallows network access, so disabling problematic networking tests
40 src = ./make-safe-for-sandbox.patch;
41 googletest = fetchurl {
42 url = "https://github.com/google/googletest/archive/release-1.8.1.tar.gz";
43 sha256 = "17147961i01fl099ygxjx4asvjanwdd446nwbq9v8156h98zxwcv";
44 name = "release-1.8.1.tar.gz";
50 mkdir -p source/build/build_libs/gbenchmark-prefix/src
51 tar -C source/build/build_libs/gbenchmark-prefix/src -zxvf "$ponygbenchmark"
52 mv source/build/build_libs/gbenchmark-prefix/src/benchmark-1.5.0 \
53 source/build/build_libs/gbenchmark-prefix/src/benchmark
59 # Patching Vendor LLVM
60 patchShebangs --host build/build_libs/gbenchmark-prefix/src/benchmark/tools/*.py
61 patch -d lib/llvm/src/ -p1 < lib/llvm/patches/2020-09-01-is-trivially-copyable.diff
62 patch -d lib/llvm/src/ -p1 < lib/llvm/patches/2020-01-07-01-c-exports.diff
63 patch -d lib/llvm/src/ -p1 < lib/llvm/patches/2019-12-23-01-jit-eh-frames.diff
65 substituteInPlace packages/process/_test.pony \
66 --replace '"/bin/' '"${coreutils}/bin/' \
67 --replace '=/bin' "${coreutils}/bin"
68 substituteInPlace src/libponyc/pkg/package.c \
69 --replace "/usr/local/lib" "" \
70 --replace "/opt/local/lib" ""
75 make libs build_flags=-j$NIX_BUILD_CORES
76 make configure build_flags=-j$NIX_BUILD_CORES
80 "PONYC_VERSION=${version}"
81 "prefix=${placeholder "out"}"
83 ++ lib.optionals stdenv.isDarwin [ "bits=64" ]
84 ++ lib.optionals (stdenv.isDarwin && (!lto)) [ "lto=no" ];
88 NIX_CFLAGS_COMPILE = [ "-Wno-error=redundant-move" "-Wno-error=implicit-fallthrough" ];
90 installPhase = "make config=release prefix=$out "
91 + lib.optionalString stdenv.isDarwin "bits=64 "
92 + lib.optionalString (stdenv.isDarwin && (!lto)) "lto=no "
95 wrapProgram $out/bin/ponyc \
96 --prefix PATH ":" "${stdenv.cc}/bin" \
97 --set-default CC "$CC" \
98 --prefix PONYPATH : "${lib.makeLibraryPath [ pcre2 openssl (placeholder "out") ]}"
101 # Stripping breaks linking for ponyc
105 description = "Pony is an Object-oriented, actor-model, capabilities-secure, high performance programming language";
106 homepage = "https://www.ponylang.org";
107 license = licenses.bsd2;
108 maintainers = with maintainers; [ kamilchm patternspandemic redvers ];
109 platforms = [ "x86_64-linux" "x86_64-darwin" ];