about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/julia
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:36 +0000
committerAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:47 +0000
commit36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch)
treeb3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/compilers/julia
parent4e31070265257dc67d120c27e0f75c2344fdfa9a (diff)
parentabf060725d7614bd3b9f96764262dfbc2f9c2199 (diff)
downloadnixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs
git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a
git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/julia')
-rw-r--r--nixpkgs/pkgs/development/compilers/julia/0.7.nix6
-rw-r--r--nixpkgs/pkgs/development/compilers/julia/0001.1-use-system-utf8proc.patch29
-rw-r--r--nixpkgs/pkgs/development/compilers/julia/0002-use-system-suitesparse.patch25
-rw-r--r--nixpkgs/pkgs/development/compilers/julia/0004-hardened.patch25
-rw-r--r--nixpkgs/pkgs/development/compilers/julia/1.0.nix6
-rw-r--r--nixpkgs/pkgs/development/compilers/julia/default.nix202
-rw-r--r--nixpkgs/pkgs/development/compilers/julia/shared.nix219
7 files changed, 512 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/compilers/julia/0.7.nix b/nixpkgs/pkgs/development/compilers/julia/0.7.nix
new file mode 100644
index 000000000000..99c6b245ba67
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/julia/0.7.nix
@@ -0,0 +1,6 @@
+import ./shared.nix {
+  majorVersion = "0";
+  minorVersion = "7";
+  maintenanceVersion = "0";
+  src_sha256 = "1j57569qm2ii8ddzsp08hds2navpk7acdz83kh27dvk44axhwj6f";
+}
diff --git a/nixpkgs/pkgs/development/compilers/julia/0001.1-use-system-utf8proc.patch b/nixpkgs/pkgs/development/compilers/julia/0001.1-use-system-utf8proc.patch
new file mode 100644
index 000000000000..be4391399f55
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/julia/0001.1-use-system-utf8proc.patch
@@ -0,0 +1,29 @@
+From 54a66b5728ec98f44a1768f064509be4fd3f2ef6 Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@gmail.com>
+Date: Sat, 10 Oct 2015 13:09:48 -0500
+Subject: [PATCH 1/3] use system utf8proc
+
+---
+ src/flisp/Makefile | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/flisp/Makefile b/src/flisp/Makefile
+index bec8624..5437b5c 100644
+--- a/src/flisp/Makefile
++++ b/src/flisp/Makefile
+@@ -24,9 +24,9 @@ DOBJS = $(SRCS:%.c=$(BUILDDIR)/%.dbg.obj)
+ LLTDIR := ../support
+ LLT_release := $(BUILDDIR)/$(LLTDIR)/libsupport.a
+ LLT_debug := $(BUILDDIR)/$(LLTDIR)/libsupport-debug.a
+-LIBFILES_release := $(LLT_release) $(LIBUV) $(LIBUTF8PROC)
+-LIBFILES_debug := $(LLT_debug) $(LIBUV) $(LIBUTF8PROC)
+-LIBS :=
++LIBFILES_release := $(LLT_release) $(LIBUV)
++LIBFILES_debug := $(LLT_debug) $(LIBUV)
++LIBS := $(LIBUTF8PROC)
+ ifneq ($(OS),WINNT)
+ LIBS += -lpthread
+ endif
+-- 
+2.5.2
+
diff --git a/nixpkgs/pkgs/development/compilers/julia/0002-use-system-suitesparse.patch b/nixpkgs/pkgs/development/compilers/julia/0002-use-system-suitesparse.patch
new file mode 100644
index 000000000000..17f49ad5ca9f
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/julia/0002-use-system-suitesparse.patch
@@ -0,0 +1,25 @@
+From e2b0ed6664fe4adfd0f9ce8fa14732d47b30ab5c Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@gmail.com>
+Date: Sat, 10 Oct 2015 16:18:53 -0500
+Subject: [PATCH 2/3] use system suitesparse
+
+---
+ base/sparse/cholmod.jl | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl
+index ec7e980..f834cc1 100644
+--- a/base/sparse/cholmod.jl
++++ b/base/sparse/cholmod.jl
+@@ -151,7 +151,7 @@ function __init__()
+ 
+         # Register gc tracked allocator if CHOLMOD is new enough
+         if current_version >= v"3.0.0"
+-            cnfg = cglobal((:SuiteSparse_config, :libsuitesparseconfig), Ptr{Void})
++            cnfg = cglobal((:SuiteSparse_config, :libsuitesparse), Ptr{Void})
+             unsafe_store!(cnfg, cglobal(:jl_malloc, Ptr{Void}), 1)
+             unsafe_store!(cnfg, cglobal(:jl_calloc, Ptr{Void}), 2)
+             unsafe_store!(cnfg, cglobal(:jl_realloc, Ptr{Void}), 3)
+-- 
+2.5.2
+
diff --git a/nixpkgs/pkgs/development/compilers/julia/0004-hardened.patch b/nixpkgs/pkgs/development/compilers/julia/0004-hardened.patch
new file mode 100644
index 000000000000..901f967c9d55
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/julia/0004-hardened.patch
@@ -0,0 +1,25 @@
+From eddb251a00ace6e63e32e7dcb9e1ec632cac14e0 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Wed, 1 Feb 2017 06:09:49 -0600
+Subject: [PATCH] Set pax flags on julia binaries to disable memory protection.
+
+---
+ Makefile | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 0e28cc87b..aab8cfa8d 100644
+--- a/Makefile
++++ b/Makefile
+@@ -91,6 +91,8 @@ julia-src-release julia-src-debug : julia-src-% : julia-deps julia_flisp.boot.in
+ 
+ julia-ui-release julia-ui-debug : julia-ui-% : julia-src-%
+ 	@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/ui julia-$*
++	@echo "setting PaX flags on $(JULIA_EXECUTABLE_$*)"
++	@paxctl -czexm $(JULIA_EXECUTABLE_$*)
+ 
+ julia-inference : julia-base julia-ui-$(JULIA_BUILD_MODE) $(build_prefix)/.examples
+ 	@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) $(build_private_libdir)/inference.ji JULIA_BUILD_MODE=$(JULIA_BUILD_MODE)
+-- 
+2.11.0
+
diff --git a/nixpkgs/pkgs/development/compilers/julia/1.0.nix b/nixpkgs/pkgs/development/compilers/julia/1.0.nix
new file mode 100644
index 000000000000..528a0d26d056
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/julia/1.0.nix
@@ -0,0 +1,6 @@
+import ./shared.nix {
+  majorVersion = "1";
+  minorVersion = "0";
+  maintenanceVersion = "1";
+  src_sha256 = "0bqb5c63c7jnb753nplqj5v4k9pvh792k8y4b1n5pq8jiibr86i0";
+}
diff --git a/nixpkgs/pkgs/development/compilers/julia/default.nix b/nixpkgs/pkgs/development/compilers/julia/default.nix
new file mode 100644
index 000000000000..086570f5ce20
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/julia/default.nix
@@ -0,0 +1,202 @@
+{ stdenv, fetchurl, fetchzip
+# build tools
+, gfortran, m4, makeWrapper, patchelf, perl, which, python2, paxctl
+# libjulia dependencies
+, libunwind, readline, utf8proc, zlib
+, llvm
+# standard library dependencies
+, curl, fftwSinglePrec, fftw, gmp, libgit2, mpfr, openlibm, openspecfun, pcre2
+# linear algebra
+, openblas, arpack, suitesparse
+# Darwin frameworks
+, CoreServices, ApplicationServices
+}:
+
+with stdenv.lib;
+
+# All dependencies must use the same OpenBLAS.
+let
+  arpack_ = arpack;
+  suitesparse_ = suitesparse;
+in
+let
+  arpack = arpack_.override { inherit openblas; };
+  suitesparse = suitesparse_.override { inherit openblas; };
+in
+
+let
+  dsfmtVersion = "2.2.3";
+  dsfmt = fetchurl {
+    url = "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/dSFMT-src-${dsfmtVersion}.tar.gz";
+    sha256 = "03kaqbjbi6viz0n33dk5jlf6ayxqlsq4804n7kwkndiga9s4hd42";
+  };
+
+  libuvVersion = "d8ab1c6a33e77bf155facb54215dd8798e13825d";
+  libuv = fetchurl {
+    url = "https://api.github.com/repos/JuliaLang/libuv/tarball/${libuvVersion}";
+    sha256 = "0q5ahc9dzca2yc6cjbhpfi9nwc4yhhjbgxgsychksn13d24gv7ba";
+  };
+
+  rmathVersion = "0.1";
+  rmath-julia = fetchurl {
+    url = "https://api.github.com/repos/JuliaLang/Rmath-julia/tarball/v${rmathVersion}";
+    sha256 = "1qyps217175qhid46l8f5i1v8i82slgp23ia63x2hzxwfmx8617p";
+  };
+
+  virtualenvVersion = "15.0.0";
+  virtualenv = fetchurl {
+    url = "mirror://pypi/v/virtualenv/virtualenv-${virtualenvVersion}.tar.gz";
+    sha256 = "06fw4liazpx5vf3am45q2pdiwrv0id7ckv7n6zmpml29x6vkzmkh";
+  };
+
+  majorVersion = "0";
+  minorVersion = "6";
+  maintenanceVersion = "4";
+  version = "${majorVersion}.${minorVersion}.${maintenanceVersion}";
+in
+
+stdenv.mkDerivation rec {
+  pname = "julia";
+  inherit version;
+  name = "${pname}-${version}";
+
+  src = fetchzip {
+    url = "https://github.com/JuliaLang/${pname}/releases/download/v${version}/${name}.tar.gz";
+    sha256 = "09axkkj914al7lzvcvhb33hz5wp083lk18llsvrn622fqhmyqabl";
+  };
+  prePatch = ''
+    mkdir deps/srccache
+    cp "${dsfmt}" "./deps/srccache/dsfmt-${dsfmtVersion}.tar.gz"
+    cp "${rmath-julia}" "./deps/srccache/Rmath-julia-${rmathVersion}.tar.gz"
+    cp "${libuv}" "./deps/srccache/libuv-${libuvVersion}.tar.gz"
+    cp "${virtualenv}" "./deps/srccache/virtualenv-${virtualenvVersion}.tar.gz"
+  '';
+
+  patches = [
+    ./0001.1-use-system-utf8proc.patch
+    ./0002-use-system-suitesparse.patch
+  ] ++ stdenv.lib.optional stdenv.needsPax ./0004-hardened.patch;
+
+  postPatch = ''
+    patchShebangs . contrib
+    for i in backtrace replutil cmdlineargs compile; do
+      mv test/$i.jl{,.off}
+      touch test/$i.jl
+    done
+
+    sed -e 's/Invalid Content-Type:/invalid Content-Type:/g' -i test/libgit2.jl
+    sed -e 's/Failed to resolve /failed to resolve /g' -i test/libgit2.jl
+  '';
+
+  buildInputs = [
+    arpack fftw fftwSinglePrec gmp libgit2 libunwind mpfr
+    pcre2.dev openblas openlibm openspecfun readline suitesparse utf8proc
+    zlib llvm
+  ]
+  ++ stdenv.lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
+  ;
+
+  nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which ]
+    ++ stdenv.lib.optional stdenv.needsPax paxctl;
+
+  makeFlags =
+    let
+      arch = head (splitString "-" stdenv.hostPlatform.system);
+      march = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}"
+              or (throw "unsupported architecture: ${arch}");
+      # Julia requires Pentium 4 (SSE2) or better
+      cpuTarget = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}"
+                  or (throw "unsupported architecture: ${arch}");
+    in [
+      "ARCH=${arch}"
+      "MARCH=${march}"
+      "JULIA_CPU_TARGET=${cpuTarget}"
+      "PREFIX=$(out)"
+      "prefix=$(out)"
+      "SHELL=${stdenv.shell}"
+
+      "USE_SYSTEM_BLAS=1"
+      "USE_BLAS64=${if openblas.blas64 then "1" else "0"}"
+      "LIBBLAS=-lopenblas"
+      "LIBBLASNAME=libopenblas"
+
+      "USE_SYSTEM_LAPACK=1"
+      "LIBLAPACK=-lopenblas"
+      "LIBLAPACKNAME=libopenblas"
+
+      "USE_SYSTEM_SUITESPARSE=1"
+      "SUITESPARSE_LIB=-lsuitesparse"
+      "SUITESPARSE_INC=-I${suitesparse}/include"
+
+      "USE_SYSTEM_ARPACK=1"
+      "USE_SYSTEM_FFTW=1"
+      "USE_SYSTEM_GMP=1"
+      "USE_SYSTEM_LIBGIT2=1"
+      "USE_SYSTEM_LIBUNWIND=1"
+
+      "USE_SYSTEM_LLVM=1"
+      "LLVM_VER=3.9.1"
+
+      "USE_SYSTEM_MPFR=1"
+      "USE_SYSTEM_OPENLIBM=1"
+      "USE_SYSTEM_OPENSPECFUN=1"
+      "USE_SYSTEM_PATCHELF=1"
+      "USE_SYSTEM_PCRE=1"
+      "PCRE_CONFIG=${pcre2.dev}/bin/pcre2-config"
+      "PCRE_INCL_PATH=${pcre2.dev}/include/pcre2.h"
+      "USE_SYSTEM_READLINE=1"
+      "USE_SYSTEM_UTF8PROC=1"
+      "USE_SYSTEM_ZLIB=1"
+    ];
+
+  NIX_CFLAGS_COMPILE = [ "-fPIC" ];
+
+  LD_LIBRARY_PATH = makeLibraryPath [
+    arpack fftw fftwSinglePrec gmp libgit2 mpfr openblas openlibm
+    openspecfun pcre2 suitesparse llvm
+  ];
+
+  dontStrip = true;
+  dontPatchELF = true;
+
+  enableParallelBuilding = true;
+
+  doCheck = !stdenv.isDarwin;
+  checkTarget = "testall";
+  # Julia's tests require read/write access to $HOME
+  preCheck = ''
+    export HOME="$NIX_BUILD_TOP"
+  '';
+
+  preBuild = ''
+    sed -e '/^install:/s@[^ ]*/doc/[^ ]*@@' -i Makefile
+    sed -e '/[$](DESTDIR)[$](docdir)/d' -i Makefile
+    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
+  '';
+
+  postInstall = ''
+    # Symlink shared libraries from LD_LIBRARY_PATH into lib/julia,
+    # as using a wrapper with LD_LIBRARY_PATH causes segmentation
+    # faults when program returns an error:
+    #   $ julia -e 'throw(Error())'
+    find $(echo $LD_LIBRARY_PATH | sed 's|:| |g') -maxdepth 1 -name '*.${if stdenv.isDarwin then "dylib" else "so"}*' | while read lib; do
+      if [[ ! -e $out/lib/julia/$(basename $lib) ]]; then
+        ln -sv $lib $out/lib/julia/$(basename $lib)
+      fi
+    done
+  '';
+
+  passthru = {
+    inherit majorVersion minorVersion maintenanceVersion;
+    site = "share/julia/site/v${majorVersion}.${minorVersion}";
+  };
+
+  meta = {
+    description = "High-level performance-oriented dynamical language for technical computing";
+    homepage = https://julialang.org/;
+    license = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ raskin ];
+    platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
+    broken = stdenv.isi686;
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/julia/shared.nix b/nixpkgs/pkgs/development/compilers/julia/shared.nix
new file mode 100644
index 000000000000..70ff40cd7ec5
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/julia/shared.nix
@@ -0,0 +1,219 @@
+{ majorVersion
+, minorVersion
+, maintenanceVersion
+, src_sha256
+}:
+{ stdenv, fetchurl, fetchzip
+# build tools
+, gfortran, m4, makeWrapper, patchelf, perl, which, python2, paxctl
+, llvm, cmake
+# libjulia dependencies
+, libunwind, readline, utf8proc, zlib
+# standard library dependencies
+, curl, fftwSinglePrec, fftw, gmp, libgit2, mpfr, openlibm, openspecfun, pcre2
+# linear algebra
+, openblas, arpack
+# Darwin frameworks
+, CoreServices, ApplicationServices
+}:
+
+with stdenv.lib;
+
+# All dependencies must use the same OpenBLAS.
+let
+  arpack_ = arpack;
+in
+let
+  arpack = arpack_.override { inherit openblas; };
+in
+
+let
+  dsfmtVersion = "2.2.3";
+  dsfmt = fetchurl {
+    url = "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/dSFMT-src-${dsfmtVersion}.tar.gz";
+    sha256 = "03kaqbjbi6viz0n33dk5jlf6ayxqlsq4804n7kwkndiga9s4hd42";
+  };
+
+  libuvVersion = "ed3700c849289ed01fe04273a7bf865340b2bd7e";
+  libuv = fetchurl {
+    url = "https://api.github.com/repos/JuliaLang/libuv/tarball/${libuvVersion}";
+    sha256 = "137w666zsjw1p0ma3lf94d75hr1q45sgkfmbizkyji2qm57cnxjs";
+  };
+
+  rmathVersion = "0.1";
+  rmath-julia = fetchurl {
+    url = "https://api.github.com/repos/JuliaLang/Rmath-julia/tarball/v${rmathVersion}";
+    sha256 = "1qyps217175qhid46l8f5i1v8i82slgp23ia63x2hzxwfmx8617p";
+  };
+
+  virtualenvVersion = "15.0.0";
+  virtualenv = fetchurl {
+    url = "mirror://pypi/v/virtualenv/virtualenv-${virtualenvVersion}.tar.gz";
+    sha256 = "06fw4liazpx5vf3am45q2pdiwrv0id7ckv7n6zmpml29x6vkzmkh";
+  };
+
+  libwhichVersion = "81e9723c0273d78493dc8c8ed570f68d9ce7e89e";
+  libwhich = fetchurl {
+    url = "https://api.github.com/repos/vtjnash/libwhich/tarball/${libwhichVersion}";
+    sha256 = "1p7zg31kpmpbmh1znrk1xrbd074agx13b9q4dcw8n2zrwwdlbz3b";
+  };
+
+  llvmVersion = "6.0.0";
+  llvm = fetchurl {
+    url = "http://releases.llvm.org/6.0.0/llvm-${llvmVersion}.src.tar.xz";
+    sha256 = "0224xvfg6h40y5lrbnb9qaq3grmdc5rg00xq03s1wxjfbf8krx8z";
+  };
+
+  suitesparseVersion = "4.4.5";
+  suitesparse = fetchurl {
+    url = "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${suitesparseVersion}.tar.gz";
+    sha256 = "1jcbxb8jx5wlcixzf6n5dca2rcfx6mlcms1k2rl5gp67ay3bix43";
+  };
+  version = "${majorVersion}.${minorVersion}.${maintenanceVersion}";
+in
+
+stdenv.mkDerivation rec {
+  pname = "julia";
+  inherit version;
+  name = "${pname}-${version}";
+
+  src = fetchzip {
+    url = "https://github.com/JuliaLang/${pname}/releases/download/v${version}/${name}.tar.gz";
+    sha256 = src_sha256;
+  };
+  prePatch = ''
+    export PATH=$PATH:${cmake}/bin
+    mkdir deps/srccache
+    cp "${dsfmt}" "./deps/srccache/dsfmt-${dsfmtVersion}.tar.gz"
+    cp "${rmath-julia}" "./deps/srccache/Rmath-julia-${rmathVersion}.tar.gz"
+    cp "${libuv}" "./deps/srccache/libuv-${libuvVersion}.tar.gz"
+    cp "${virtualenv}" "./deps/srccache/virtualenv-${virtualenvVersion}.tar.gz"
+    cp "${libwhich}" "./deps/srccache/libwhich-${libwhichVersion}.tar.gz"
+    cp "${llvm}" "./deps/srccache/llvm-${llvmVersion}.src.tar.xz"
+    cp "${suitesparse}" "./deps/srccache/SuiteSparse-${suitesparseVersion}.tar.gz"
+  '';
+
+  patches = [
+    ./0001.1-use-system-utf8proc.patch
+  ] ++ stdenv.lib.optional stdenv.needsPax ./0004-hardened.patch;
+
+  postPatch = ''
+    patchShebangs . contrib
+    for i in backtrace cmdlineargs; do
+      mv test/$i.jl{,.off}
+      touch test/$i.jl
+    done
+    rm stdlib/Sockets/test/runtests.jl && touch stdlib/Sockets/test/runtests.jl
+    rm stdlib/Distributed/test/runtests.jl && touch stdlib/Distributed/test/runtests.jl
+    sed -e 's/Invalid Content-Type:/invalid Content-Type:/g' -i ./stdlib/LibGit2/test/libgit2.jl
+    sed -e 's/Failed to resolve /failed to resolve /g' -i ./stdlib/LibGit2/test/libgit2.jl
+  '';
+
+  buildInputs = [
+    arpack fftw fftwSinglePrec gmp libgit2 libunwind mpfr
+    pcre2.dev openblas openlibm openspecfun readline utf8proc
+    zlib
+  ]
+  ++ stdenv.lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
+  ;
+
+  nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which ]
+    ++ stdenv.lib.optional stdenv.needsPax paxctl;
+
+  makeFlags =
+    let
+      arch = head (splitString "-" stdenv.system);
+      march = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}"
+              or (throw "unsupported architecture: ${arch}");
+      # Julia requires Pentium 4 (SSE2) or better
+      cpuTarget = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}"
+                  or (throw "unsupported architecture: ${arch}");
+    in [
+      "ARCH=${arch}"
+      "MARCH=${march}"
+      "JULIA_CPU_TARGET=${cpuTarget}"
+      "PREFIX=$(out)"
+      "prefix=$(out)"
+      "SHELL=${stdenv.shell}"
+
+      "USE_SYSTEM_BLAS=1"
+      "USE_BLAS64=${if openblas.blas64 then "1" else "0"}"
+      "LIBBLAS=-lopenblas"
+      "LIBBLASNAME=libopenblas"
+
+      "USE_SYSTEM_LAPACK=1"
+      "LIBLAPACK=-lopenblas"
+      "LIBLAPACKNAME=libopenblas"
+
+      "USE_SYSTEM_ARPACK=1"
+      "USE_SYSTEM_FFTW=1"
+      "USE_SYSTEM_GMP=1"
+      "USE_SYSTEM_LIBGIT2=1"
+      "USE_SYSTEM_LIBUNWIND=1"
+
+      #"USE_SYSTEM_LLVM=1"
+      "LLVM_VER=6.0.0"
+
+      "USE_SYSTEM_MPFR=1"
+      "USE_SYSTEM_OPENLIBM=1"
+      "USE_SYSTEM_OPENSPECFUN=1"
+      "USE_SYSTEM_PATCHELF=1"
+      "USE_SYSTEM_PCRE=1"
+      "PCRE_CONFIG=${pcre2.dev}/bin/pcre2-config"
+      "PCRE_INCL_PATH=${pcre2.dev}/include/pcre2.h"
+      "USE_SYSTEM_READLINE=1"
+      "USE_SYSTEM_UTF8PROC=1"
+      "USE_SYSTEM_ZLIB=1"
+    ];
+
+  NIX_CFLAGS_COMPILE = [ "-fPIC" ];
+
+  LD_LIBRARY_PATH = makeLibraryPath [
+    arpack fftw fftwSinglePrec gmp libgit2 mpfr openblas openlibm
+    openspecfun pcre2
+  ];
+
+  dontStrip = true;
+  dontPatchELF = true;
+
+  enableParallelBuilding = true;
+
+  doCheck = !stdenv.isDarwin;
+  checkTarget = "testall";
+  # Julia's tests require read/write access to $HOME
+  preCheck = ''
+    export HOME="$NIX_BUILD_TOP"
+  '';
+
+  preBuild = ''
+    sed -e '/^install:/s@[^ ]*/doc/[^ ]*@@' -i Makefile
+    sed -e '/[$](DESTDIR)[$](docdir)/d' -i Makefile
+    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
+  '';
+
+  postInstall = ''
+    # Symlink shared libraries from LD_LIBRARY_PATH into lib/julia,
+    # as using a wrapper with LD_LIBRARY_PATH causes segmentation
+    # faults when program returns an error:
+    #   $ julia -e 'throw(Error())'
+    find $(echo $LD_LIBRARY_PATH | sed 's|:| |g') -maxdepth 1 -name '*.${if stdenv.isDarwin then "dylib" else "so"}*' | while read lib; do
+      if [[ ! -e $out/lib/julia/$(basename $lib) ]]; then
+        ln -sv $lib $out/lib/julia/$(basename $lib)
+      fi
+    done
+  '';
+
+  passthru = {
+    inherit majorVersion minorVersion maintenanceVersion;
+    site = "share/julia/site/v${majorVersion}.${minorVersion}";
+  };
+
+  meta = {
+    description = "High-level performance-oriented dynamical language for technical computing";
+    homepage = https://julialang.org/;
+    license = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ raskin rob garrison ];
+    platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
+    broken = stdenv.isi686;
+  };
+}