Skip to content

Commit

Permalink
Merge pull request #15454 from MinaProtocol/georgeee/update-nix-berke…
Browse files Browse the repository at this point in the history
…ley-migration-to-develop

[Develop] Update nix berkeley migration
  • Loading branch information
georgeee authored Apr 3, 2024
2 parents 3cabf66 + bb814f0 commit b5911de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 47 deletions.
17 changes: 13 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,25 @@
- use "${ref "git+https://github.com/minaprotocol/mina?submodules=1"}";
- use non-flake commands like ${command "nix-build"} and ${command "nix-shell"}.
'';
# Only get the ocaml stuff, to reduce the amount of unnecessary rebuilds
ocaml-src =
with inputs.nix-filter.lib;
filter {
root = ./.;
include =
[ (inDirectory "src") "dune" "dune-project"
"./graphql_schema.json" "opam.export" ];
};
in {
overlays = {
misc = import ./nix/misc.nix;
rust = import ./nix/rust.nix;
go = import ./nix/go.nix;
javascript = import ./nix/javascript.nix;
ocaml = final: prev: {
ocaml = pkgs: prev: {
ocamlPackages_mina = requireSubmodules (import ./nix/ocaml.nix {
inherit inputs;
pkgs = final;
inherit inputs pkgs;
src = ocaml-src;
});
};
};
Expand Down Expand Up @@ -288,7 +297,7 @@
# Main user-facing binaries.
packages = rec {
inherit (ocamlPackages)
mina berkeley-migration devnet mainnet mina_tests mina-ocaml-format mina_client_sdk test_executive with-instrumentation;
mina devnet mainnet mina_tests mina-ocaml-format mina_client_sdk test_executive with-instrumentation;
inherit (pkgs)
libp2p_helper kimchi_bindings_stubs snarky_js leaderboard
validation trace-tool zkapp-cli;
Expand Down
56 changes: 13 additions & 43 deletions nix/ocaml.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# A set defining OCaml parts&dependencies of Minaocamlnix
{ inputs, ... }@args:
{ inputs, src, ... }@args:
let
opam-nix = inputs.opam-nix.lib.${pkgs.system};

Expand All @@ -12,10 +12,10 @@ let
escapeShellArg;

external-repo =
opam-nix.makeOpamRepoRec ../src/external; # Pin external packages
opam-nix.makeOpamRepoRec "${src}/src/external"; # Pin external packages
repos = [ external-repo inputs.opam-repository ];

export = opam-nix.importOpam ../opam.export;
export = opam-nix.importOpam "${src}/opam.export";
external-packages = pkgs.lib.getAttrs [ "sodium" "base58" ]
(builtins.mapAttrs (_: pkgs.lib.last) (opam-nix.listRepo external-repo));

Expand Down Expand Up @@ -61,14 +61,6 @@ let
[ zlib bzip2 gmp openssl libffi ]
++ lib.optional (!(stdenv.isDarwin && stdenv.isAarch64)) jemalloc;

# Only get the ocaml stuff, to reduce the amount of unnecessary rebuilds
filtered-src = with inputs.nix-filter.lib;
filter {
root = ../.;
include =
[ (inDirectory "src") "dune" "dune-project" "./graphql_schema.json" ];
};

overlay = self: super:
let
ocaml-libs = builtins.attrValues (getAttrs installedPackageNames self);
Expand Down Expand Up @@ -137,7 +129,7 @@ let
pname = "mina";
version = "dev";
# Prevent unnecessary rebuilds on non-source changes
src = filtered-src;
inherit src;

withFakeOpam = false;

Expand Down Expand Up @@ -206,7 +198,9 @@ let
src/app/missing_blocks_auditor/missing_blocks_auditor.exe \
src/app/replayer/replayer.exe \
src/app/swap_bad_balances/swap_bad_balances.exe \
src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe
src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe \
src/app/berkeley_migration/berkeley_migration.exe \
src/app/berkeley_migration_verifier/berkeley_migration_verifier.exe
# TODO figure out purpose of the line below
# dune exec src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe -- --genesis-dir _build/coda_cache_dir
# Building documentation fails, because not everything in the source tree compiles. Ignore the errors.
Expand All @@ -222,10 +216,11 @@ let
"genesis"
"sample"
"batch_txn_tool"
"berkeley_migration"
];

installPhase = ''
mkdir -p $out/bin $archive/bin $sample/share/mina $out/share/doc $generate_keypair/bin $mainnet/bin $testnet/bin $genesis/bin $genesis/var/lib/coda $batch_txn_tool/bin
mkdir -p $out/bin $archive/bin $sample/share/mina $out/share/doc $generate_keypair/bin $mainnet/bin $testnet/bin $genesis/bin $genesis/var/lib/coda $batch_txn_tool/bin $berkeley_migration/bin
# TODO uncomment when genesis is generated above
# mv _build/coda_cache_dir/genesis* $genesis/var/lib/coda
pushd _build/default
Expand All @@ -244,6 +239,10 @@ let
cp src/app/archive_blocks/archive_blocks.exe $archive/bin/mina-archive-blocks
cp src/app/missing_blocks_auditor/missing_blocks_auditor.exe $archive/bin/mina-missing-blocks-auditor
cp src/app/replayer/replayer.exe $archive/bin/mina-replayer
cp src/app/replayer/replayer.exe $berkeley_migration/bin/mina-migration-replayer
cp src/app/berkeley_migration/berkeley_migration.exe $berkeley_migration/bin/mina-berkeley-migration
cp src/app/berkeley_migration_verifier/berkeley_migration_verifier.exe $berkeley_migration/bin/mina-berkeley-migration-verifier
cp ${../scripts/archive/migration/mina-berkeley-migration-script} $berkeley_migration/bin/mina-berkeley-migration-script
cp src/app/swap_bad_balances/swap_bad_balances.exe $archive/bin/mina-swap-bad-balances
cp -R _doc/_html $out/share/doc/html
# cp src/lib/mina_base/sample_keypairs.json $sample/share/mina
Expand Down Expand Up @@ -293,35 +292,6 @@ let

devnet = wrapMina self.devnet-pkg { };

berkeley-migration-pkg = self.mina-dev.overrideAttrs (s: {
pname = "mina-berkeley-migration";
version = "mainnet";
DUNE_PROFILE = "berkeley_archive_migration";
# For compatibility with Docker build
MINA_ROCKSDB = "${pkgs.rocksdb511}/lib/librocksdb.a";
buildPhase = ''
dune build --display=short \
src/app/berkeley_migration/berkeley_migration.exe \
src/app/berkeley_migration_verifier/berkeley_migration_verifier.exe \
src/app/replayer/replayer.exe
'';

outputs = [ "out" ];

installPhase = ''
mkdir -p $out/bin
pushd _build/default
cp src/app/berkeley_migration/berkeley_migration.exe $out/bin/mina-berkeley-migration
cp src/app/berkeley_migration_verifier/berkeley_migration_verifier.exe $out/bin/mina-berkeley-migration-verifier
cp src/app/replayer/replayer.exe $out/bin/mina-migration-replayer
popd
remove-references-to -t $(dirname $(dirname $(command -v ocaml))) $out/bin/*
'';
shellHook = "";
});

berkeley-migration = wrapMina self.berkeley-migration-pkg { };

# Unit tests
mina_tests = runMinaCheck {
name = "tests";
Expand Down

0 comments on commit b5911de

Please sign in to comment.