1 { lib, stdenv, fetchurl, fetchzip, fetchFromGitHub
3 , gfortran, m4, makeWrapper, patchelf, perl, which, python2
5 # libjulia dependencies
6 , libunwind, readline, utf8proc, zlib
7 # standard library dependencies
8 , curl, fftwSinglePrec, fftw, gmp, libgit2, mpfr, openlibm, openspecfun, pcre2
10 , blas, lapack, arpack
12 , CoreServices, ApplicationServices
15 assert (!blas.isILP64) && (!lapack.isILP64);
22 maintenanceVersion = "1";
23 src_sha256 = "0q9a7yc3b235psrwl5ghyxgwly25lf8n818l8h6bkf2ymdbsv5p6";
24 version = "${majorVersion}.${minorVersion}.${maintenanceVersion}";
27 stdenv.mkDerivation rec {
32 url = "https://github.com/JuliaLang/julia/releases/download/v${majorVersion}.${minorVersion}.${maintenanceVersion}/julia-${majorVersion}.${minorVersion}.${maintenanceVersion}-full.tar.gz";
37 export PATH=$PATH:${cmake}/bin
41 ./use-system-utf8proc-julia-1.3.patch
43 # Julia recompiles a precompiled file if the mtime stored *in* the
44 # .ji file differs from the mtime of the .ji file. This
45 # doesn't work in Nix because Nix changes the mtime of files in
46 # the Nix store to 1. So patch Julia to accept mtimes of 1.
47 ./allow_nix_mtime.patch
51 patchShebangs . contrib
52 for i in backtrace cmdlineargs; do
56 rm stdlib/Sockets/test/runtests.jl && touch stdlib/Sockets/test/runtests.jl
57 rm stdlib/Distributed/test/runtests.jl && touch stdlib/Distributed/test/runtests.jl
58 sed -e 's/Invalid Content-Type:/invalid Content-Type:/g' -i ./stdlib/LibGit2/test/libgit2.jl
59 sed -e 's/Failed to resolve /failed to resolve /g' -i ./stdlib/LibGit2/test/libgit2.jl
63 arpack fftw fftwSinglePrec gmp libgit2 libunwind mpfr
64 pcre2.dev blas lapack openlibm openspecfun readline utf8proc
67 ++ lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
70 nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which ];
74 arch = head (splitString "-" stdenv.system);
76 x86_64 = stdenv.hostPlatform.gcc.arch or "x86-64";
80 or (throw "unsupported architecture: ${arch}");
81 # Julia requires Pentium 4 (SSE2) or better
82 cpuTarget = { x86_64 = "x86-64"; i686 = "pentium4"; aarch64 = "generic"; }.${arch}
83 or (throw "unsupported architecture: ${arch}");
87 "JULIA_CPU_TARGET=${cpuTarget}"
90 "SHELL=${stdenv.shell}"
92 (lib.optionalString (!stdenv.isDarwin) "USE_SYSTEM_BLAS=1")
93 "USE_BLAS64=${if blas.isILP64 then "1" else "0"}"
100 "USE_SYSTEM_LIBGIT2=1"
101 "USE_SYSTEM_LIBUNWIND=1"
104 "USE_SYSTEM_OPENLIBM=1"
105 "USE_SYSTEM_OPENSPECFUN=1"
106 "USE_SYSTEM_PATCHELF=1"
108 "PCRE_CONFIG=${pcre2.dev}/bin/pcre2-config"
109 "PCRE_INCL_PATH=${pcre2.dev}/include/pcre2.h"
110 "USE_SYSTEM_READLINE=1"
111 "USE_SYSTEM_UTF8PROC=1"
114 "USE_BINARYBUILDER=0"
117 LD_LIBRARY_PATH = makeLibraryPath [
118 arpack fftw fftwSinglePrec gmp libgit2 mpfr blas openlibm
119 openspecfun pcre2 lapack
122 # Other versions of Julia pass the tests, but we are not sure why these fail.
124 checkTarget = "testall";
125 # Julia's tests require read/write access to $HOME
127 export HOME="$NIX_BUILD_TOP"
131 sed -e '/^install:/s@[^ ]*/doc/[^ ]*@@' -i Makefile
132 sed -e '/[$](DESTDIR)[$](docdir)/d' -i Makefile
133 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
137 # Symlink shared libraries from LD_LIBRARY_PATH into lib/julia,
138 # as using a wrapper with LD_LIBRARY_PATH causes segmentation
139 # faults when program returns an error:
140 # $ julia -e 'throw(Error())'
141 find $(echo $LD_LIBRARY_PATH | sed 's|:| |g') -maxdepth 1 -name '*.${if stdenv.isDarwin then "dylib" else "so"}*' | while read lib; do
142 if [[ ! -e $out/lib/julia/$(basename $lib) ]]; then
143 ln -sv $lib $out/lib/julia/$(basename $lib)
149 inherit majorVersion minorVersion maintenanceVersion;
150 site = "share/julia/site/v${majorVersion}.${minorVersion}";
154 description = "High-level performance-oriented dynamical language for technical computing";
155 homepage = "https://julialang.org/";
156 license = lib.licenses.mit;
157 maintainers = with lib.maintainers; [ raskin rob garrison ];
158 platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
159 broken = stdenv.isi686;