Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.11 134 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.21"; 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-6EeRmxAmb1nCQ2FTNtWfQ7HCH0g9nJXC3jnhV0KEOwk="; 63 }; 64 65 postPatch = '' 66 substituteInPlace cmake/jsoncpp.cmake \ 67 --replace "${jsoncppUrl}" ${jsoncpp} 68 substituteInPlace cmake/range-v3.cmake \ 69 --replace "${range3Url}" ${range3} 70 substituteInPlace cmake/fmtlib.cmake \ 71 --replace "${fmtlibUrl}" ${fmtlib} 72 ''; 73 74 cmakeFlags = [ 75 "-DBoost_USE_STATIC_LIBS=OFF" 76 77 ] ++ (if z3Support then [ 78 "-DSTRICT_Z3_VERSION=OFF" 79 ] else [ 80 "-DUSE_Z3=OFF" 81 ]) ++ lib.optionals (!cvc4Support) [ 82 "-DUSE_CVC4=OFF" 83 ]; 84 85 nativeBuildInputs = [ cmake ]; 86 buildInputs = [ boost ] 87 ++ lib.optionals z3Support [ z3 ] 88 ++ lib.optionals cvc4Support [ cvc4 cln gmp ]; 89 nativeCheckInputs = [ jq ncurses (python3.withPackages (ps: with ps; [ colorama deepdiff devtools docopt docutils requests sphinx tabulate z3 ])) ]; # contextlib2 glob2 textwrap3 traceback2 urllib3 90 91 # tests take 60+ minutes to complete, only run as part of passthru tests 92 doCheck = false; 93 94 checkPhase = '' 95 pushd .. 96 # IPC tests need aleth avaliable, so we disable it 97 sed -i "s/IPC_ENABLED=true/IPC_ENABLED=false\nIPC_FLAGS=\"--no-ipc\"/" ./scripts/tests.sh 98 for i in ./scripts/*.sh ./scripts/*.py ./test/*.sh ./test/*.py; do 99 patchShebangs "$i" 100 done 101 ## TODO: reenable tests below after adding evmone and hera and their dependencies to nixpkgs 102 #TERM=xterm ./scripts/tests.sh ${lib.optionalString z3Support "--no-smt"} 103 popd 104 ''; 105 106 doInstallCheck = true; 107 installCheckPhase = '' 108 $out/bin/solc --version > /dev/null 109 ''; 110 111 passthru.tests = { 112 solcWithTests = solc.overrideAttrs (attrs: { doCheck = true; }); 113 }; 114 } else gccStdenv.mkDerivation rec { 115 inherit pname version meta; 116 117 src = pkgs.fetchurl { 118 url = "https://github.com/ethereum/solidity/releases/download/v${version}/solc-macos"; 119 sha256 = "sha256-GdBldJ+wjL/097RShKxVhTBjhl9q6GIeTe+l2Ti5pQI="; 120 }; 121 dontUnpack = true; 122 123 installPhase = '' 124 runHook preInstall 125 126 mkdir -p $out/bin 127 cp ${src} $out/bin/solc 128 chmod +x $out/bin/solc 129 130 runHook postInstall 131 ''; 132 }; 133in 134 solc