Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e770fab
Update GHC to 9.6
arcz Mar 7, 2024
bbedb1b
Ignore failing yul optimizer tests
arcz Mar 13, 2024
db8bddf
Bump nixpkgs
arcz Mar 18, 2024
6b4cfef
Fix static binaries
arcz Mar 21, 2024
161a3ac
Fix tests
arcz Mar 21, 2024
0b744ce
Bump nixpkgs
arcz May 30, 2024
fbda341
flake: bump nixpkgs, use dynaimc binary in devShell
d-xo Jul 8, 2024
17f706c
Merge remote-tracking branch 'origin/main' into ghc-9.6-v2
d-xo Jul 8, 2024
0de509f
Workaround for a possible bug in GHC
blishko Jul 8, 2024
da17d9b
Test: Remove copying of a directory that no longer exists
blishko Jul 9, 2024
8f70949
Nix: Add a new develop shell for MacOS
blishko Jul 9, 2024
a09dcb9
GitHub actions: Fix expected version of libsecp256k1
blishko Jul 9, 2024
7d0dc85
flake: use pkgsStatic on linux
d-xo Jul 9, 2024
9428a20
flake: warnings as errors in nix build
d-xo Jul 9, 2024
f445333
fixup cabal file
d-xo Jul 9, 2024
459495b
flake: use latest with-utf8
d-xo Jul 9, 2024
97a535e
flake: use monthly foundry
d-xo Jul 9, 2024
1b8bc40
flake: rollback to match foundry version on main
d-xo Jul 9, 2024
342cf20
flake: nix keeps updating this in flake.lock for some reason
d-xo Jul 9, 2024
8f57a76
flake: build cabal-install v3.12
d-xo Jul 12, 2024
c990bbb
flake: rm update to with-utf8
d-xo Jul 12, 2024
ee3a532
flake: workaround ghc / macos / nixpkgs / cc bug
d-xo Jul 12, 2024
93a37d4
flake: fix typo
d-xo Jul 12, 2024
2c21f94
cabal: add missing autogen-moduels field
d-xo Jul 12, 2024
2f04a93
ci: cabal shouldn't look for upstream repos
d-xo Jul 12, 2024
396247c
flake: try adding libiconv as a dep to with-utf8 on darwin
d-xo Jul 12, 2024
e769fff
flake: actually apply with-utf8 override
d-xo Jul 12, 2024
9a61a60
flake: trying libiconv override again
d-xo Jul 12, 2024
644a264
ci: run cabal update in shell jobs
d-xo Jul 12, 2024
3827486
flake: add x86 check to with-utf8
d-xo Jul 14, 2024
13e1254
Make CVC5 default
msooseth Jul 19, 2024
3989a1d
Let's ignore this one test
msooseth Jul 19, 2024
33fb289
Fixing up moving to CVC5
msooseth Jul 19, 2024
0d31359
Just one more ignoreTest
msooseth Jul 19, 2024
d477376
Making tests run on Linux, too -- thanks to Emilio Lopez
msooseth Jul 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/install-libsecp256k1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eux -o pipefail

## The following script builds and installs libsecp256k1 to ~/.local/lib

INSTALL_VERSION=0.3.2
INSTALL_VERSION=0.5.0

if [[ "$(uname -s)" =~ ^MSYS_NT.* ]]; then
echo "This script is only meant to run on Windows under MSYS2"
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ jobs:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
# cabal complains if we don't do this...
- name: cabal update
run: nix-shell --pure --command "cabal update"
# can't be run in nix build due to network usage
- name: run rpc tests
run: nix-shell --pure --command "cabal run rpc-tests"
run: nix-shell --pure --command "cabal --active-repositories=:none run rpc-tests"
# if we run this in nix build we often get killed due to oom in ci
- name: run ethereum tests
run: nix-shell --pure --command "cabal run ethereum-tests"
run: nix-shell --pure --command "cabal --active-repositories=:none run ethereum-tests"

build-windows:
name: build (windows-latest)
Expand Down
54 changes: 19 additions & 35 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

183 changes: 91 additions & 92 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
foundry.url = "github:shazow/foundry.nix/monthly";
bitwuzla-pkgs.url = "github:d-xo/nixpkgs/94e802bce3a1bc05b3acfc5e876de15fd2ecb564";
# TODO: we are broken with latest foundry
foundry.url = "github:shazow/foundry.nix/6089aad0ef615ac8c7b0c948d6052fa848c99523";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
Expand All @@ -18,8 +18,8 @@
url = "github:ethereum/tests/v12.2";
flake = false;
};
cabal-head = {
url = "github:haskell/cabal";
cabal-3-12 = {
url = "github:haskell/cabal?ref=Cabal-v3.12.1.0";
flake = false;
};
forge-std = {
Expand All @@ -32,15 +32,14 @@
};
};

outputs = { self, nixpkgs, flake-utils, solidity, forge-std, ethereum-tests, foundry, cabal-head, bitwuzla-pkgs, solc-pkgs, ... }:
outputs = { self, nixpkgs, flake-utils, solidity, forge-std, ethereum-tests, foundry, cabal-3-12, solc-pkgs, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs {
inherit system;
overlays = [solc-pkgs.overlay];
config = { allowBroken = true; };
});
bitwuzla = (import bitwuzla-pkgs { inherit system; }).bitwuzla;
solc = (solc-pkgs.mkDefault pkgs pkgs.solc_0_8_24);
testDeps = with pkgs; [
go-ethereum
Expand All @@ -52,83 +51,84 @@
foundry.defaultPackage.${system}
];

# custom package set capable of building latest (unreleased) `cabal-install`.
# This gives us support for multiple home units in cabal repl
cabal-multi-pkgs = pkgs.haskell.packages.ghc94.override {
# custom package set for cabal 3.12 (has support for `--enable-multi-repl`)
cabal-3-12-pkgs = pkgs.haskellPackages.override {
overrides = with pkgs.haskell.lib; self: super: rec {
cabal-install = dontCheck (self.callCabal2nix "cabal-install" "${cabal-head}/cabal-install" {});
cabal-install-solver = dontCheck (self.callCabal2nix "cabal-install-solver" "${cabal-head}/cabal-install-solver" {});
Cabal-described = dontCheck (self.callCabal2nix "Cabal-described" "${cabal-head}/Cabal-described" {});
Cabal-QuickCheck = dontCheck (self.callCabal2nix "Cabal-QuickCheck" "${cabal-head}/Cabal-QuickCheck" {});
Cabal-tree-diff = dontCheck (self.callCabal2nix "Cabal-tree-diff" "${cabal-head}/Cabal-tree-diff" {});
Cabal-syntax = dontCheck (self.callCabal2nix "Cabal-syntax" "${cabal-head}/Cabal-syntax" {});
Cabal = dontCheck (self.callCabal2nix "Cabal" "${cabal-head}/Cabal" {});
unix = dontCheck (doJailbreak super.unix_2_8_1_1);
filepath = dontCheck (doJailbreak super.filepath_1_4_100_4);
process = dontCheck (doJailbreak super.process_1_6_17_0);
directory = dontCheck (doJailbreak (super.directory_1_3_7_1));
tasty = dontCheck (doJailbreak super.tasty);
QuickCheck = dontCheck (doJailbreak super.QuickCheck);
hashable = dontCheck (doJailbreak super.hashable);
async = dontCheck (doJailbreak super.async);
hspec-meta = dontCheck (doJailbreak super.hspec-meta);
hpc = dontCheck (doJailbreak super.hpc);
ghci = dontCheck (doJailbreak super.ghci);
ghc-boot = dontCheck (doJailbreak super.ghc-boot);
setenv = dontCheck (doJailbreak super.setenv);
vector = dontCheck (doJailbreak super.vector);
network-uri = dontCheck (doJailbreak super.network-uri);
aeson = dontCheck (doJailbreak super.aeson);
th-compat = dontCheck (doJailbreak super.th-compat);
safe-exceptions = dontCheck (doJailbreak super.safe-exceptions);
bifunctors = dontCheck (doJailbreak super.bifunctors);
base-compat-batteries = dontCheck (doJailbreak super.base-compat-batteries);
distributative = dontCheck (doJailbreak super.distributative);
semialign = dontCheck (doJailbreak super.semialign);
semigroupoids = dontCheck (doJailbreak super.semigroupoids);
hackage-security = dontCheck (doJailbreak super.hackage-security);
cabal-install = dontCheck (self.callCabal2nix "cabal-install" "${cabal-3-12}/cabal-install" {});
cabal-install-solver = dontCheck (self.callCabal2nix "cabal-install-solver" "${cabal-3-12}/cabal-install-solver" {});
Cabal-described = dontCheck (self.callCabal2nix "Cabal-described" "${cabal-3-12}/Cabal-described" {});
Cabal-QuickCheck = dontCheck (self.callCabal2nix "Cabal-QuickCheck" "${cabal-3-12}/Cabal-QuickCheck" {});
Cabal-tree-diff = dontCheck (self.callCabal2nix "Cabal-tree-diff" "${cabal-3-12}/Cabal-tree-diff" {});
Cabal-syntax = dontCheck (self.callCabal2nix "Cabal-syntax" "${cabal-3-12}/Cabal-syntax" {});
Cabal-tests = dontCheck (self.callCabal2nix "Cabal" "${cabal-3-12}/Cabal-tests" {});
Cabal = dontCheck (self.callCabal2nix "Cabal" "${cabal-3-12}/Cabal" {});
hackage-security = dontCheck (doJailbreak super.hackage-security_0_6_2_6);
};
};

secp256k1-static = stripDylib (pkgs.secp256k1.overrideAttrs (attrs: {
configureFlags = attrs.configureFlags ++ [ "--enable-static" ];
}));

hevmUnwrapped = (with pkgs; lib.pipe (
haskellPackages.callCabal2nix "hevm" ./. {
hsPkgs = ps :
ps.haskellPackages.override {
overrides = hfinal: hprev: {
with-utf8 =
if (with ps.stdenv; hostPlatform.isDarwin && hostPlatform.isx86)
then ps.haskell.lib.compose.overrideCabal (_ : { extraLibraries = [ps.libiconv]; }) hprev.with-utf8
else hprev.with-utf8;
};
};

hevmBase = ps :
((hsPkgs ps).callCabal2nix "hevm" ./. {
# Haskell libs with the same names as C libs...
# Depend on the C libs, not the Haskell libs.
# These are system deps, not Cabal deps.
inherit secp256k1;
})
[
(haskell.lib.compose.overrideCabal (old: { testTarget = "test"; }))
(haskell.lib.compose.addTestToolDepends testDeps)
(haskell.lib.compose.appendBuildFlags ["-v3"])
(haskell.lib.compose.appendConfigureFlags (
[ "-fci"
"-O2"
"--extra-lib-dirs=${stripDylib (pkgs.gmp.override { withStatic = true; })}/lib"
"--extra-lib-dirs=${stripDylib secp256k1-static}/lib"
"--extra-lib-dirs=${stripDylib (libff.override { enableStatic = true; })}/lib"
"--extra-lib-dirs=${zlib.static}/lib"
"--extra-lib-dirs=${stripDylib (libffi.overrideAttrs (_: { dontDisableStatic = true; }))}/lib"
"--extra-lib-dirs=${stripDylib (ncurses.override { enableStatic = true; })}/lib"
]
++ lib.optionals stdenv.isLinux [
"--enable-executable-static"
# TODO: replace this with musl: https://stackoverflow.com/a/57478728
"--extra-lib-dirs=${glibc}/lib"
"--extra-lib-dirs=${glibc.static}/lib"
]))
haskell.lib.dontHaddock
]).overrideAttrs(final: prev: {
secp256k1 = ps.secp256k1;
}).overrideAttrs(final: prev: {
HEVM_SOLIDITY_REPO = solidity;
HEVM_ETHEREUM_TESTS_REPO = ethereum-tests;
HEVM_FORGE_STD_REPO = forge-std;
DAPP_SOLC = "${solc}/bin/solc";
});

# workaround for nixpkgs / ghc / macos / cc issue
# https://gitlab.haskell.org/ghc/ghc/-/issues/23138
cc-workaround-ghc-23138 =
pkgs.writeScriptBin "cc-workaround-ghc-23138" ''
if [ "$1" = "--print-file-name" ] && [ "$2" = "c++" ]; then
echo c++
else
exec cc "$@"
fi
'';

hevmUnwrapped = let
ps = if pkgs.stdenv.isDarwin then pkgs else pkgs.pkgsStatic;
in (with ps; lib.pipe
(hevmBase ps)
[
(haskell.lib.compose.overrideCabal (old: { testTarget = "test"; }))
(haskell.lib.compose.addTestToolDepends testDeps)
#(haskell.lib.compose.appendBuildFlags ["-v3"])
(haskell.lib.compose.appendConfigureFlags (
[ "-fci"
"-O2"
]
++ lib.optionals stdenv.isDarwin
[ "--extra-lib-dirs=${stripDylib (pkgs.gmp.override { withStatic = true; })}/lib"
"--extra-lib-dirs=${stripDylib secp256k1-static}/lib"
"--extra-lib-dirs=${stripDylib (libff.override { enableStatic = true; })}/lib"
"--extra-lib-dirs=${zlib.static}/lib"
"--extra-lib-dirs=${stripDylib (libffi.overrideAttrs (_: { dontDisableStatic = true; }))}/lib"
"--extra-lib-dirs=${stripDylib (ncurses.override { enableStatic = true; })}/lib"
"--ghc-options=-pgml=${cc-workaround-ghc-23138}/bin/cc-workaround-ghc-23138"
]))
haskell.lib.compose.dontHaddock
haskell.lib.compose.doCheck
]);

# wrapped binary for use on systems with nix available. ensures all
# required runtime deps are available and on path
hevmWrapped = with pkgs; symlinkJoin {
Expand Down Expand Up @@ -201,32 +201,31 @@

# --- shell ---

devShell = with pkgs;
let libraryPath = "${lib.makeLibraryPath [ libff secp256k1 gmp ]}";
in haskellPackages.shellFor {
packages = _: [ hevmUnwrapped ];
buildInputs = [
# cabal from nixpkgs
# haskellPackages.cabal-install
cabal-multi-pkgs.cabal-install
mdbook
yarn
haskellPackages.eventlog2html
haskellPackages.haskell-language-server
] ++ testDeps;
withHoogle = true;

HEVM_SOLIDITY_REPO = solidity;
DAPP_SOLC = "${solc}/bin/solc";
HEVM_ETHEREUM_TESTS_REPO = ethereum-tests;
HEVM_FORGE_STD_REPO = forge-std;

# NOTE: hacks for bugged cabal new-repl
LD_LIBRARY_PATH = libraryPath;
shellHook = lib.optionalString stdenv.isDarwin ''
export DYLD_LIBRARY_PATH="${libraryPath}";
'';
};
devShells.default = with pkgs; let
libraryPath = "${lib.makeLibraryPath [ libff secp256k1 gmp ]}";
in haskellPackages.shellFor {
packages = _: [ (hevmBase pkgs) ];
buildInputs = [
cabal-3-12-pkgs.cabal-install
mdbook
yarn
haskellPackages.eventlog2html
haskellPackages.haskell-language-server
] ++ testDeps;
withHoogle = true;

# hevm tests expect these to be set
HEVM_SOLIDITY_REPO = solidity;
DAPP_SOLC = "${solc}/bin/solc";
HEVM_ETHEREUM_TESTS_REPO = ethereum-tests;
HEVM_FORGE_STD_REPO = forge-std;

# point cabal repl to system deps
LD_LIBRARY_PATH = libraryPath;
shellHook = lib.optionalString stdenv.isDarwin ''
export DYLD_LIBRARY_PATH="${libraryPath}";
'';
};
}
);
}
Loading