2015-10-11 15:15:50 +01:00
|
|
|
{ stdenv, fetchgit, fetchurl
|
|
|
|
# build tools
|
2017-02-01 09:55:05 +00:00
|
|
|
, gfortran, m4, makeWrapper, patchelf, perl, which, python2, paxctl
|
2015-10-11 15:15:50 +01:00
|
|
|
# libjulia dependencies
|
|
|
|
, libunwind, llvm, readline, utf8proc, zlib
|
|
|
|
# standard library dependencies
|
|
|
|
, curl, fftwSinglePrec, fftw, gmp, libgit2, mpfr, openlibm, openspecfun, pcre2
|
|
|
|
# linear algebra
|
|
|
|
, openblas, arpack, suitesparse
|
2016-03-13 08:18:16 +00:00
|
|
|
# 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; };
|
2016-03-13 08:18:16 +00:00
|
|
|
llvmShared = if stdenv.isDarwin
|
|
|
|
then llvm.override { enableSharedLibraries = true; }
|
|
|
|
else llvm;
|
2015-10-11 15:15:50 +01:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
|
2016-05-10 10:25:18 +01:00
|
|
|
libuvVersion = "efb40768b7c7bd9f173a7868f74b92b1c5a61a0e";
|
2015-10-11 15:15:50 +01:00
|
|
|
libuv = fetchurl {
|
|
|
|
url = "https://api.github.com/repos/JuliaLang/libuv/tarball/${libuvVersion}";
|
2016-05-10 10:25:18 +01:00
|
|
|
sha256 = "1znkxyv1cy9pjap7afypipzsn04533ni3pqjd191fdgw2sv9cal7";
|
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 = "0ai5dhjc43zcvangz123ryxmlbm51s21rg13bllwyn98w67arhb4";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "julia";
|
2016-11-27 09:13:24 +00:00
|
|
|
version = "0.4.7";
|
2015-10-11 15:15:50 +01:00
|
|
|
name = "${pname}-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/JuliaLang/${pname}/releases/download/v${version}/${name}.tar.gz";
|
2016-11-27 09:13:24 +00:00
|
|
|
sha256 = "09f531jhs8pyd1xng5c26x994w7q0sxxr28mr3qfw9wpkbmsc2pf";
|
2015-10-11 15:15:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
cp "${dsfmt}" "./deps/dsfmt-${dsfmtVersion}.tar.gz"
|
|
|
|
cp "${rmath-julia}" "./deps/Rmath-julia-${rmathVersion}.tar.gz"
|
|
|
|
cp "${libuv}" "./deps/libuv-${libuvVersion}.tar.gz"
|
|
|
|
'';
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./0001-use-system-utf8proc.patch
|
|
|
|
./0002-use-system-suitesparse.patch
|
|
|
|
./0003-no-ldconfig.patch
|
2017-02-01 09:55:05 +00:00
|
|
|
] ++ stdenv.lib.optional stdenv.needsPax ./0004-hardened-0.4.7.patch;
|
2015-10-11 15:15:50 +01:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs . contrib
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [
|
2016-03-13 08:18:16 +00:00
|
|
|
arpack fftw fftwSinglePrec gmp libgit2 libunwind llvmShared mpfr
|
2016-09-14 17:34:56 +01:00
|
|
|
pcre2.dev openblas openlibm openspecfun readline suitesparse utf8proc
|
2015-10-11 15:15:50 +01:00
|
|
|
zlib
|
2016-03-13 08:18:16 +00:00
|
|
|
] ++
|
|
|
|
stdenv.lib.optionals stdenv.isDarwin [CoreServices ApplicationServices] ;
|
2015-10-11 15:15:50 +01:00
|
|
|
|
2017-02-01 09:55:05 +00: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);
|
|
|
|
march = { "x86_64" = "x86-64"; "i686" = "i686"; }."${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"
|
|
|
|
"USE_SYSTEM_MPFR=1"
|
|
|
|
"USE_SYSTEM_OPENLIBM=1"
|
|
|
|
"USE_SYSTEM_OPENSPECFUN=1"
|
|
|
|
"USE_SYSTEM_PATCHELF=1"
|
|
|
|
"USE_SYSTEM_PCRE=1"
|
2016-09-14 17:34:56 +01:00
|
|
|
"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" ];
|
|
|
|
|
2016-04-13 13:53:51 +01:00
|
|
|
LD_LIBRARY_PATH = makeLibraryPath [
|
2015-10-11 15:15:50 +01:00
|
|
|
arpack fftw fftwSinglePrec gmp libgit2 mpfr openblas openlibm
|
|
|
|
openspecfun pcre2 suitesparse
|
|
|
|
];
|
|
|
|
|
2016-03-13 08:18:16 +00:00
|
|
|
NIX_LDFLAGS = optionalString stdenv.isDarwin "-rpath ${llvmShared}/lib";
|
|
|
|
|
2015-10-11 15:15:50 +01:00
|
|
|
dontStrip = true;
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkTarget = "testall";
|
|
|
|
# Julia's tests require read/write access to $HOME
|
|
|
|
preCheck = ''
|
|
|
|
export HOME="$NIX_BUILD_TOP"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
for prog in "$out/bin/julia" "$out/bin/julia-debug"; do
|
|
|
|
wrapProgram "$prog" \
|
|
|
|
--prefix LD_LIBRARY_PATH : "$LD_LIBRARY_PATH" \
|
2016-04-16 17:47:55 +01:00
|
|
|
--prefix PATH : "${stdenv.lib.makeBinPath [ curl ]}"
|
2015-10-11 15:15:50 +01:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "High-level performance-oriented dynamical language for technical computing";
|
2017-08-02 22:50:51 +01:00
|
|
|
homepage = https://julialang.org/;
|
2015-10-11 15:15:50 +01:00
|
|
|
license = stdenv.lib.licenses.mit;
|
2016-05-02 19:54:47 +01:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ raskin ];
|
2015-10-11 15:15:50 +01:00
|
|
|
platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
|
2016-09-10 17:58:29 +01:00
|
|
|
broken = stdenv.isi686;
|
2015-10-11 15:15:50 +01:00
|
|
|
};
|
|
|
|
}
|