nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 gccStdenv,
4 fetchzip,
5 pkgs,
6 boost,
7 cmake,
8 jq,
9 ncurses,
10 python3,
11 versionCheckHook,
12 z3Support ? true,
13 z3 ? null,
14 cvc4Support ? gccStdenv.hostPlatform.isLinux,
15 cvc4 ? null,
16 cln ? null,
17 gmp ? null,
18}:
19
20# compiling source/libsmtutil/CVC4Interface.cpp breaks on clang on Darwin,
21# general commandline tests fail at abiencoderv2_no_warning/ on clang on NixOS
22assert z3Support -> z3 != null && lib.versionAtLeast z3.version "4.11.0";
23assert cvc4Support -> cvc4 != null && cln != null && gmp != null;
24
25let
26 pname = "solc";
27
28 version = "0.8.33";
29 linuxHash = "sha256-sWCV0GOUW5GPNX1flk+UOrdwoHZHnx4MsZMGDDBxx6M=";
30 darwinHash = "sha256-gyQoBZHOOY1+JyKEa8EOzxd5sToyjvl7aHySzZxwgBo=";
31
32 nativeInstallCheckInputs = [
33 versionCheckHook
34 ];
35 doInstallCheck = true;
36
37 meta = {
38 description = "Compiler for Ethereum smart contract language Solidity";
39 homepage = "https://github.com/ethereum/solidity";
40 changelog = "https://github.com/ethereum/solidity/releases/tag/v${version}";
41 license = lib.licenses.gpl3;
42 maintainers = with lib.maintainers; [
43 dbrock
44 akru
45 lionello
46 sifmelcara
47 ];
48 };
49
50 solc =
51 if gccStdenv.hostPlatform.isLinux then
52 gccStdenv.mkDerivation rec {
53 inherit
54 pname
55 version
56 nativeInstallCheckInputs
57 doInstallCheck
58 meta
59 ;
60
61 # upstream suggests avoid using archive generated by github
62 src = fetchzip {
63 url = "https://github.com/ethereum/solidity/releases/download/v${version}/solidity_${version}.tar.gz";
64 hash = linuxHash;
65 };
66
67 cmakeFlags = [
68 "-DBoost_USE_STATIC_LIBS=OFF"
69
70 ]
71 ++ (
72 if z3Support then
73 [
74 "-DSTRICT_Z3_VERSION=OFF"
75 ]
76 else
77 [
78 "-DUSE_Z3=OFF"
79 ]
80 )
81 ++ lib.optionals (!cvc4Support) [
82 "-DUSE_CVC4=OFF"
83 ];
84
85 nativeBuildInputs = [ cmake ];
86 buildInputs = [
87 boost
88 ]
89 ++ lib.optionals z3Support [ z3 ]
90 ++ lib.optionals cvc4Support [
91 cvc4
92 cln
93 gmp
94 ];
95 nativeCheckInputs = [
96 jq
97 ncurses
98 (python3.withPackages (
99 ps: with ps; [
100 colorama
101 deepdiff
102 devtools
103 docopt
104 docutils
105 requests
106 sphinx
107 tabulate
108 z3-solver
109 ]
110 ))
111 ]; # contextlib2 glob2 textwrap3 traceback2 urllib3
112
113 enableParallelBuilding = true;
114
115 # tests take 60+ minutes to complete, only run as part of passthru tests
116 doCheck = false;
117
118 checkPhase = ''
119 pushd ..
120 # IPC tests need aleth avaliable, so we disable it
121 sed -i "s/IPC_ENABLED=true/IPC_ENABLED=false\nIPC_FLAGS=\"--no-ipc\"/" ./scripts/tests.sh
122 for i in ./scripts/*.sh ./scripts/*.py ./test/*.sh ./test/*.py; do
123 patchShebangs "$i"
124 done
125 ## TODO: reenable tests below after adding evmone and hera and their dependencies to nixpkgs
126 #TERM=xterm ./scripts/tests.sh ${lib.optionalString z3Support "--no-smt"}
127 popd
128 '';
129
130 installCheckPhase = ''
131 runHook preInstallCheck
132
133 $out/bin/solc --version > /dev/null
134
135 runHook postInstallCheck
136 '';
137
138 passthru.tests = {
139 solcWithTests = solc.overrideAttrs (attrs: {
140 doCheck = true;
141 });
142 };
143 }
144 else
145 gccStdenv.mkDerivation rec {
146 inherit
147 pname
148 version
149 nativeInstallCheckInputs
150 doInstallCheck
151 meta
152 ;
153
154 src = pkgs.fetchurl {
155 url = "https://github.com/ethereum/solidity/releases/download/v${version}/solc-macos";
156 hash = darwinHash;
157 };
158 dontUnpack = true;
159
160 installPhase = ''
161 runHook preInstall
162
163 mkdir -p $out/bin
164 cp ${src} $out/bin/solc
165 chmod +x $out/bin/solc
166
167 runHook postInstall
168 '';
169 };
170in
171solc