Skip to content

Commit

Permalink
Allow users to select version of solc via kup (#105)
Browse files Browse the repository at this point in the history
* Allow users to select version of solc via kup install kontrol.solc_0_8_13

* Set Version: 0.1.28

* Set Version: 0.1.29

---------

Co-authored-by: devops <devops@runtimeverification.com>
  • Loading branch information
goodlyrottenapple and devops authored Oct 18, 2023
1 parent 879cf58 commit bf4f567
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 47 deletions.
97 changes: 53 additions & 44 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,69 @@
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
foundry.url =
"github:shazow/foundry.nix/monthly"; # Use monthly branch for permanent releases
solc = {
url = "github:hellwolf/solc.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, k-framework, nixpkgs, flake-utils
, poetry2nix, kevm
outputs = { self, k-framework, nixpkgs, flake-utils, poetry2nix, kevm
, rv-utils, pyk, foundry, solc }:
let
nixLibs = pkgs:
with pkgs;
"-I${procps}/include -L${procps}/lib -I${openssl.dev}/include -L${openssl.out}/lib";
overlay = final: prev: {
kontrol = prev.poetry2nix.mkPoetryApplication {
python = prev.python310;
projectDir = ./.;
overlay = final: prev:
let
kontrol = { solc_version ? null }:
(prev.poetry2nix.mkPoetryApplication {
python = prev.python310;
projectDir = ./.;

postPatch = ''
substituteInPlace ./src/kontrol/foundry.py \
--replace "'forge', 'build'," "'forge', 'build', '--no-auto-detect',"
substituteInPlace ./pyproject.toml \
--replace ', subdirectory = "kevm-pyk"' ""
'';
postPatch = ''
${prev.lib.strings.optionalString (solc_version != null) ''
substituteInPlace ./src/kontrol/foundry.py \
--replace "'forge', 'build'," "'forge', 'build', '--no-auto-detect',"
''}
substituteInPlace ./pyproject.toml \
--replace ', subdirectory = "kevm-pyk"' ""
'';

overrides = prev.poetry2nix.overrides.withDefaults
(finalPython: prevPython: {
pyk = prev.pyk-python310;
kevm-pyk = prev.kevm-pyk;
xdg-base-dirs = prevPython.xdg-base-dirs.overridePythonAttrs
(old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
++ [ finalPython.poetry ];
overrides = prev.poetry2nix.overrides.withDefaults
(finalPython: prevPython: {
pyk = prev.pyk-python310;
kevm-pyk = prev.kevm-pyk;
xdg-base-dirs = prevPython.xdg-base-dirs.overridePythonAttrs
(old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
++ [ finalPython.poetry ];
});
});
});
groups = [ ];
# We remove `"dev"` from `checkGroups`, so that poetry2nix does not try to resolve dev dependencies.
checkGroups = [ ];

postInstall = ''
wrapProgram $out/bin/kontrol --prefix PATH : ${
prev.lib.makeBinPath [
(solc.mkDefault final final.solc_0_8_13)
final.foundry-bin
prev.which
k-framework.packages.${prev.system}.k
]
} --set NIX_LIBS "${nixLibs prev}" --set KEVM_DIST_DIR ${prev.kevm k-framework.packages.${prev.system}.k}
'';
};
groups = [ ];
# We remove `"dev"` from `checkGroups`, so that poetry2nix does not try to resolve dev dependencies.
checkGroups = [ ];

};
postInstall = ''
wrapProgram $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 ${
prev.kevm k-framework.packages.${prev.system}.k
}
'';
}).overrideAttrs (old: {
passthru = old.passthru // (if solc_version == null then {
# list all supported solc versions here
solc_0_8_13 = kontrol { solc_version = final.solc_0_8_13; };
} else
{ });
});
in { inherit kontrol; };
in flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
Expand All @@ -74,9 +85,7 @@
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: {
llvm-backend-release = false;
})
(final: prev: { llvm-backend-release = false; })
k-framework.overlay
poetry2nix.overlay
pyk.overlay
Expand All @@ -87,9 +96,9 @@
];
};
in {
packages = {
inherit (pkgs) kontrol;
default = pkgs.kontrol;
packages = rec {
kontrol = pkgs.kontrol { };
default = self.kontrol;
};
}) // {
overlays.default = overlay;
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.28
0.1.29
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kontrol"
version = "0.1.28"
version = "0.1.29"
description = "Foundry integration for KEVM"
authors = [
"Runtime Verification, Inc. <contact@runtimeverification.com>",
Expand Down
2 changes: 1 addition & 1 deletion src/kontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
if TYPE_CHECKING:
from typing import Final

VERSION: Final = '0.1.28'
VERSION: Final = '0.1.29'

0 comments on commit bf4f567

Please sign in to comment.