From ed3439e027c2b222728bd4f01734722cc860aa92 Mon Sep 17 00:00:00 2001 From: Shaun Khundker Date: Fri, 9 May 2025 12:56:30 -0400 Subject: [PATCH 1/4] update flake --- flake.lock | 75 +++++++++++++++++++++++++++------------------- flake.nix | 87 +++++++++++++++++++++++++++++------------------------- 2 files changed, 91 insertions(+), 71 deletions(-) diff --git a/flake.lock b/flake.lock index 45ed6bb432ffb..c7aedf7d8ae6c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,15 +1,36 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1746772806, + "narHash": "sha256-5/Nq62wjkZrOhUULTFjgi4Dsc7T8kIluUPkoLsyAeUA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "505bf684711e964c8f84d4c804e38f62b24accec", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -20,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1719468428, - "narHash": "sha256-vN5xJAZ4UGREEglh3lfbbkIj+MPEYMuqewMn4atZFaQ=", + "lastModified": 1746576598, + "narHash": "sha256-FshoQvr6Aor5SnORVvh/ZdJ1Sa2U4ZrIMwKBX5k2wu0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1e3deb3d8a86a870d925760db1a5adecc64d329d", + "rev": "b3582c75c7f21ce0b429898980eddbbf05c68e55", "type": "github" }, "original": { @@ -36,48 +57,42 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", + "fenix": "fenix", "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay", "solc": "solc" } }, - "rust-overlay": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, + "rust-analyzer-src": { + "flake": false, "locked": { - "lastModified": 1719714047, - "narHash": "sha256-MeNPopLLv63EZj5L43j4TZkmW4wj1ouoc/h/E20sl/U=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "cb216719ce89a43dfb3d1b86a9575e89f4b727a4", + "lastModified": 1746722075, + "narHash": "sha256-t4ZntWiW4C3lE621lV3XyK3KltC5/SW1V9G+CSz70rQ=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "8b624868e4ce2cb5b39559175f0978bee86bdeea", "type": "github" }, "original": { - "owner": "oxalica", - "repo": "rust-overlay", + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", "type": "github" } }, "solc": { "inputs": { - "flake-utils": [ - "flake-utils" - ], + "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ], "solc-macos-amd64-list-json": "solc-macos-amd64-list-json" }, "locked": { - "lastModified": 1717442267, - "narHash": "sha256-6TnQvA6Q/xC3r1M+wGC5gnDc/5XfOPjC8X6LlGDWDNc=", + "lastModified": 1742758229, + "narHash": "sha256-FrU9rhab/0vOjjeFoQF+Ej43zRLv3enUIYjgLrH3Gd8=", "owner": "hellwolf", "repo": "solc.nix", - "rev": "2ac2862f224aa0d67cbc6b3246392489f8a50596", + "rev": "6885b61bac89da19a6e3c70b89fdd592e2cef884", "type": "github" }, "original": { @@ -89,13 +104,13 @@ "solc-macos-amd64-list-json": { "flake": false, "locked": { - "narHash": "sha256-Prwz95BgMHcWd72VwVbcH17LsV9f24K2QMcUiWUQZzI=", + "narHash": "sha256-U5ckttxwKO13gIKggel6iybG5oTDbSidPR5nH3Gs+kY=", "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/f743ca7/macosx-amd64/list.json" + "url": "https://github.com/ethereum/solc-bin/raw/30a3695/macosx-amd64/list.json" }, "original": { "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/f743ca7/macosx-amd64/list.json" + "url": "https://github.com/ethereum/solc-bin/raw/30a3695/macosx-amd64/list.json" } }, "systems": { diff --git a/flake.nix b/flake.nix index ff783b4956e4e..d4089ce574875 100644 --- a/flake.nix +++ b/flake.nix @@ -1,52 +1,57 @@ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs = { - nixpkgs.follows = "nixpkgs"; - }; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; }; solc = { url = "github:hellwolf/solc.nix"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - }; + inputs = { nixpkgs.follows = "nixpkgs"; }; }; }; - outputs = { self, nixpkgs, rust-overlay, flake-utils, solc }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = [ rust-overlay.overlays.default solc.overlay ]; - }; - lib = pkgs.lib; - toolchain = pkgs.rust-bin.stable.latest.default.override { - extensions = [ "rustfmt" "clippy" "rust-src" ]; - }; - in - { - devShells.default = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ - pkg-config - solc_0_8_23 - (solc.mkDefault pkgs solc_0_8_23) - toolchain - ]; - buildInputs = lib.optionals pkgs.stdenv.isDarwin [ - pkgs.darwin.apple_sdk.frameworks.AppKit - ]; - packages = with pkgs; [ - rust-analyzer-unwrapped - ]; + outputs = { self, nixpkgs, fenix, solc }: + let eachSystem = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; + in { + devShells = eachSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ fenix.overlays.default solc.overlay ]; + }; - # Environment variables - RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; - LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.libusb1 ]; - }; - }); + lib = pkgs.lib; + toolchain = fenix.packages.${system}.stable.toolchain; + in { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + pkg-config + solc_0_8_27 + # default for foundry's tests + (solc.mkDefault pkgs solc_0_8_27) + toolchain + ]; + buildInputs = lib.optionals pkgs.stdenv.isDarwin + [ pkgs.darwin.apple_sdk.frameworks.AppKit ]; + + packages = with pkgs; [ rust-analyzer-unwrapped ]; + + shellHook = '' + # Directly set CFLAGS to what we need. + # This will overwrite any CFLAGS inherited from the parent environment. + # -O2: Enable optimization (for _FORTIFY_SOURCE and jemalloc performance). + # -DJEMALLOC_STRERROR_R_RETURNS_CHAR_P: Hint for jemalloc's strerror_r usage. + export CFLAGS="-O2 -DJEMALLOC_STRERROR_R_RETURNS_CHAR_P" + + # Simple trim of whitespace + export CFLAGS=$(echo "$CFLAGS" | xargs) + ''; + + # Environment variables + RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; + LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.libusb1 ]; + }; + }); + }; } From 033f8b7c8ecc8515c2825814f045f8e8ff139a1a Mon Sep 17 00:00:00 2001 From: shaunkh <13260261+shaunkh@users.noreply.github.com> Date: Sat, 10 May 2025 10:02:19 -0400 Subject: [PATCH 2/4] update env variables --- flake.nix | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index d4089ce574875..063cc7b7de9bc 100644 --- a/flake.nix +++ b/flake.nix @@ -37,20 +37,10 @@ packages = with pkgs; [ rust-analyzer-unwrapped ]; - shellHook = '' - # Directly set CFLAGS to what we need. - # This will overwrite any CFLAGS inherited from the parent environment. - # -O2: Enable optimization (for _FORTIFY_SOURCE and jemalloc performance). - # -DJEMALLOC_STRERROR_R_RETURNS_CHAR_P: Hint for jemalloc's strerror_r usage. - export CFLAGS="-O2 -DJEMALLOC_STRERROR_R_RETURNS_CHAR_P" - - # Simple trim of whitespace - export CFLAGS=$(echo "$CFLAGS" | xargs) - ''; - # Environment variables RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.libusb1 ]; + CFLAGS = "-DJEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE"; }; }); }; From 6508d3f583a2a9011f057a26b0815914f607c080 Mon Sep 17 00:00:00 2001 From: zerosnacks Date: Tue, 13 May 2025 12:16:10 +0200 Subject: [PATCH 3/4] add nix.yml ci job Co-authored-by: sveitser --- .github/workflows/nix.yml | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/nix.yml diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000000000..0db166fcbbbe7 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,41 @@ +name: nix + +on: + schedule: + # Run weekly + - cron: "0 0 * * SUN" + workflow_dispatch: + # Needed so we can run it manually + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + # Opens a PR with an updated flake.lock file + update: + runs-on: ubuntu-latest + steps: + - uses: cachix/install-nix-action@v30 + - uses: actions/checkout@v4 + - uses: DeterminateSystems/update-flake-lock@main + with: + pr-title: "Update flake.lock" + pr-labels: | + L-ignore + A-dependencies + + build: + strategy: + matrix: + runs-on: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.runs-on }} + steps: + - uses: cachix/install-nix-action@v30 + - uses: actions/checkout@v4 + + - name: Activate nix env + run: nix develop -c echo Ok + + - name: Check that we can compile all crates + run: nix develop -c cargo check --all-targets From 68645bd1eb45ce2078c7969b23c253943e97f90d Mon Sep 17 00:00:00 2001 From: Shaun Khundker Date: Wed, 14 May 2025 17:04:48 -0400 Subject: [PATCH 4/4] review: use nixpkgs for solc --- flake.lock | 70 +----------------------------------------------------- flake.nix | 16 ++++++------- 2 files changed, 8 insertions(+), 78 deletions(-) diff --git a/flake.lock b/flake.lock index c7aedf7d8ae6c..35fa2913ff888 100644 --- a/flake.lock +++ b/flake.lock @@ -21,24 +21,6 @@ "type": "github" } }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1746576598, @@ -58,8 +40,7 @@ "root": { "inputs": { "fenix": "fenix", - "nixpkgs": "nixpkgs", - "solc": "solc" + "nixpkgs": "nixpkgs" } }, "rust-analyzer-src": { @@ -78,55 +59,6 @@ "repo": "rust-analyzer", "type": "github" } - }, - "solc": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": [ - "nixpkgs" - ], - "solc-macos-amd64-list-json": "solc-macos-amd64-list-json" - }, - "locked": { - "lastModified": 1742758229, - "narHash": "sha256-FrU9rhab/0vOjjeFoQF+Ej43zRLv3enUIYjgLrH3Gd8=", - "owner": "hellwolf", - "repo": "solc.nix", - "rev": "6885b61bac89da19a6e3c70b89fdd592e2cef884", - "type": "github" - }, - "original": { - "owner": "hellwolf", - "repo": "solc.nix", - "type": "github" - } - }, - "solc-macos-amd64-list-json": { - "flake": false, - "locked": { - "narHash": "sha256-U5ckttxwKO13gIKggel6iybG5oTDbSidPR5nH3Gs+kY=", - "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/30a3695/macosx-amd64/list.json" - }, - "original": { - "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/30a3695/macosx-amd64/list.json" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 063cc7b7de9bc..8cf41ed16d3a3 100644 --- a/flake.nix +++ b/flake.nix @@ -5,20 +5,16 @@ url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; - solc = { - url = "github:hellwolf/solc.nix"; - inputs = { nixpkgs.follows = "nixpkgs"; }; - }; }; - outputs = { self, nixpkgs, fenix, solc }: + outputs = { self, nixpkgs, fenix }: let eachSystem = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; in { devShells = eachSystem (system: let pkgs = import nixpkgs { inherit system; - overlays = [ fenix.overlays.default solc.overlay ]; + overlays = [ fenix.overlays.default ]; }; lib = pkgs.lib; @@ -27,10 +23,12 @@ default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ pkg-config - solc_0_8_27 - # default for foundry's tests - (solc.mkDefault pkgs solc_0_8_27) toolchain + + # test dependencies + solc + vyper + nodejs ]; buildInputs = lib.optionals pkgs.stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.AppKit ];