at master 2.9 kB view raw
1{ 2 version, 3 hash, 4 patches, 5}: 6 7{ 8 lib, 9 stdenv, 10 fetchurl, 11 which, 12 python3, 13 gfortran, 14 cacert, 15 cmake, 16 perl, 17 gnum4, 18 openssl, 19 libxml2, 20 zlib, 21 buildPackages, 22}: 23 24stdenv.mkDerivation rec { 25 pname = "julia"; 26 27 inherit version patches; 28 29 src = fetchurl { 30 url = "https://github.com/JuliaLang/julia/releases/download/v${version}/julia-${version}-full.tar.gz"; 31 inherit hash; 32 }; 33 34 strictDeps = true; 35 36 nativeBuildInputs = [ 37 which 38 python3 39 gfortran 40 cmake 41 perl 42 gnum4 43 openssl 44 ]; 45 46 buildInputs = [ 47 libxml2 48 zlib 49 ] 50 ++ lib.optionals (lib.versionAtLeast version "1.11") [ 51 cacert 52 ]; 53 54 dontUseCmakeConfigure = true; 55 56 postPatch = '' 57 patchShebangs . 58 '' 59 + lib.optionalString (lib.versionAtLeast version "1.11") '' 60 substituteInPlace deps/curl.mk \ 61 --replace-fail 'cd $(dir $<) && $(TAR) jxf $(notdir $<)' \ 62 'cd $(dir $<) && $(TAR) jxf $(notdir $<) && sed -i "s|/usr/bin/env perl|${lib.getExe buildPackages.perl}|" curl-$(CURL_VER)/scripts/cd2nroff' 63 ''; 64 65 makeFlags = [ 66 "prefix=$(out)" 67 "USE_BINARYBUILDER=0" 68 ] 69 ++ lib.optionals stdenv.hostPlatform.isx86_64 [ 70 # https://github.com/JuliaCI/julia-buildkite/blob/main/utilities/build_envs.sh 71 "JULIA_CPU_TARGET=generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1);x86-64-v4,-rdrnd,base(1)" 72 ] 73 ++ lib.optionals stdenv.hostPlatform.isAarch64 [ 74 "JULIA_CPU_TARGET=generic;cortex-a57;thunderx2t99;carmel,clone_all;apple-m1,base(3);neoverse-512tvb,base(3)" 75 ]; 76 77 # remove forbidden reference to $TMPDIR 78 preFixup = '' 79 for file in libcurl.so libgmpxx.so libmpfr.so; do 80 patchelf --shrink-rpath --allowed-rpath-prefixes ${builtins.storeDir} "$out/lib/julia/$file" 81 done 82 ''; 83 84 # tests are flaky for aarch64-linux on hydra 85 doInstallCheck = if (lib.versionOlder version "1.10") then !stdenv.hostPlatform.isAarch64 else true; 86 87 installCheckTarget = "testall"; 88 89 preInstallCheck = '' 90 export JULIA_TEST_USE_MULTIPLE_WORKERS="true" 91 # Some tests require read/write access to $HOME. 92 # And $HOME cannot be equal to $TMPDIR as it causes test failures 93 export HOME=$(mktemp -d) 94 ''; 95 96 dontStrip = true; 97 98 enableParallelBuilding = true; 99 100 env = lib.optionalAttrs (lib.versionOlder version "1.11" || stdenv.hostPlatform.isAarch64) { 101 NIX_CFLAGS_COMPILE = toString [ 102 "-Wno-error=implicit-function-declaration" 103 "-Wno-error=incompatible-pointer-types" 104 ]; 105 }; 106 107 meta = with lib; { 108 description = "High-level performance-oriented dynamical language for technical computing"; 109 mainProgram = "julia"; 110 homepage = "https://julialang.org/"; 111 license = licenses.mit; 112 maintainers = with maintainers; [ 113 nickcao 114 joshniemela 115 thomasjm 116 ]; 117 platforms = [ 118 "x86_64-linux" 119 "aarch64-linux" 120 ]; 121 }; 122}