From b81a92ee0edde192068d2112272b7dabec95f9dc Mon Sep 17 00:00:00 2001 From: Mathis Antony Date: Fri, 19 Jul 2024 11:04:17 +0200 Subject: [PATCH] Add flake for contract development - Works for `yarn install`, `yarn build:all`, `forg test` - The command `yarn test` fails with 1) ArbRollupFastConfirm should initialize: Error: missing argument: in Contract constructor (count=0, expectedCount=1, code=MISSING_ARGUMENT, version=contracts/5.7.0) --- flake.lock | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 39 +++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..175b9937 --- /dev/null +++ b/flake.lock @@ -0,0 +1,111 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "foundry": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1719997877, + "narHash": "sha256-/Edw+w0PiGgxwnCeJycM0VgH4HtlCi91v1d8xbi+REE=", + "owner": "shazow", + "repo": "foundry.nix", + "rev": "02febba4f1cf0606d790acdb24adcf7a64afb4e1", + "type": "github" + }, + "original": { + "owner": "shazow", + "ref": "monthly", + "repo": "foundry.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1666753130, + "narHash": "sha256-Wff1dGPFSneXJLI2c0kkdWTgxnQ416KE6X4KnFkgPYQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f540aeda6f677354f1e7144ab04352f61aaa0118", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1721303309, + "narHash": "sha256-/+Yw4tW/mcTRKmkEAO64ObzCQClpSUZpk2flUD9GDHE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7e2fb8e0eb807e139d42b05bf8e28da122396bed", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "foundry": "foundry", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..f999c165 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.utils.url = "github:numtide/flake-utils"; + inputs.foundry.url = "github:shazow/foundry.nix/monthly"; # Use monthly branch for permanent releases + + outputs = { self, nixpkgs, utils, foundry }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs + { + inherit system; + overlays = [ + foundry.overlay + (final: prev: { + # Overlaying nodejs here to ensure nodePackages use the desired + # version of nodejs use by the upstream CI. + nodejs = prev.nodejs-18_x; + pnpm = prev.nodePackages.pnpm; + yarn = prev.nodePackages.yarn; + }) + ]; + }; + in + { + devShells.default = with pkgs; mkShell { + buildInputs = [ + foundry-bin + nodejs + yarn + ]; + shellHook = '' + # Add node executables (incl. hardhat) to PATH + export PATH=$PWD/node_modules/.bin:$PATH + ''; + + }; + + }); +}