Skip to content

Commit df61b67

Browse files
authored
Merge pull request #11569 from MinaProtocol/ylecornec/check_opam_switch-compatible
check opam switch - compatible
2 parents 18f2bf3 + fcab071 commit df61b67

File tree

11 files changed

+66
-15
lines changed

11 files changed

+66
-15
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ ocaml_version:
6969
ocaml_word_size:
7070
@if ! ocamlopt -config | grep "word_size:" | grep $(WORD_SIZE); then echo "invalid machine word size, expected $(WORD_SIZE)" ; exit 1; fi
7171

72-
ocaml_checks: ocaml_version ocaml_word_size
72+
73+
# Checks that the current opam switch contains the packages from opam.export at the same version.
74+
# This check is disabled in the pure nix environment (that does not use opam).
75+
check_opam_switch:
76+
ifneq ($(DISABLE_CHECK_OPAM_SWITCH), true)
77+
check_opam_switch opam.export
78+
endif
79+
80+
ocaml_checks: ocaml_version ocaml_word_size check_opam_switch
7381

7482
libp2p_helper:
7583
make -C src/app/libp2p_helper

README-dev.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ Refer to [/dev](/dev).
5050

5151
Mina has a variety of opam and system dependencies.
5252

53-
To get all the opam dependencies you need, you run `opam switch import
54-
src/opam.export`.
53+
To get all the opam dependencies you need, you run `opam switch import opam.export`.
54+
> *_NOTE:_* The switch provides a `dune_wrapper` binary that you can use instead of dune, and will fail early if your switch becomes out of sync with the `opam.export` file.
5555
5656
Some of our dependencies aren't taken from `opam`, and aren't integrated
5757
with `dune`, so you need to add them manually, by running `scripts/pin-external-packages.sh`.

buildkite/src/Constants/ContainerImages.dhall

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
-- NOTE: minaToolchainStretch is also used for building Ubuntu Bionic packages in CI
33
{
44
toolchainBase = "codaprotocol/ci-toolchain-base:v3",
5-
minaToolchainStretch = "gcr.io/o1labs-192920/mina-toolchain@sha256:d2b4e83f641b87b2aee4b981f374d524802a5535e5326ecea9ebe8ad2676faf3",
6-
minaToolchainBuster = "gcr.io/o1labs-192920/mina-toolchain@sha256:8701d3a8ba2c3cf56aa07196a68ac51687466ebace570a4e725bd38157a36e97",
7-
minaToolchainBullseye = "gcr.io/o1labs-192920/mina-toolchain@sha256:f887e30966bc2747302f1f7e0e3baa8e08aad4b387469f0212a4c3534260019b",
8-
minaToolchainFocal = "gcr.io/o1labs-192920/mina-toolchain@sha256:16ebfd20c2f22cb99dde2afd253daa5c91d254f34316943a54e09c1caedfbe55",
5+
minaToolchainStretch = "gcr.io/o1labs-192920/mina-toolchain@sha256:d58f431177b453f3dddd48119d1ca86c9daf9c51f54f2daec5092bb5de674dc8",
6+
minaToolchainBuster = "gcr.io/o1labs-192920/mina-toolchain@sha256:d2305beb4ed343113b79a6cbf88d25fbd4fb9b85913a2fe039b6a545cec63213",
7+
minaToolchainBullseye = "gcr.io/o1labs-192920/mina-toolchain@sha256:ab84f1d19d73ca67d31ee7e11eafd0b5a6bea3fb165b2f3f0469fb6af3efc9e3",
8+
minaToolchainFocal = "gcr.io/o1labs-192920/mina-toolchain@sha256:68bd612b2615946740a4e06dd0e9c3a87fd074cea1456efc1a0bc6149409c923",
99
delegationBackendToolchain = "gcr.io/o1labs-192920/delegation-backend-production@sha256:8ca5880845514ef56a36bf766a0f9de96e6200d61b51f80d9f684a0ec9c031f4",
1010
elixirToolchain = "elixir:1.10-alpine",
1111
nodeToolchain = "node:14.13.1-stretch-slim",

buildkite/src/Jobs/Release/MinaToolchainArtifact.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Pipeline.build
2323
S.strictlyStart (S.contains "dockerfiles/stages/2-"),
2424
S.strictlyStart (S.contains "dockerfiles/stages/3-"),
2525
S.strictlyStart (S.contains "buildkite/src/Jobs/Release/MinaToolchainArtifact"),
26-
S.strictly (S.contains "src/opam.export")
26+
S.strictly (S.contains "opam.export")
2727
],
2828
path = "Release",
2929
name = "MinaToolchainArtifact"

dockerfiles/stages/2-opam-deps

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ WORKDIR $HOME/$MINA_DIR
3636
ENV OPAMYES 1
3737

3838
# --- Import Opam Switch
39-
# TODO: handle this opam work without cloning the full repository (directly pull src/opam.export)
40-
RUN opam switch import src/opam.export
39+
# TODO: handle this opam work without cloning the full repository (directly pull opam.export)
40+
RUN opam switch import opam.export
4141

4242
# --- Pin external packages / submodules
43-
# TODO: Would be really nice to pull this script, the git submodules, and src/opam.export exclusively in this stage
43+
# TODO: Would be really nice to pull this script, the git submodules, and opam.export exclusively in this stage
4444
RUN eval $(opam config env) \
4545
&& scripts/pin-external-packages.sh \
4646
&& opam clean --logs -cs

nix/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ If you wish to update all the inputs of this flake, run `nix flake update` . If
196196

197197
The "pure" build is performed with the help of
198198
[opam-nix](https://github.com/tweag/opam-nix). The switch is imported
199-
from `src/opam.export`, and then external deps (from `src/external`)
199+
from `opam.export`, and then external deps (from `src/external`)
200200
are added on top. Also, all in-tree Rust dependencies
201201
(`kimchi_bindings` in particular) are built as separate derivations
202202
using `rustPlatform`. Implicit native dependencies are taken from

nix/checks.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ inputs: pkgs: {
5151
buildPhase = "make check-format";
5252
installPhase = "touch $out";
5353
meta.checkDescription = "that OCaml code is formatted properly";
54+
DISABLE_CHECK_OPAM_SWITCH = "true";
5455
};
5556

5657
# todo: libp2p_ipc

nix/impure-shell.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pkgs.mkShell {
3030
tput bold
3131
printf 'opam init --bare # Only if you are running opam for the first time\n'
3232
printf 'opam update\n'
33-
printf 'opam switch import src/opam.export --strict\n'
33+
printf 'opam switch import opam.export --strict\n'
3434
printf 'eval $(opam env)\n'
3535
printf './scripts/pin-external-packages.sh\n'
3636
tput sgr0

nix/ocaml.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let
1515
opam-nix.makeOpamRepoRec ../src/external; # Pin external packages
1616
repos = [ external-repo inputs.opam-repository ];
1717

18-
export = opam-nix.importOpam ../src/opam.export;
18+
export = opam-nix.importOpam ../opam.export;
1919
external-packages =
2020
getAttrs [ "sodium" "capnp" "rpc_parallel" "async_kernel" "base58" ]
2121
(builtins.mapAttrs (_: last) (opam-nix.listRepo external-repo));
@@ -135,6 +135,7 @@ let
135135
GO_CAPNP_STD = "${pkgs.go-capnproto2.src}/std";
136136

137137
MARLIN_PLONK_STUBS = "${pkgs.marlin_plonk_bindings_stubs}/lib";
138+
DISABLE_CHECK_OPAM_SWITCH = "true";
138139
configurePhase = ''
139140
export MINA_ROOT="$PWD"
140141
patchShebangs .

src/opam.export renamed to opam.export

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ roots: [
77
"bitstring.4.1.0"
88
"camlp4.4.14+1"
99
"capnp.3.4.0"
10+
"check_opam_switch.~dev"
1011
"cohttp-async.5.0.0"
1112
"core_extended.v0.14.0"
1213
"extlib.1.7.8"
@@ -67,6 +68,7 @@ installed: [
6768
"caqti-async.1.3.0"
6869
"caqti-driver-postgresql.1.5.1"
6970
"charInfo_width.1.1.0"
71+
"check_opam_switch.~dev"
7072
"cmdliner.1.0.3"
7173
"cohttp.5.0.0"
7274
"cohttp-async.5.0.0"
@@ -140,6 +142,7 @@ installed: [
140142
"merlin-extend.0.6.1"
141143
"mew.0.1.0"
142144
"mew_vi.0.5.0"
145+
"minicli.5.0.2"
143146
"mmap.1.1.0"
144147
"num.1.1"
145148
"ocaml.4.14.0"
@@ -161,7 +164,10 @@ installed: [
161164
"octavius.1.2.2"
162165
"odoc.2.1.0"
163166
"odoc-parser.1.0.0"
167+
"opam-core.2.1.2"
164168
"opam-depext.1.2.1"
169+
"opam-file-format.2.1.4"
170+
"opam-format.2.1.2"
165171
"parsexp.v0.14.2"
166172
"postgresql.5.0.0"
167173
"ppx_assert.v0.14.0"
@@ -241,8 +247,43 @@ installed: [
241247
"zed.3.1.0"
242248
]
243249
pinned: [
250+
"check_opam_switch.~dev"
244251
"graphql_ppx.1.2.2"
245252
]
253+
package "check_opam_switch" {
254+
opam-version: "2.0"
255+
version: "~dev"
256+
synopsis:
257+
"A tool to check that the current opam environment is up to date with an opam.export file"
258+
description:
259+
"A tool to check that the current opam environment is up to date with an opam.export file"
260+
maintainer: "[email protected]"
261+
depends: [
262+
"dune" {>= "3.3"}
263+
"opam-core" {>= "2.0.0"}
264+
"opam-format" {>= "2.0.0"}
265+
"minicli" {>= "5.0.0"}
266+
"odoc" {with-doc}
267+
]
268+
build: [
269+
["dune" "subst"] {dev}
270+
[
271+
"dune"
272+
"build"
273+
"-p"
274+
name
275+
"-j"
276+
jobs
277+
"@install"
278+
"@runtest" {with-test}
279+
"@doc" {with-doc}
280+
]
281+
]
282+
url {
283+
src: "https://github.com/tweag/check_opam_switch/archive/d0aa49884e0f9fd4bbb2cd1a32b798a12f84b603.tar.gz"
284+
checksum: "sha256=24ab29ea4aff9da9d649f0b577c5d4e27ce2bef51058e139965cc9be25494a46"
285+
}
286+
}
246287
package "graphql_ppx" {
247288
opam-version: "2.0"
248289
version: "1.2.2"

scripts/select-opam-deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -eou pipefail
88

99
RES=()
1010
for lib in $@; do
11-
RES+=($(cat src/opam.export | grep '"'"$lib"'\.' | awk -F'"' '{ print $2 }'))
11+
RES+=($(cat opam.export | grep '"'"$lib"'\.' | awk -F'"' '{ print $2 }'))
1212
done
1313

1414
echo "${RES[@]}"

0 commit comments

Comments
 (0)