diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 000000000000..0db166fcbbbe --- /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 diff --git a/flake.lock b/flake.lock index 45ed6bb432ff..35fa2913ff88 100644 --- a/flake.lock +++ b/flake.lock @@ -1,30 +1,33 @@ { "nodes": { - "flake-utils": { + "fenix": { "inputs": { - "systems": "systems" + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "lastModified": 1746772806, + "narHash": "sha256-5/Nq62wjkZrOhUULTFjgi4Dsc7T8kIluUPkoLsyAeUA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "505bf684711e964c8f84d4c804e38f62b24accec", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "nix-community", + "repo": "fenix", "type": "github" } }, "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,80 +39,24 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay", - "solc": "solc" - } - }, - "rust-overlay": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1719714047, - "narHash": "sha256-MeNPopLLv63EZj5L43j4TZkmW4wj1ouoc/h/E20sl/U=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "cb216719ce89a43dfb3d1b86a9575e89f4b727a4", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "solc": { - "inputs": { - "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=", - "owner": "hellwolf", - "repo": "solc.nix", - "rev": "2ac2862f224aa0d67cbc6b3246392489f8a50596", - "type": "github" - }, - "original": { - "owner": "hellwolf", - "repo": "solc.nix", - "type": "github" + "fenix": "fenix", + "nixpkgs": "nixpkgs" } }, - "solc-macos-amd64-list-json": { + "rust-analyzer-src": { "flake": false, "locked": { - "narHash": "sha256-Prwz95BgMHcWd72VwVbcH17LsV9f24K2QMcUiWUQZzI=", - "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/f743ca7/macosx-amd64/list.json" - }, - "original": { - "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/f743ca7/macosx-amd64/list.json" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1746722075, + "narHash": "sha256-t4ZntWiW4C3lE621lV3XyK3KltC5/SW1V9G+CSz70rQ=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "8b624868e4ce2cb5b39559175f0978bee86bdeea", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", "type": "github" } } diff --git a/flake.nix b/flake.nix index ff783b4956e4..8cf41ed16d3a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,52 +1,45 @@ { 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"; - }; - }; - solc = { - url = "github:hellwolf/solc.nix"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - }; + fenix = { + url = "github:nix-community/fenix"; + 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 }: + let eachSystem = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; + in { + devShells = eachSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ fenix.overlays.default ]; + }; + + lib = pkgs.lib; + toolchain = fenix.packages.${system}.stable.toolchain; + in { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + pkg-config + toolchain + + # test dependencies + solc + vyper + nodejs + ]; + buildInputs = lib.optionals pkgs.stdenv.isDarwin + [ pkgs.darwin.apple_sdk.frameworks.AppKit ]; - # Environment variables - RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; - LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.libusb1 ]; - }; - }); + packages = with pkgs; [ rust-analyzer-unwrapped ]; + + # 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"; + }; + }); + }; }