Skip to content

Commit

Permalink
Problem: don't support solc 0.8 (#1160)
Browse files Browse the repository at this point in the history
* Problem: don't support solc 0.8

Solution:
- support multiple solc in the nix shell

* avoid fork the repo
  • Loading branch information
yihuang authored Sep 11, 2023
1 parent 1f215fb commit ccc82fa
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 12 deletions.
6 changes: 5 additions & 1 deletion integration_tests/shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{ system ? builtins.currentSystem, pkgs ? import ../nix { inherit system; } }:
let
renameExe = pkgs.callPackage ../nix/rename-exe.nix { };
in
pkgs.mkShell {
buildInputs = [
pkgs.jq
Expand All @@ -13,7 +16,8 @@ pkgs.mkShell {
pkgs.nodejs
pkgs.git
pkgs.dapp
pkgs.solc-versions.solc_0_6_8
(renameExe pkgs.solc-static-versions.solc_0_6_8 "solc-0.6.8" "solc06")
(renameExe pkgs.solc-static-versions.solc_0_8_21 "solc-0.8.21" "solc08")
pkgs.test-env
pkgs.nixpkgs-fmt
pkgs.rocksdb
Expand Down
24 changes: 24 additions & 0 deletions nix/dapptools-overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ dapptools-release, dapptools-master }:
self: super:
let
dapptools = {
x86_64-linux =
(import (dapptools-release + "/release.nix") { }).dapphub.linux.stable;
x86_64-darwin =
(import (dapptools-release + "/release.nix") { }).dapphub.darwin.stable;
}.${self.system} or (throw
"Unsupported system: ${self.system}");
dapptools-patched = self.srcOnly {
name = "dapptools-patched";
src = dapptools-master;
patches = [
./dapptools.patch
];
};
in
{
# use released version to hit the binary cache
inherit (dapptools) dapp solc-versions;
# use the patched version to access solc-static-versions
inherit (import (dapptools-patched + "/overlay.nix") self super) solc-static-versions;
}
25 changes: 25 additions & 0 deletions nix/dapptools.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 455cfd7356c0a10d276e614304ed2b93b880257d Mon Sep 17 00:00:00 2001
From: HuangYi <[email protected]>
Date: Mon, 11 Sep 2023 14:50:08 +0800
Subject: [PATCH] fix solc-static on macos

---
nix/solc-static.nix | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nix/solc-static.nix b/nix/solc-static.nix
index 8ea194ea..e6945828 100644
--- a/nix/solc-static.nix
+++ b/nix/solc-static.nix
@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
sha256 = "${sha256}";
};

- nativeBuildInputs = [ autoPatchelfHook makeWrapper ];
+ nativeBuildInputs = [ makeWrapper ] ++ lib.optional stdenv.isLinux autoPatchelfHook;

postFixup = if (platform == "linux-amd64") then ''
wrapProgram $out/bin/solc-${version} \
--
2.39.2

12 changes: 1 addition & 11 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
{ sources ? import ./sources.nix, system ? builtins.currentSystem, ... }:

let
dapptools = {
x86_64-linux =
(import (sources.dapptools + "/release.nix") { }).dapphub.linux.stable;
x86_64-darwin =
(import (sources.dapptools + "/release.nix") { }).dapphub.darwin.stable;
}.${system} or (throw
"Unsupported system: ${system}");
in
import sources.nixpkgs {
overlays = [
(import ./build_overlay.nix)
(_: pkgs: dapptools) # use released version to hit the binary cache
(import ./dapptools-overlay.nix { dapptools-release = sources.dapptools; dapptools-master = sources.dapptools-master; })
(_: pkgs: {
go = pkgs.go_1_20;
go-ethereum = pkgs.callPackage ./go-ethereum.nix {
Expand Down
6 changes: 6 additions & 0 deletions nix/rename-exe.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ runCommandLocal }:
drv: oldName: newName:
runCommandLocal drv.name { } ''
mkdir -p $out/bin
ln -s ${drv}/bin/${oldName} $out/bin/${newName}
''
12 changes: 12 additions & 0 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
"url_template": "https://github.com/dapphub/dapptools/archive/refs/tags/hevm/0.49.0.tar.gz",
"version": "hevm/0.49.0"
},
"dapptools-master": {
"branch": "master",
"description": "Dapp, Seth, Hevm, and more",
"homepage": "https://dapp.tools",
"owner": "dapphub",
"repo": "dapptools",
"rev": "ba9fbcf95c01d247a30b26d7e064e8abdfba79db",
"sha256": "0kj726lmsdaljjm7wz3gpfs90h03h006z3w4fwcyan4bi5myi1k2",
"type": "tarball",
"url": "https://github.com/dapphub/dapptools/archive/ba9fbcf95c01d247a30b26d7e064e8abdfba79db.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"flake-compat": {
"branch": "master",
"description": null,
Expand Down

0 comments on commit ccc82fa

Please sign in to comment.