1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
{
version,
sha256,
patches ? [ ],
}:
{
autoPatchelfHook,
fetchurl,
lib,
stdenv,
}:
let
skip_tests = [
# Test flaky on ofborg
"channels"
# Test flaky
"read"
]
++ lib.optionals (lib.versions.majorMinor version == "1.10") [
"LinearAlgebra/blas"
]
++ lib.optionals (lib.versionAtLeast version "1.10") [
# Test flaky
# https://github.com/JuliaLang/julia/issues/52739
"REPL"
# Test flaky
"ccall"
"loading"
]
++ lib.optionals (lib.versionAtLeast version "1.11") [
# Test flaky
# https://github.com/JuliaLang/julia/issues/54280
"cmdlineargs"
]
++ lib.optionals (lib.versionAtLeast version "1.12") [
# Test flaky because of our RPATH patching
# https://github.com/NixOS/nixpkgs/pull/230965#issuecomment-1545336489
"Compiler/codegen"
"precompile"
"compileall"
"Profile"
]
++ lib.optionals (lib.versionOlder version "1.12") [
"compiler/codegen" # older versions' test was in lowercase
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# Test flaky on ofborg
"FileWatching"
# Test requires pbcopy
"InteractiveUtils"
# Test requires network access
"Sockets"
"Distributed"
]
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
# Test Failed at $out/share/julia/stdlib/v1.8/LinearAlgebra/test/blas.jl:702
"LinearAlgebra/blas"
# Test Failed at $out/share/julia/test/misc.jl:724
"misc"
];
in
stdenv.mkDerivation {
pname = "julia-bin";
inherit version patches;
src =
{
x86_64-linux = fetchurl {
url = "https://julialang-s3.julialang.org/bin/linux/x64/${lib.versions.majorMinor version}/julia-${version}-linux-x86_64.tar.gz";
sha256 = sha256.x86_64-linux;
};
aarch64-linux = fetchurl {
url = "https://julialang-s3.julialang.org/bin/linux/aarch64/${lib.versions.majorMinor version}/julia-${version}-linux-aarch64.tar.gz";
sha256 = sha256.aarch64-linux;
};
aarch64-darwin = fetchurl {
url = "https://julialang-s3.julialang.org/bin/mac/aarch64/${lib.versions.majorMinor version}/julia-${version}-macaarch64.tar.gz";
sha256 = sha256.aarch64-darwin;
};
}
.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
postPatch = ''
# Julia fails to pick up our Certification Authority root certificates, but
# it provides its own so we can simply disable the test. Patching in the
# dynamic path to ours require us to rebuild the Julia system image.
substituteInPlace share/julia/stdlib/v${lib.versions.majorMinor version}/NetworkOptions/test/runtests.jl \
--replace '@test ca_roots_path() != bundled_ca_roots()' \
'@test_skip ca_roots_path() != bundled_ca_roots()'
'';
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
autoPatchelfHook
# https://github.com/JuliaLang/julia/blob/v1.9.0/NEWS.md#external-dependencies
stdenv.cc.cc
];
installPhase = ''
runHook preInstall
cp -r . $out
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
# "$out/share" is intentionally omitted since it contains
# julia package images and patchelf would break them
autoPatchelf "$out/bin" "$out/lib" "$out/libexec"
''
+ ''
runHook postInstall
'';
# Breaks backtraces, etc.
dontStrip = true;
dontAutoPatchelf = true;
doInstallCheck = true;
preInstallCheck = ''
export JULIA_TEST_USE_MULTIPLE_WORKERS=true
# Some tests require read/write access to $HOME.
# And $HOME cannot be equal to $TMPDIR as it causes test failures
export HOME=$(mktemp -d)
'';
installCheckPhase = ''
runHook preInstallCheck
# Command lifted from `test/Makefile`.
$out/bin/julia \
--check-bounds=yes \
--startup-file=no \
--depwarn=error \
$out/share/julia/test/runtests.jl \
--skip internet_required ${toString skip_tests}
runHook postInstallCheck
'';
meta = {
description = "High-level, high-performance, dynamic language for technical computing";
homepage = "https://julialang.org";
# Bundled and linked with various GPL code, although Julia itself is MIT.
license = lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [
raskin
nickcao
wegank
thomasjm
];
platforms = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
mainProgram = "julia";
};
}
|