forked from tezos-checker/checker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
126 lines (116 loc) · 3.45 KB
/
default.nix
File metadata and controls
126 lines (116 loc) · 3.45 KB
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
{ doCheck ? false, e2eTestsHack ? false }:
let
sources = import ./nix/sources.nix { };
overlay = se: su: {
poetry2nix = se.callPackage sources.poetry2nix { };
};
pkgsHost = import sources.nixpkgs { overlays = [ overlay ]; };
pkgsLinux = import sources.nixpkgs { system = "x86_64-linux"; overlays = [ overlay ]; };
gitignoreNix = import sources."gitignore.nix" { lib = pkgsHost.lib; };
ligoBinary =
# This is a precompiled file, which is the ligo revision `1d1cc2cae` compiled
# with the patch ./patches/ligo_michelson_maximum_type_size.patch.
pkgsLinux.runCommand "ligo-binary" { buildInputs = [ pkgsLinux.unzip ]; } ''
mkdir -p $out/bin
ln -s ${./bin/ligo} $out/bin/ligo
'';
# Run 'niv update ligo-artifacts -r <git_rev>' to update
# pkgsLinux.runCommand "ligo-binary" { buildInputs = [ pkgs.unzip ]; } ''
# mkdir -p $out/bin
# unzip ${sources.ligo-artifacts} ligo -d $out/bin
# chmod +x $out/bin/ligo
# '';
ocamlDeps = pkgs: with pkgs.ocamlPackages; [
ocaml
ocaml-lsp
dune_2
findlib # Lets merlin see packages like ounit
ocp-indent
merlin
ounit
qcheck
ppxlib
bisect_ppx
ppx_tools_versioned
ppx_deriving
zarith
odoc
core_kernel
];
checkerSource =
let filter =
let ignored = gitignoreNix.gitignoreFilter ./.;
in path: type: ignored path type && builtins.baseNameOf path != "ligo";
in
pkgsHost.lib.cleanSourceWith {
inherit filter;
src = ./.;
name = "checker-source";
};
in
rec
{
michelson =
let pkgs = pkgsLinux;
in
pkgs.stdenv.mkDerivation {
name = "checker-michelson";
buildInputs = [ ligoBinary ] ++ (with pkgs; [ ruby ]) ++ ocamlDeps pkgs;
src = checkerSource;
# On E2E tests, we are using a patched version of checker to be able to experiment
# with index changes without having to wait for the protected index to catch up.
# It's a hack, and shouldn't be used for anything else than the tests.
patchPhase = pkgs.lib.optional e2eTestsHack ''
set -x
cat ${./patches/e2e-tests-hack.patch} | patch -p1
set +x
'';
buildPhase = ''
export HOME=$(mktemp -d)
make build-ligo
'';
inherit doCheck;
checkPhase = ''
make build-ocaml
make test
'';
installPhase = ''
mkdir -p $out
cp generated/michelson/* $out
'';
};
spec =
let pkgs = pkgsHost;
in
pkgs.stdenv.mkDerivation {
src = checkerSource;
name = "checker-spec";
buildInputs = with pkgs; [ sphinx python3Packages.sphinx_rtd_theme ];
buildPhase = ''
make spec
'';
installPhase = ''
cp -R docs/spec/_build/html $out
'';
};
shell =
let
pkgs = pkgsHost;
pythonDeps = import ./nix/python.nix { inherit pkgs; };
in
pkgs.mkShell {
name = "checker-shell";
buildInputs =
# ligo does not compile on macos, also we don't want to
# compile it in CI
pkgs.lib.optionals (pkgs.stdenv.isLinux) [ ligoBinary ]
++ pkgs.lib.optionals (!(pkgs.stdenv.isDarwin && pkgs.stdenv.isAarch64)) [ pkgs.niv ]
++ (with pkgs; [ ruby bc sphinx poetry entr nodePackages.live-server fd python3Packages.black nixpkgs-fmt jq gawk gitMinimal ])
++ spec.buildInputs
++ ocamlDeps pkgs
++ pythonDeps.buildInputs;
shellHook = ''
${pythonDeps.shellHook}
'';
};
}