@@ -0,0 +1,61 @@
1+{ stdenv, fetchurl, pkgconfig, perl, python2, zip, libffi, readline, icu, zlib, nspr }:
2+
3+stdenv.mkDerivation rec {
4+ version = "38.2.1.rc0";
5+ name = "spidermonkey-${version}";
6+
7+ # the release notes point to some guys home directory, see
8+ # https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/38
9+ # probably it would be more ideal to pull a particular tag/revision
10+ # from the mercurial repo
11+ src = fetchurl {
12+ url = "https://people.mozilla.org/~sstangl/mozjs-${version}.tar.bz2";
13+ sha256 = "0p4bmbpgkfsj54xschcny0a118jdrdgg0q29rwxigg3lh5slr681";
14+ };
15+
16+ buildInputs = [ pkgconfig perl python2 zip libffi readline icu zlib nspr ];
17+
18+ postUnpack = "sourceRoot=\${sourceRoot}/js/src";
19+
20+ preConfigure = ''
21+ export CXXFLAGS="-fpermissive"
22+ export LIBXUL_DIST=$out
23+ export PYTHON="${python2.interpreter}"
24+ '';
25+
26+ configureFlags = [
27+ "--enable-threadsafe"
28+ "--with-system-ffi"
29+ "--with-system-nspr"
30+ "--with-system-zlib"
31+ "--with-system-icu"
32+ "--enable-readline"
33+
34+ # enabling these because they're wanted by 0ad. They may or may
35+ # not be good defaults for other uses.
36+ "--enable-gcgenerational"
37+ "--enable-shared-js"
38+ ];
39+
40+ # This addresses some build system bug. It's quite likely to be safe
41+ # to re-enable parallel builds if the source revision changes.
42+ enableParallelBuilding = true;
43+
44+ postFixup = ''
45+ # The headers are symlinks to a directory that doesn't get put
46+ # into $out, so they end up broken. Fix that by just resolving the
47+ # symlinks.
48+ for i in $(find $out -type l); do
49+ cp --remove-destination "$(readlink "$i")" "$i";
50+ done
51+ '';
52+
53+ meta = with stdenv.lib; {
54+ description = "Mozilla's JavaScript engine written in C/C++";
55+ homepage = https://developer.mozilla.org/en/SpiderMonkey;
56+ # TODO: MPL/GPL/LGPL tri-license.
57+
58+ maintainers = [ maintainers.abbradar ];
59+ platforms = platforms.linux;
60+ };
61+}