nixpkgs/pkgs/development/compilers/julia/default.nix

203 lines
6.1 KiB
Nix
Raw Normal View History

2018-07-29 10:16:15 +01:00
{ stdenv, fetchurl, fetchzip
2015-10-11 15:15:50 +01:00
# build tools
, gfortran, m4, makeWrapper, patchelf, perl, which, python2, paxctl
2015-10-11 15:15:50 +01:00
# libjulia dependencies
2018-07-29 10:16:15 +01:00
, libunwind, readline, utf8proc, zlib
, llvm
2015-10-11 15:15:50 +01:00
# standard library dependencies
, curl, fftwSinglePrec, fftw, gmp, libgit2, mpfr, openlibm, openspecfun, pcre2
# linear algebra
, openblas, arpack, suitesparse
# Darwin frameworks
, CoreServices, ApplicationServices
2015-10-11 15:15:50 +01:00
}:
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";
};
2018-07-29 10:16:15 +01:00
libuvVersion = "d8ab1c6a33e77bf155facb54215dd8798e13825d";
2015-10-11 15:15:50 +01:00
libuv = fetchurl {
url = "https://api.github.com/repos/JuliaLang/libuv/tarball/${libuvVersion}";
2018-07-29 10:16:15 +01:00
sha256 = "0q5ahc9dzca2yc6cjbhpfi9nwc4yhhjbgxgsychksn13d24gv7ba";
2015-10-11 15:15:50 +01:00
};
rmathVersion = "0.1";
rmath-julia = fetchurl {
url = "https://api.github.com/repos/JuliaLang/Rmath-julia/tarball/v${rmathVersion}";
sha256 = "1qyps217175qhid46l8f5i1v8i82slgp23ia63x2hzxwfmx8617p";
2015-10-11 15:15:50 +01:00
};
2018-07-29 10:16:15 +01:00
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}";
2015-10-11 15:15:50 +01:00
in
stdenv.mkDerivation rec {
pname = "julia";
2018-07-29 10:16:15 +01:00
inherit version;
2015-10-11 15:15:50 +01:00
name = "${pname}-${version}";
2018-07-29 10:16:15 +01:00
src = fetchzip {
2015-10-11 15:15:50 +01:00
url = "https://github.com/JuliaLang/${pname}/releases/download/v${version}/${name}.tar.gz";
2018-07-29 10:16:15 +01:00
sha256 = "09axkkj914al7lzvcvhb33hz5wp083lk18llsvrn622fqhmyqabl";
2015-10-11 15:15:50 +01:00
};
prePatch = ''
2018-07-29 10:16:15 +01:00
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"
2015-10-11 15:15:50 +01:00
'';
patches = [
2018-07-29 10:16:15 +01:00
./0001.1-use-system-utf8proc.patch
2015-10-11 15:15:50 +01:00
./0002-use-system-suitesparse.patch
2018-07-29 10:16:15 +01:00
] ++ stdenv.lib.optional stdenv.needsPax ./0004-hardened.patch;
2015-10-11 15:15:50 +01:00
postPatch = ''
patchShebangs . contrib
2018-07-29 10:16:15 +01:00
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
2015-10-11 15:15:50 +01:00
'';
buildInputs = [
2018-07-29 10:16:15 +01:00
arpack fftw fftwSinglePrec gmp libgit2 libunwind mpfr
pcre2.dev openblas openlibm openspecfun readline suitesparse utf8proc
2018-07-29 10:16:15 +01:00
zlib llvm
]
++ stdenv.lib.optionals stdenv.isDarwin [CoreServices ApplicationServices]
;
2015-10-11 15:15:50 +01:00
nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which ]
++ stdenv.lib.optional stdenv.needsPax paxctl;
2015-10-11 15:15:50 +01:00
makeFlags =
let
arch = head (splitString "-" stdenv.system);
2018-07-29 10:16:15 +01:00
march = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}"
2015-10-11 15:15:50 +01:00
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"
2018-07-29 10:16:15 +01:00
2015-10-11 15:15:50 +01:00
"USE_SYSTEM_LLVM=1"
2018-07-29 10:16:15 +01:00
"LLVM_VER=3.9.1"
2015-10-11 15:15:50 +01:00
"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"
2015-10-11 15:15:50 +01:00
"USE_SYSTEM_READLINE=1"
"USE_SYSTEM_UTF8PROC=1"
"USE_SYSTEM_ZLIB=1"
];
NIX_CFLAGS_COMPILE = [ "-fPIC" ];
LD_LIBRARY_PATH = makeLibraryPath [
2015-10-11 15:15:50 +01:00
arpack fftw fftwSinglePrec gmp libgit2 mpfr openblas openlibm
2018-07-29 10:16:15 +01:00
openspecfun pcre2 suitesparse llvm
2015-10-11 15:15:50 +01:00
];
dontStrip = true;
dontPatchELF = true;
enableParallelBuilding = true;
2018-07-29 10:16:15 +01:00
doCheck = !stdenv.isDarwin;
2015-10-11 15:15:50 +01:00
checkTarget = "testall";
# Julia's tests require read/write access to $HOME
preCheck = ''
export HOME="$NIX_BUILD_TOP"
'';
2018-07-29 10:16:15 +01:00
preBuild = ''
sed -e '/^install:/s@[^ ]*/doc/[^ ]*@@' -i Makefile
sed -e '/[$](DESTDIR)[$](docdir)/d' -i Makefile
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
'';
2015-10-11 15:15:50 +01:00
postInstall = ''
2018-07-29 10:16:15 +01:00
# 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
2015-10-11 15:15:50 +01:00
done
'';
2018-07-29 10:16:15 +01:00
passthru = {
inherit majorVersion minorVersion maintenanceVersion;
site = "share/julia/site/v${majorVersion}.${minorVersion}";
};
2015-10-11 15:15:50 +01:00
meta = {
description = "High-level performance-oriented dynamical language for technical computing";
homepage = https://julialang.org/;
2015-10-11 15:15:50 +01:00
license = stdenv.lib.licenses.mit;
maintainers = with stdenv.lib.maintainers; [ raskin ];
2015-10-11 15:15:50 +01:00
platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
2018-07-29 10:16:15 +01:00
broken = stdenv.isi686;
2015-10-11 15:15:50 +01:00
};
}