forked from flicaflow/julia_flake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-julia-15-package.nix
73 lines (52 loc) · 1.63 KB
/
build-julia-15-package.nix
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
{ runCommand, lib, stdenv, julia_15, curl, cacert, writeShellScript, coreutils, ... }:
{name, src, entry, dependencyHash, execName, ... }: let
depot = stdenv.mkDerivation rec {
name = "julia_depot";
buildInputs = [ julia_15 curl ];
inherit src;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = dependencyHash;
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
buildPhase = ''
mkdir depot
export JULIA_DEPOT_PATH=depot/
julia -e "import Pkg; Pkg.activate(\".\"); Pkg.instantiate(); Pkg.precompile()"
mkdir -p depot/environments/v1.5
cp Manifest.toml depot/environments/v1.5/
cp Project.toml depot/environments/v1.5/
rm -r depot/registries
'';
installPhase = ''
mkdir -p $out/
cp -R depot/ $out/depot
'';
};
filesEqual = f1: f2: let
a = runCommand "compare-mainfests" {} ''
cmp ${f1} ${f2} > $out || true
'';
file = builtins.readFile a;
in file == "";
in
assert (lib.assertMsg (
filesEqual "${depot}/depot/environments/v1.5/Manifest.toml" "${src}/Manifest.toml")
"buildJuila15Package: Manifest has changed, update dependencyHash");
stdenv.mkDerivation rec {
inherit name src;
exec = writeShellScript execName ''
DEPOT=$(${coreutils}/bin/mktemp -d)
export JULIA_DEPOT_PATH="$DEPOT/depot"
echo Depot path is $DEPOT
cp -R ${depot}/* $DEPOT/depot
chmod -R +w $DEPOT
exec ${julia_15}/bin/julia --project="${src}" ${src}/${entry} $@
'';
buildPhase = ''
:
'';
installPhase = ''
mkdir -p $out/bin
cp ${exec} $out/bin/${execName}
'';
}