From a9d9c08a64c266b6116ddd0ffe938097c96cc59c Mon Sep 17 00:00:00 2001 From: Sam Balco Date: Tue, 31 Oct 2023 10:47:00 +0000 Subject: [PATCH] fix flake --- flake.lock | 133 +++++++++-------------------------------------------- flake.nix | 83 +++++++++++++++++---------------- 2 files changed, 66 insertions(+), 150 deletions(-) diff --git a/flake.lock b/flake.lock index 137db55dc..63cf428ff 100644 --- a/flake.lock +++ b/flake.lock @@ -171,21 +171,6 @@ } }, "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" - } - }, - "flake-utils_2": { "inputs": { "systems": "systems" }, @@ -203,7 +188,7 @@ "type": "github" } }, - "flake-utils_3": { + "flake-utils_2": { "inputs": { "systems": "systems_2" }, @@ -221,21 +206,6 @@ "type": "github" } }, - "flake-utils_4": { - "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "fmt-src": { "flake": false, "locked": { @@ -254,26 +224,6 @@ } }, "foundry": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1696410815, - "narHash": "sha256-uku47D/L+VzO3sVoZbnexPQPGeQtMwMFBesyaA1vKtE=", - "owner": "shazow", - "repo": "foundry.nix", - "rev": "a56126a754d73f85d904768fed569a9e250388d9", - "type": "github" - }, - "original": { - "owner": "shazow", - "ref": "monthly", - "repo": "foundry.nix", - "type": "github" - } - }, - "foundry_2": { "inputs": { "flake-utils": [ "kevm", @@ -303,7 +253,7 @@ }, "haskell-backend": { "inputs": { - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", "stacklock2nix": "stacklock2nix", "z3": "z3" }, @@ -343,7 +293,7 @@ "inputs": { "booster-backend": "booster-backend", "flake-compat": "flake-compat", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "haskell-backend": "haskell-backend", "llvm-backend": "llvm-backend", "mavenix": "mavenix", @@ -380,7 +330,7 @@ "k-framework", "flake-utils" ], - "foundry": "foundry_2", + "foundry": "foundry", "haskell-backend": [ "kevm", "k-framework", @@ -531,20 +481,6 @@ } }, "nixpkgs": { - "locked": { - "lastModified": 1666753130, - "narHash": "sha256-Wff1dGPFSneXJLI2c0kkdWTgxnQ416KE6X4KnFkgPYQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f540aeda6f677354f1e7144ab04352f61aaa0118", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { "locked": { "lastModified": 1696983906, "narHash": "sha256-L7GyeErguS7Pg4h8nK0wGlcUTbfUMDu+HMf1UcyP72k=", @@ -559,7 +495,7 @@ "type": "indirect" } }, - "nixpkgs_3": { + "nixpkgs_2": { "locked": { "lastModified": 1698675399, "narHash": "sha256-nj+LNEeVXGP31vxoL3x7HW7+oEiyoLVDqwMg30yFBMA=", @@ -576,7 +512,7 @@ }, "poetry2nix": { "inputs": { - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_2", "nix-github-actions": "nix-github-actions", "nixpkgs": [ "kevm", @@ -626,7 +562,7 @@ "poetry2nix", "flake-utils" ], - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_2", "poetry2nix": "poetry2nix" }, "locked": { @@ -667,7 +603,10 @@ "kevm", "flake-utils" ], - "foundry": "foundry", + "foundry": [ + "kevm", + "foundry" + ], "k-framework": [ "kevm", "k-framework" @@ -677,6 +616,10 @@ "kevm", "nixpkgs" ], + "nixpkgs-pyk": [ + "kevm", + "nixpkgs-pyk" + ], "poetry2nix": [ "kevm", "poetry2nix" @@ -685,8 +628,14 @@ "kevm", "pyk" ], - "rv-utils": "rv-utils_2", - "solc": "solc_2" + "rv-utils": [ + "kevm", + "rv-utils" + ], + "solc": [ + "kevm", + "solc" + ] } }, "rv-utils": { @@ -704,21 +653,6 @@ "type": "github" } }, - "rv-utils_2": { - "locked": { - "lastModified": 1659349707, - "narHash": "sha256-+RwJvYwRS4In+pl8R5Uz+R/yZ5yO5SAa7X6UR+eSC2U=", - "owner": "runtimeverification", - "repo": "rv-nix-tools", - "rev": "7026604726c5247ceb6e7a1a7532302a58e7e2bf", - "type": "github" - }, - "original": { - "owner": "runtimeverification", - "repo": "rv-nix-tools", - "type": "github" - } - }, "secp256k1": { "flake": false, "locked": { @@ -763,27 +697,6 @@ "type": "github" } }, - "solc_2": { - "inputs": { - "flake-utils": "flake-utils_4", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1692871473, - "narHash": "sha256-2eLQOPBzQomQfcC8wQdYekccvl1KtYCqkDdw7oPeOiU=", - "owner": "hellwolf", - "repo": "solc.nix", - "rev": "fbbe5553a7fc52f2d423afac81316023a183e72c", - "type": "github" - }, - "original": { - "owner": "hellwolf", - "repo": "solc.nix", - "type": "github" - } - }, "stacklock2nix": { "locked": { "lastModified": 1696895532, diff --git a/flake.nix b/flake.nix index 69d8059a4..f504f18c2 100644 --- a/flake.nix +++ b/flake.nix @@ -4,32 +4,33 @@ inputs = { kevm.url = "github:runtimeverification/evm-semantics/v1.0.332"; nixpkgs.follows = "kevm/nixpkgs"; + nixpkgs-pyk.follows = "kevm/nixpkgs-pyk"; k-framework.follows = "kevm/k-framework"; - k-framework.inputs.nixpkgs.follows = "nixpkgs"; flake-utils.follows = "kevm/flake-utils"; - rv-utils.url = "github:runtimeverification/rv-nix-tools"; + rv-utils.follows = "kevm/rv-utils"; pyk.follows = "kevm/pyk"; - pyk.inputs.flake-utils.follows = "k-framework/flake-utils"; - pyk.inputs.nixpkgs.follows = "k-framework/nixpkgs"; poetry2nix.follows = "kevm/poetry2nix"; - foundry.url = - "github:shazow/foundry.nix/monthly"; # Use monthly branch for permanent releases - solc = { - url = "github:hellwolf/solc.nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + foundry.follows = "kevm/foundry"; + solc.follows = "kevm/solc"; }; outputs = { self, k-framework, nixpkgs, flake-utils, poetry2nix, kevm - , rv-utils, pyk, foundry, solc }: + , rv-utils, pyk, foundry, solc, ... }@inputs: let nixLibs = pkgs: with pkgs; "-I${procps}/include -L${procps}/lib -I${openssl.dev}/include -L${openssl.out}/lib"; overlay = final: prev: let + nixpkgs-pyk = import inputs.nixpkgs-pyk { + system = prev.system; + overlays = [ pyk.overlay ]; + }; + poetry2nix = + inputs.poetry2nix.lib.mkPoetry2Nix { pkgs = nixpkgs-pyk; }; + kontrol-pyk = { solc_version ? null }: - (prev.poetry2nix.mkPoetryApplication { - python = prev.python310; + (poetry2nix.mkPoetryApplication { + python = nixpkgs-pyk.python310; projectDir = ./.; postPatch = '' @@ -41,9 +42,9 @@ --replace ', subdirectory = "kevm-pyk"' "" ''; - overrides = prev.poetry2nix.overrides.withDefaults + overrides = poetry2nix.overrides.withDefaults (finalPython: prevPython: { - pyk = prev.pyk-python310; + pyk = nixpkgs-pyk.pyk-python310; kevm-pyk = prev.kevm-pyk; xdg-base-dirs = prevPython.xdg-base-dirs.overridePythonAttrs (old: { @@ -64,9 +65,15 @@ autoconf automake cmake - (kevm-pyk.overridePythonAttrs (old: { + # This is somewhat hacky but it's only a build time dependency. + # We basically override kevm-pyk to add kontrol as a runtime dependency + # so that kevm-dist finds the foundryx target. + (prev.kevm-pyk.overridePythonAttrs (old: { propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) - ++ [ (kontrol-pyk { inherit solc_version; }) ]; + ++ [ + ((kontrol-pyk { inherit solc_version; }).overrideAttrs + (oldAttrs: { propagatedBuildInputs = [ ]; })) + ]; })) k-framework.packages.${prev.system}.k libtool @@ -89,27 +96,25 @@ } kevm-dist build -j4 foundryx ''; - installPhase = - let kevm = prev.kevm k-framework.packages.${prev.system}.k; - in '' - mkdir -p $out - cp -r ./kdist-*/* $out/ - ln -s ${kevm}/haskell $out/haskell - ln -s ${kevm}/haskell-standalone $out/haskell-standalone - ln -s ${kevm}/llvm $out/llvm - ln -s ${kevm}/plugin $out/plugin - mkdir -p $out/bin - makeWrapper ${ - (kontrol-pyk { inherit solc_version; }) - }/bin/kontrol $out/bin/kontrol --prefix PATH : ${ - prev.lib.makeBinPath - ([ prev.which k-framework.packages.${prev.system}.k ] - ++ prev.lib.optionals (solc_version != null) [ - final.foundry-bin - (solc.mkDefault final solc_version) - ]) - } --set NIX_LIBS "${nixLibs prev}" --set KEVM_DIST_DIR $out - ''; + installPhase = '' + mkdir -p $out + cp -r ./kdist-*/* $out/ + ln -s ${prev.kevm}/haskell $out/haskell + ln -s ${prev.kevm}/haskell-standalone $out/haskell-standalone + ln -s ${prev.kevm}/llvm $out/llvm + ln -s ${prev.kevm}/plugin $out/plugin + mkdir -p $out/bin + makeWrapper ${ + (kontrol-pyk { inherit solc_version; }) + }/bin/kontrol $out/bin/kontrol --prefix PATH : ${ + prev.lib.makeBinPath + ([ prev.which k-framework.packages.${prev.system}.k ] + ++ prev.lib.optionals (solc_version != null) [ + final.foundry-bin + (solc.mkDefault final solc_version) + ]) + } --set NIX_LIBS "${nixLibs prev}" --set KEVM_DIST_DIR $out + ''; passthru = if solc_version == null then { # list all supported solc versions here @@ -130,8 +135,6 @@ overlays = [ (final: prev: { llvm-backend-release = false; }) k-framework.overlay - poetry2nix.overlay - pyk.overlay foundry.overlay solc.overlay kevm.overlays.default