2021-01-22 11:25:31 +00:00
|
|
|
{ lib, stdenv, fetchurl, fetchzip, fetchFromGitHub
|
2020-02-03 18:17:22 +00:00
|
|
|
# build tools
|
|
|
|
, gfortran, m4, makeWrapper, patchelf, perl, which, python2
|
|
|
|
, cmake
|
|
|
|
# libjulia dependencies
|
|
|
|
, libunwind, readline, utf8proc, zlib
|
|
|
|
# standard library dependencies
|
|
|
|
, curl, fftwSinglePrec, fftw, gmp, libgit2, mpfr, openlibm, openspecfun, pcre2
|
|
|
|
# linear algebra
|
2020-03-31 15:47:18 +01:00
|
|
|
, blas, lapack, arpack
|
2020-02-13 11:57:14 +00:00
|
|
|
# Darwin frameworks
|
|
|
|
, CoreServices, ApplicationServices
|
2020-02-03 18:17:22 +00:00
|
|
|
}:
|
|
|
|
|
2020-04-20 21:50:55 +01:00
|
|
|
assert (!blas.isILP64) && (!lapack.isILP64);
|
2020-03-31 15:47:18 +01:00
|
|
|
|
2021-01-22 11:25:31 +00:00
|
|
|
with lib;
|
2020-02-03 18:17:22 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
majorVersion = "1";
|
|
|
|
minorVersion = "3";
|
|
|
|
maintenanceVersion = "1";
|
|
|
|
src_sha256 = "0q9a7yc3b235psrwl5ghyxgwly25lf8n818l8h6bkf2ymdbsv5p6";
|
|
|
|
version = "${majorVersion}.${minorVersion}.${maintenanceVersion}";
|
2020-03-31 15:47:18 +01:00
|
|
|
in
|
2020-02-03 18:17:22 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "julia";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchzip {
|
|
|
|
url = "https://github.com/JuliaLang/julia/releases/download/v${majorVersion}.${minorVersion}.${maintenanceVersion}/julia-${majorVersion}.${minorVersion}.${maintenanceVersion}-full.tar.gz";
|
|
|
|
sha256 = src_sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
export PATH=$PATH:${cmake}/bin
|
|
|
|
'';
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./use-system-utf8proc-julia-1.3.patch
|
|
|
|
|
|
|
|
# Julia recompiles a precompiled file if the mtime stored *in* the
|
|
|
|
# .ji file differs from the mtime of the .ji file. This
|
|
|
|
# doesn't work in Nix because Nix changes the mtime of files in
|
|
|
|
# the Nix store to 1. So patch Julia to accept mtimes of 1.
|
|
|
|
./allow_nix_mtime.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
|
2020-03-31 15:47:18 +01:00
|
|
|
pcre2.dev blas lapack openlibm openspecfun readline utf8proc
|
2020-02-03 18:17:22 +00:00
|
|
|
zlib
|
|
|
|
]
|
2021-01-22 11:25:31 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
|
2020-02-03 18:17:22 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which ];
|
|
|
|
|
|
|
|
makeFlags =
|
|
|
|
let
|
|
|
|
arch = head (splitString "-" stdenv.system);
|
2020-11-18 13:33:03 +00:00
|
|
|
march = {
|
2021-01-23 01:33:55 +00:00
|
|
|
x86_64 = stdenv.hostPlatform.gcc.arch or "x86-64";
|
2020-11-18 13:33:03 +00:00
|
|
|
i686 = "pentium4";
|
|
|
|
aarch64 = "armv8-a";
|
|
|
|
}.${arch}
|
2020-02-03 18:17:22 +00:00
|
|
|
or (throw "unsupported architecture: ${arch}");
|
|
|
|
# Julia requires Pentium 4 (SSE2) or better
|
2020-11-18 13:33:03 +00:00
|
|
|
cpuTarget = { x86_64 = "x86-64"; i686 = "pentium4"; aarch64 = "generic"; }.${arch}
|
2020-02-03 18:17:22 +00:00
|
|
|
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"
|
2020-04-20 21:50:55 +01:00
|
|
|
"USE_BLAS64=${if blas.isILP64 then "1" else "0"}"
|
2020-02-03 18:17:22 +00:00
|
|
|
|
|
|
|
"USE_SYSTEM_LAPACK=1"
|
|
|
|
|
|
|
|
"USE_SYSTEM_ARPACK=1"
|
|
|
|
"USE_SYSTEM_FFTW=1"
|
|
|
|
"USE_SYSTEM_GMP=1"
|
|
|
|
"USE_SYSTEM_LIBGIT2=1"
|
|
|
|
"USE_SYSTEM_LIBUNWIND=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"
|
|
|
|
|
|
|
|
"USE_BINARYBUILDER=0"
|
|
|
|
];
|
|
|
|
|
|
|
|
LD_LIBRARY_PATH = makeLibraryPath [
|
2020-03-31 15:47:18 +01:00
|
|
|
arpack fftw fftwSinglePrec gmp libgit2 mpfr blas openlibm
|
2020-05-31 21:50:36 +01:00
|
|
|
openspecfun pcre2 lapack
|
2020-02-03 18:17:22 +00:00
|
|
|
];
|
|
|
|
|
2020-11-18 13:33:03 +00:00
|
|
|
# Other versions of Julia pass the tests, but we are not sure why these fail.
|
|
|
|
doCheck = false;
|
2020-02-03 18:17:22 +00:00
|
|
|
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";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://julialang.org/";
|
2021-01-22 11:25:31 +00:00
|
|
|
license = lib.licenses.mit;
|
|
|
|
maintainers = with lib.maintainers; [ raskin rob garrison ];
|
2020-02-03 18:17:22 +00:00
|
|
|
platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
|
|
|
|
broken = stdenv.isi686;
|
|
|
|
};
|
|
|
|
}
|