Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.05 138 lines 4.1 kB view raw
1{ lib, gccStdenv, fetchzip 2, pkgs 3, boost 4, cmake 5, coreutils 6, fetchpatch 7, jq 8, ncurses 9, python3 10, z3Support ? true 11, z3_4_11 ? null 12, cvc4Support ? gccStdenv.isLinux 13, cvc4 ? null 14, cln ? null 15, gmp ? null 16}: 17 18# compiling source/libsmtutil/CVC4Interface.cpp breaks on clang on Darwin, 19# general commandline tests fail at abiencoderv2_no_warning/ on clang on NixOS 20let z3 = z3_4_11; in 21 22assert z3Support -> z3 != null && lib.versionAtLeast z3.version "4.11.0"; 23assert cvc4Support -> cvc4 != null && cln != null && gmp != null; 24 25let 26 jsoncppVersion = "1.9.3"; 27 jsoncppUrl = "https://github.com/open-source-parsers/jsoncpp/archive/${jsoncppVersion}.tar.gz"; 28 jsoncpp = fetchzip { 29 url = jsoncppUrl; 30 sha256 = "1vbhi503rgwarf275ajfdb8vpdcbn1f7917wjkf8jghqwb1c24lq"; 31 }; 32 33 range3Version = "0.12.0"; 34 range3Url = "https://github.com/ericniebler/range-v3/archive/${range3Version}.tar.gz"; 35 range3 = fetchzip { 36 url = range3Url; 37 sha256 = "sha256-bRSX91+ROqG1C3nB9HSQaKgLzOHEFy9mrD2WW3PRBWU="; 38 }; 39 40 fmtlibVersion = "8.0.1"; 41 fmtlibUrl = "https://github.com/fmtlib/fmt/archive/${fmtlibVersion}.tar.gz"; 42 fmtlib = fetchzip { 43 url = fmtlibUrl; 44 sha256 = "1mnvxqsan034d2jiqnw2yvkljl7lwvhakmj5bscwp1fpkn655bbw"; 45 }; 46 47 pname = "solc"; 48 version = "0.8.19"; 49 meta = with lib; { 50 description = "Compiler for Ethereum smart contract language Solidity"; 51 homepage = "https://github.com/ethereum/solidity"; 52 license = licenses.gpl3; 53 maintainers = with maintainers; [ dbrock akru lionello sifmelcara ]; 54 }; 55 56 solc = if gccStdenv.isLinux then gccStdenv.mkDerivation rec { 57 inherit pname version meta; 58 59 # upstream suggests avoid using archive generated by github 60 src = fetchzip { 61 url = "https://github.com/ethereum/solidity/releases/download/v${version}/solidity_${version}.tar.gz"; 62 sha256 = "sha256-xh/QPYNEWxPtDaVmBeIE/Ch98g0ox9gJ/lR6ziOu+bg="; 63 }; 64 65 patches = [ 66 ./tests.patch 67 ]; 68 69 postPatch = '' 70 substituteInPlace cmake/jsoncpp.cmake \ 71 --replace "${jsoncppUrl}" ${jsoncpp} 72 substituteInPlace cmake/range-v3.cmake \ 73 --replace "${range3Url}" ${range3} 74 substituteInPlace cmake/fmtlib.cmake \ 75 --replace "${fmtlibUrl}" ${fmtlib} 76 ''; 77 78 cmakeFlags = [ 79 "-DBoost_USE_STATIC_LIBS=OFF" 80 81 ] ++ (if z3Support then [ 82 "-DSTRICT_Z3_VERSION=OFF" 83 ] else [ 84 "-DUSE_Z3=OFF" 85 ]) ++ lib.optionals (!cvc4Support) [ 86 "-DUSE_CVC4=OFF" 87 ]; 88 89 nativeBuildInputs = [ cmake ]; 90 buildInputs = [ boost ] 91 ++ lib.optionals z3Support [ z3 ] 92 ++ lib.optionals cvc4Support [ cvc4 cln gmp ]; 93 nativeCheckInputs = [ jq ncurses (python3.withPackages (ps: with ps; [ colorama deepdiff devtools docopt docutils requests sphinx tabulate z3 ])) ]; # contextlib2 glob2 textwrap3 traceback2 urllib3 94 95 # tests take 60+ minutes to complete, only run as part of passthru tests 96 doCheck = false; 97 98 checkPhase = '' 99 pushd .. 100 # IPC tests need aleth avaliable, so we disable it 101 sed -i "s/IPC_ENABLED=true/IPC_ENABLED=false\nIPC_FLAGS=\"--no-ipc\"/" ./scripts/tests.sh 102 for i in ./scripts/*.sh ./scripts/*.py ./test/*.sh ./test/*.py; do 103 patchShebangs "$i" 104 done 105 ## TODO: reenable tests below after adding evmone and hera and their dependencies to nixpkgs 106 #TERM=xterm ./scripts/tests.sh ${lib.optionalString z3Support "--no-smt"} 107 popd 108 ''; 109 110 doInstallCheck = true; 111 installCheckPhase = '' 112 $out/bin/solc --version > /dev/null 113 ''; 114 115 passthru.tests = { 116 solcWithTests = solc.overrideAttrs (attrs: { doCheck = true; }); 117 }; 118 } else gccStdenv.mkDerivation rec { 119 inherit pname version meta; 120 121 src = pkgs.fetchurl { 122 url = "https://github.com/ethereum/solidity/releases/download/v${version}/solc-macos"; 123 sha256 = "sha256-OMhSOrZ+Cz4hxIGJ1r+5mtaHm5zgLg2ALsi+WYuyYi0="; 124 }; 125 dontUnpack = true; 126 127 installPhase = '' 128 runHook preInstall 129 130 mkdir -p $out/bin 131 cp ${src} $out/bin/solc 132 chmod +x $out/bin/solc 133 134 runHook postInstall 135 ''; 136 }; 137in 138 solc