Skip to content

Commit

Permalink
Unbreak normal nix build
Browse files Browse the repository at this point in the history
  • Loading branch information
elopez committed Oct 26, 2023
1 parent 1048fa6 commit 139366b
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
repo = "hevm";
rev = "release/0.51.3-plus-ghc-9.4-support";
sha256 = "sha256-gJMFYfsPqf5XZyyPDGJLqr9q9RpXkemGeUQUvFT6V0E";
}) { secp256k1 = secp256k1-static; });
}) { secp256k1 = pkgs.secp256k1; });

# FIXME: figure out solc situation, it conflicts with the one from
# solc-select that is installed with slither, disable tests in the meantime
Expand All @@ -60,7 +60,12 @@
[
(haskell.lib.compose.addTestToolDepends [ haskellPackages.hpack slither-analyzer solc ])
(haskell.lib.compose.disableCabalFlag "static")
(haskell.lib.compose.appendConfigureFlags (
]);

echidna-static = with pkgs; lib.pipe
echidna
[
(haskell.lib.compose.appendConfigureFlags
[
"--extra-lib-dirs=${stripDylib (pkgs.gmp.override { withStatic = true; })}/lib"
"--extra-lib-dirs=${stripDylib secp256k1-static}/lib"
Expand All @@ -69,8 +74,9 @@
"--extra-lib-dirs=${stripDylib (libiconv.override { enableStatic = true; })}/lib"
"--extra-lib-dirs=${stripDylib (libffi.overrideAttrs (_: { dontDisableStatic = true; }))}/lib"
"--extra-lib-dirs=${stripDylib (ncurses-static)}/lib"
]))
]);
])
(haskell.lib.compose.enableCabalFlag "static")
];

# "static" binary for distribution
# on linux this is actually a real fully static binary
Expand All @@ -82,11 +88,13 @@
perl = "${pkgs.perl}/bin/perl";
otool = "${pkgs.darwin.binutils.bintools}/bin/otool";
install_name_tool = "${pkgs.darwin.binutils.bintools}/bin/install_name_tool";
codesign_allocate = "${pkgs.darwin.binutils.bintools}/bin/codesign_allocate";
codesign = "${pkgs.darwin.sigtool}/bin/codesign";
in if pkgs.stdenv.isLinux
then pkgs.haskell.lib.dontCheck echidna
then pkgs.haskell.lib.dontCheck echidna-static
else pkgs.runCommand "echidna-stripNixRefs" {} ''
mkdir -p $out/bin
cp ${pkgs.haskell.lib.dontCheck echidna}/bin/echidna $out/bin/
cp ${pkgs.haskell.lib.dontCheck echidna-static}/bin/echidna $out/bin/
# get the list of dynamic libs from otool and tidy the output
libs=$(${otool} -L $out/bin/echidna | tail -n +2 | sed 's/^[[:space:]]*//' | cut -d' ' -f1)
# get the path for libcxx
Expand All @@ -96,6 +104,8 @@
${install_name_tool} -change "$cxx" /usr/lib/libc++.1.dylib $out/bin/echidna
# fix TERMINFO path in ncurses
${perl} -i -pe 's#(${ncurses-static}/share/terminfo)#"/usr/share/terminfo" . "\x0" x (length($1) - 19)#e' $out/bin/echidna
# re-sign binary
CODESIGN_ALLOCATE=${codesign_allocate} ${codesign} -f -s - $out/bin/echidna
chmod 555 $out/bin/echidna
'';

Expand All @@ -114,8 +124,7 @@
packages.echidna = echidna;
packages.default = echidna;

packages.echidna-bundle =
pkgs.callPackage nix-bundle-exe {} echidnaRedistributable;
packages.echidna-redistributable = echidnaRedistributable;

devShell = with pkgs;
haskellPackages.shellFor {
Expand Down

0 comments on commit 139366b

Please sign in to comment.