1 { lib, stdenv, fetchzip
3 , gfortran, m4, makeWrapper, patchelf, perl, which, python2, cmake
4 # libjulia dependencies
5 , libunwind, readline, utf8proc, zlib
6 # standard library dependencies
7 , curl, fftwSinglePrec, fftw, libgit2, mpfr, openlibm, openspecfun, pcre2
11 , CoreServices, ApplicationServices
14 assert (!blas.isILP64) && (!lapack.isILP64);
21 maintenanceVersion = "4";
22 src_sha256 = "1ba1v7hakgj95xvhyff0zcp0574qv6vailjl48wl1f8w5k54lsw2";
23 version = "${majorVersion}.${minorVersion}.${maintenanceVersion}";
26 stdenv.mkDerivation rec {
31 url = "https://github.com/JuliaLang/julia/releases/download/v${version}/julia-${version}-full.tar.gz";
36 ./use-system-utf8proc-julia-1.3.patch
38 # Julia recompiles a precompiled file if the mtime stored *in* the
39 # .ji file differs from the mtime of the .ji file. This
40 # doesn't work in Nix because Nix changes the mtime of files in
41 # the Nix store to 1. So patch Julia to accept mtimes of 1.
42 ./allow_nix_mtime.patch
46 patchShebangs . contrib
47 for i in backtrace cmdlineargs; do
51 rm stdlib/Sockets/test/runtests.jl && touch stdlib/Sockets/test/runtests.jl
52 rm stdlib/Distributed/test/runtests.jl && touch stdlib/Distributed/test/runtests.jl
53 # LibGit2 fails with a weird error, so we skip it as well now
54 rm stdlib/LibGit2/test/runtests.jl && touch stdlib/LibGit2/test/runtests.jl
55 sed -e 's/Invalid Content-Type:/invalid Content-Type:/g' -i ./stdlib/LibGit2/test/libgit2.jl
56 sed -e 's/Failed to resolve /failed to resolve /g' -i ./stdlib/LibGit2/test/libgit2.jl
59 dontUseCmakeConfigure = true;
62 arpack fftw fftwSinglePrec libgit2 libunwind mpfr
63 pcre2.dev blas lapack openlibm openspecfun readline utf8proc
65 ] ++ lib.optionals stdenv.isDarwin [CoreServices ApplicationServices];
67 nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which cmake ];
71 arch = head (splitString "-" stdenv.system);
73 x86_64 = stdenv.hostPlatform.gcc.arch or "x86-64";
77 or (throw "unsupported architecture: ${arch}");
78 # Julia requires Pentium 4 (SSE2) or better
79 cpuTarget = { x86_64 = "x86-64"; i686 = "pentium4"; aarch64 = "generic"; }.${arch}
80 or (throw "unsupported architecture: ${arch}");
81 # Julia applies a lot of patches to its dependencies, so for now do not use the system LLVM
82 # https://github.com/JuliaLang/julia/tree/master/deps/patches
86 "JULIA_CPU_TARGET=${cpuTarget}"
89 "SHELL=${stdenv.shell}"
91 (lib.optionalString (!stdenv.isDarwin) "USE_SYSTEM_BLAS=1")
92 "USE_BLAS64=${if blas.isILP64 then "1" else "0"}"
99 "USE_SYSTEM_LIBGIT2=1"
100 "USE_SYSTEM_LIBUNWIND=1"
103 "USE_SYSTEM_OPENLIBM=1"
104 "USE_SYSTEM_OPENSPECFUN=1"
105 "USE_SYSTEM_PATCHELF=1"
107 "PCRE_CONFIG=${pcre2.dev}/bin/pcre2-config"
108 "PCRE_INCL_PATH=${pcre2.dev}/include/pcre2.h"
109 "USE_SYSTEM_READLINE=1"
110 "USE_SYSTEM_UTF8PROC=1"
113 "USE_BINARYBUILDER=0"
116 LD_LIBRARY_PATH = makeLibraryPath [
117 arpack fftw fftwSinglePrec libgit2 mpfr blas openlibm
118 openspecfun pcre2 lapack
121 # Julia's tests require read/write access to $HOME
123 export HOME="$NIX_BUILD_TOP"
127 sed -e '/^install:/s@[^ ]*/doc/[^ ]*@@' -i Makefile
128 sed -e '/[$](DESTDIR)[$](docdir)/d' -i Makefile
129 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
133 # Symlink shared libraries from LD_LIBRARY_PATH into lib/julia,
134 # as using a wrapper with LD_LIBRARY_PATH causes segmentation
135 # faults when program returns an error:
136 # $ julia -e 'throw(Error())'
137 find $(echo $LD_LIBRARY_PATH | sed 's|:| |g') -maxdepth 1 -name '*.${if stdenv.isDarwin then "dylib" else "so"}*' | while read lib; do
138 if [[ ! -e $out/lib/julia/$(basename $lib) ]]; then
139 ln -sv $lib $out/lib/julia/$(basename $lib)
145 inherit majorVersion minorVersion maintenanceVersion;
146 site = "share/julia/site/v${majorVersion}.${minorVersion}";
150 description = "High-level performance-oriented dynamical language for technical computing";
151 homepage = "https://julialang.org/";
152 license = lib.licenses.mit;
153 maintainers = with lib.maintainers; [ raskin rob garrison ];
154 platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
155 broken = stdenv.isi686;