@@ -0,0 +1,73 @@
1+{ autoPatchelfHook, fetchurl, lib, stdenv }:
2+
3+stdenv.mkDerivation rec {
4+ pname = "julia-bin";
5+ version = "1.6.1";
6+
7+ src = {
8+ x86_64-linux = fetchurl {
9+ url = "https://julialang-s3.julialang.org/bin/linux/x64/${lib.versions.majorMinor version}/julia-${version}-linux-x86_64.tar.gz";
10+ sha256 = "01i5sm4vqb0y5qznql571zap19b42775drrcxnzsyhpaqgg8m23w";
11+ };
12+ }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
13+
14+ # Julia’s source files are in different locations for source and binary
15+ # releases. Thus we temporarily create a symlink to allow us to share patches
16+ # with source releases.
17+ prePatch = ''
18+ ln -s share/julia/test
19+ '';
20+ patches = [
21+ # Source release Nix patch(es) relevant for binary releases as well.
22+ ./patches/1.6-bin/0002-nix-Skip-tempname-test-broken-in-sandbox.patch
23+ ./patches/1.6-bin/0003-nix-Skip-chown-tests-broken-in-sandbox.patch
24+ ./patches/1.6-bin/0005-nix-Enable-parallel-unit-tests-for-sandbox.patch
25+ ];
26+ postPatch = ''
27+ # Revert symlink hack.
28+ rm test
29+
30+ # Julia fails to pick up our Certification Authority root certificates, but
31+ # it provides its own so we can simply disable the test. Patching in the
32+ # dynamic path to ours require us to rebuild the Julia system image.
33+ substituteInPlace share/julia/stdlib/v${lib.versions.majorMinor version}/NetworkOptions/test/runtests.jl \
34+ --replace '@test ca_roots_path() != bundled_ca_roots()' \
35+ '@test_skip ca_roots_path() != bundled_ca_roots()'
36+ '';
37+
38+ nativeBuildInputs = [ autoPatchelfHook ];
39+
40+ installPhase = ''
41+ runHook preInstall
42+ cp -r . $out
43+ runHook postInstall
44+ '';
45+
46+ # Breaks backtraces, etc.
47+ dontStrip = true;
48+
49+ doInstallCheck = true;
50+ preInstallCheck = ''
51+ # Some tests require read/write access to $HOME.
52+ export HOME="$TMPDIR"
53+ '';
54+ installCheckPhase = ''
55+ runHook preInstallCheck
56+ # Command lifted from `test/Makefile`.
57+ $out/bin/julia \
58+ --check-bounds=yes \
59+ --startup-file=no \
60+ --depwarn=error \
61+ $out/share/julia/test/runtests.jl
62+ runHook postInstallCheck
63+ '';
64+
65+ meta = {
66+ description = "High-level, high-performance dynamic language for technical computing.";
67+ homepage = "https://julialang.org";
68+ # Bundled and linked with various GPL code, although Julia itself is MIT.
69+ license = lib.licenses.gpl2Plus;
70+ maintainers = with lib.maintainers; [ ninjin raskin ];
71+ platforms = [ "x86_64-linux" ];
72+ };
73+}