diff --git a/flake.lock b/flake.lock index fc545ab1e..a44f65c89 100644 --- a/flake.lock +++ b/flake.lock @@ -21,11 +21,29 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -52,11 +70,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1720368505, - "narHash": "sha256-5r0pInVo5d6Enti0YwUSQK4TebITypB42bWy5su3MrQ=", + "lastModified": 1726436956, + "narHash": "sha256-a3rP7uafX/qBFX0y4CGS8vvTPvxsLl9eZQ85DkIn3DI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ab82a9612aa45284d4adf69ee81871a389669a9e", + "rev": "039b72d0c738c934e2e36d7fc5520d1b425287a6", "type": "github" }, "original": { @@ -71,7 +89,42 @@ "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nix-bundle-exe": "nix-bundle-exe", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "solc-pkgs": "solc-pkgs" + } + }, + "solc-macos-amd64-list-json": { + "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" + } + }, + "solc-pkgs": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ], + "solc-macos-amd64-list-json": "solc-macos-amd64-list-json" + }, + "locked": { + "lastModified": 1724145339, + "narHash": "sha256-z8pLkpdsAA0At1ofQd6KNmrxpBuUT9OKTlCDqJDW1GI=", + "owner": "hellwolf", + "repo": "solc.nix", + "rev": "9630767051bfefd552c6858c5df141368338b077", + "type": "github" + }, + "original": { + "owner": "hellwolf", + "repo": "solc.nix", + "type": "github" } }, "systems": { @@ -88,6 +141,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "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 ffb58bcc1..50d6460cc 100644 --- a/flake.nix +++ b/flake.nix @@ -10,36 +10,25 @@ url = "github:3noch/nix-bundle-exe"; flake = false; }; + solc-pkgs = { + url = "github:hellwolf/solc.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, flake-utils, nix-bundle-exe, ... }: + outputs = { self, nixpkgs, flake-utils, nix-bundle-exe, solc-pkgs, ... }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = import nixpkgs { + inherit system; + overlays = [solc-pkgs.overlay]; + }; + # prefer musl on Linux, static glibc + threading does not work properly # TODO: maybe only override it for echidna-redistributable? pkgsStatic = if pkgs.stdenv.hostPlatform.isLinux then pkgs.pkgsStatic else pkgs; # this is not perfect for development as it hardcodes solc to 0.5.7, test suite runs fine though - # would be great to integrate solc-select to be more flexible, improve this in future - solc = pkgs.stdenv.mkDerivation { - name = "solc"; - src = if pkgs.stdenv.isDarwin then - pkgs.fetchurl { - url = "https://binaries.soliditylang.org/macosx-amd64/solc-macosx-amd64-v0.5.7+commit.6da8b019"; - sha256 = "095mlw5x9lpdcdl9jzlvkvw46ag03xr4nj4vly4hgn92rgivimm7"; - } - else - pkgs.fetchurl { - url = "https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.5.7+commit.6da8b019"; - sha256 = "0dsvzck5jh8rvdxs7zyn2ga9hif024msx8gr8ifgj4cmyb7m4341"; - }; - phases = ["installPhase" "patchPhase"]; - installPhase = '' - mkdir -p $out/bin - cp $src $out/bin/solc - chmod +x $out/bin/solc - ''; - }; + solc = solc-pkgs.mkDefault pkgs pkgs.solc_0_5_7; secp256k1-static = pkgsStatic.secp256k1.overrideAttrs (attrs: { configureFlags = attrs.configureFlags ++ [ "--enable-static" ]; @@ -57,25 +46,14 @@ }; }; - cc-workaround-nix-23138 = - pkgs.writeScriptBin "cc-workaround-nix-23138" '' - if [ "$1" = "--print-file-name" ] && [ "$2" = "c++" ]; then - echo c++ - else - exec cc "$@" - fi - ''; - hevm = pkgs: pkgs.lib.pipe ((hsPkgs pkgs).callCabal2nix "hevm" (pkgs.fetchFromGitHub { - owner = "ethereum"; - repo = "hevm"; - rev = "c779777d18c8ff60867f009d434b44ce08188e01"; - sha256 = "sha256-JnJUZ9AxhxTP+TBMThksh0D4R6KFdzjgu1+fBeBERws="; + owner = "ethereum"; + repo = "hevm"; + rev = "c779777d18c8ff60867f009d434b44ce08188e01"; + sha256 = "sha256-JnJUZ9AxhxTP+TBMThksh0D4R6KFdzjgu1+fBeBERws="; }) { secp256k1 = pkgs.secp256k1; }) ([ pkgs.haskell.lib.compose.dontCheck - ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ - (pkgs.haskell.lib.compose.appendConfigureFlag "--ghc-options=-pgml=${cc-workaround-nix-23138}/bin/cc-workaround-nix-23138") ]); echidna = pkgs: with pkgs; lib.pipe @@ -86,8 +64,6 @@ haskell.lib.compose.dontCheck (haskell.lib.compose.addTestToolDepends [ haskellPackages.hpack slither-analyzer solc ]) (haskell.lib.compose.disableCabalFlag "static") - ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ - (pkgs.haskell.lib.compose.appendConfigureFlag "--ghc-options=-pgml=${cc-workaround-nix-23138}/bin/cc-workaround-nix-23138") ]); echidna-static = with pkgsStatic; lib.pipe @@ -173,9 +149,7 @@ packages = _: [ (echidna pkgs) ]; shellHook = '' hpack - '' + (if pkgs.stdenv.isDarwin then '' - cabal configure --ghc-options=-pgml=${cc-workaround-nix-23138}/bin/cc-workaround-nix-23138 - '' else ""); + ''; buildInputs = [ solc slither-analyzer diff --git a/stack.yaml b/stack.yaml index a6e9495b6..15fa8406f 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-22.19 +resolver: lts-22.34 packages: - '.'