Skip to content

Commit

Permalink
build(nix/balance-verifier): Use lib.fileset for defining pkg source
Browse files Browse the repository at this point in the history
  • Loading branch information
monyarm committed Jan 12, 2024
1 parent 9a2a056 commit b6c23c4
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 139 deletions.
2 changes: 1 addition & 1 deletion balance-verifier/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
yarn-deps = callPackage ../libs/nix/yarn-deps.nix {inherit fileset;};

get-balances-input = callPackage ../libs/nix/get_balances_input {inherit fileset;};
get-changed-validators = callPackage ../libs/nix/get_changed_validators {};
get-changed-validators = callPackage ../libs/nix/get_changed_validators {inherit fileset;};
misc-images =
writeScriptBin "misc-images"
(
Expand Down
85 changes: 49 additions & 36 deletions libs/nix/get_changed_validators/default.nix
Original file line number Diff line number Diff line change
@@ -1,42 +1,55 @@
{pkgs ? import <nixpkgs> {}}: let
project =
pkgs.callPackage ../../../yarn-project.nix {
nodejs = pkgs.nodejs-18_x;
} {
src = pkgs.lib.cleanSource ../../..;
overrideBcryptoAttrs = old: {
buildInputs = old.buildInputs ++ [pkgs.python3 pkgs.sqlite];
};
overrideBufferutilAttrs = old: {
buildInputs = old.buildInputs ++ [pkgs.python3 pkgs.sqlite];
};
overrideClassicLevelAttrs = old: {
buildInputs = old.buildInputs ++ [pkgs.python3 pkgs.sqlite];
};
overrideMsgpackrExtractAttrs = old: {
buildInputs = old.buildInputs ++ [pkgs.python3 pkgs.sqlite];
};
overrideUtf8ValidateAttrs = old: {
buildInputs = old.buildInputs ++ [pkgs.python3 pkgs.sqlite];
};
overrideLeveldownAttrs = old: {
buildInputs = old.buildInputs ++ [pkgs.python3 pkgs.sqlite];
};
overrideBcryptAttrs = old: {
buildInputs = old.buildInputs ++ [pkgs.python3 pkgs.sqlite];
};
overrideGetBalancesInputAttrs = old: {
buildInputs = old.buildInputs ++ [pkgs.python3 pkgs.sqlite];
};
};
{
pkgs ? import <nixpkgs> {},
fileset,
}: let
yarn-deps =
pkgs.callPackage ../yarn-deps.nix {inherit fileset;};
in
project.overrideAttrs (oldAttrs: {
pkgs.stdenv.mkDerivation {
name = "get-changed-validators";
buildInputs = oldAttrs.buildInputs ++ [pkgs.python3 pkgs.sqlite];
src = with fileset;
toSource {
root = ../../..;
fileset = unions [
(fileFilter (file: file.name == "package.json" || file.name == "tsconfig.json") ../../..)
../../../libs/typescript
(fileFilter (file: file.hasExt "ts" || file.hasExt "js") ../../..)
../../../beacon-light-client/plonky2/constants/validator_commitment_constants.json
../../../beacon-light-client/plonky2/mock_data
];
};
buildInputs = yarn-deps.buildInputs;
postUnpack = ''
dir="$(pwd)/source"
rm -rf "$dir/.yarn"
ln -s ${yarn-deps}/libexec/yarn-deps/.yarn "$dir"
ln -s ${yarn-deps}/libexec/yarn-deps/.pnp.cjs "$dir"
ln -s ${yarn-deps}/libexec/yarn-deps/.pnp.loader.mjs "$dir"
ln -s ${yarn-deps}/libexec/yarn-deps/.yarnrc.yml "$dir"
ln -s ${yarn-deps}/libexec/yarn-deps/yarn.lock "$dir"
cd "$dir/.."
'';
buildPhase = ''
yarn build-plonky-2
'';
postInstall = ''
installPhase = ''
mkdir -p $out/bin
cp -r beacon-light-client/plonky2/mock_data $out/bin'';
})
mkdir -p "$out/libexec/$name"
ln -s ${yarn-deps}/libexec/yarn-deps/.yarn "$out/libexec/$name"
# ln -s ${yarn-deps}/libexec/yarn-deps/.pnp.cjs "$out/libexec/$name"
# ln -s ${yarn-deps}/libexec/yarn-deps/.pnp.loader.mjs "$out/libexec/$name"
# cp yarn.lock .yarnrc.yml "$out/libexec/$name"
# find . -name "package.json" -or -name "tsconfig.json" -exec cp {} "$out/libexec/$name" \;
find -not -path "./.yarn/*" -prune -exec cp -r {} "$out/libexec/$name" \;
cp -r beacon-light-client/plonky2/mock_data $out/bin
cd "$out/libexec/$name"
# Invoke a plugin internal command to setup binaries.
yarn nixify install-bin $out/bin
'';
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"hardhat": "^2.10.2",
"hardhat-gas-reporter": "^1.0.8",
"ioredis": "^5.3.2",
"ms": "^2.1.3",
"prom-client": "^14.2.0",
"r1csfile": "^0.0.40",
"redis": "^4.6.5",
Expand Down
Loading

0 comments on commit b6c23c4

Please sign in to comment.