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