-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
223 lines (206 loc) · 7.43 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
{
description = "Crytic Toolbox";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/856556b164d56f63434d2dd3e954f00f4b3a075f"; # v24.05 on 240912
utils.url = "github:numtide/flake-utils/b1d9ab70662946ef0850d488da1c9019f3a9752a"; # 240311
};
outputs = inputs: with inputs;
utils.lib.eachDefaultSystem (system: let
pyVersion = "python312";
python = pkgs.${pyVersion};
pyPkgs = pkgs.${pyVersion + "Packages"};
skipTests = { doCheck = false; checkPhase = "true"; checkInputs = []; };
pyCommon = skipTests // {
format = "pyproject";
# Chill out re dependency versions
pythonRelaxDeps = true; nativeBuildInputs = with pyPkgs; [ pkgs.git pythonRelaxDepsHook ];
};
pkgs = import nixpkgs { inherit system; };
noCheck = drv: drv.overridePythonAttrs (old: skipTests // old);
in rec {
lib = {
mkSolcSelect = {
commitHash ? "8072a3394bdc960c0f652fb72e928a7eae3631da",
version ? "1.0.4",
src ? null,
}: pyPkgs.buildPythonPackage (pyCommon // {
pname = "solc-select";
inherit version;
src = if src != null then src else builtins.fetchGit {
url = "https://github.com/crytic/solc-select";
rev = commitHash;
allRefs = true;
};
propagatedBuildInputs = with pyPkgs; [
packaging
pycryptodome
setuptools
];
});
mkCryticCompile = {
commitHash ? "20df04f37af723eaa7fa56dc2c80169776f3bc4d",
version ? "0.3.7",
src ? null,
solc-select ? packages.solc-select,
}: pyPkgs.buildPythonPackage (pyCommon // {
pname = "crytic-compile";
inherit version;
src = if src != null then src else builtins.fetchGit {
url = "https://github.com/crytic/crytic-compile";
rev = commitHash;
allRefs = true;
};
propagatedBuildInputs = with pyPkgs; [
solc-select
cbor2
pycryptodome
setuptools
toml
];
});
mkSlither = {
commitHash ? "aeeb2d368802844733671e35200b30b5f5bdcf5c",
version ? "0.10.4",
src ? null,
solc-select ? packages.solc-select,
crytic-compile ? packages.crytic-compile,
}: pyPkgs.buildPythonPackage (pyCommon // {
pname = "slither";
inherit version;
src = if src != null then src else builtins.fetchGit {
url = "https://github.com/crytic/slither";
rev = commitHash;
allRefs = true;
};
propagatedBuildInputs = with pyPkgs; [
solc-select
crytic-compile
deepdiff
eth-abi
eth-typing
eth-utils
numpy
packaging
prettytable
pycryptodome
pytest
pytest-cov
setuptools
];
postPatch = ''
echo "web3 dependency depends on ipfs which is bugged, removing it from the listed deps"
sed -i 's/"web3>=6.20.2, <7",//' setup.py
echo "openai dependency is bugged, removing it from the listed deps"
sed -i 's/"openai",//' setup.py
'';
});
mkCloudexec = {
commitHash ? "cbba8d81e4b64f5d0634e728c339101a53d373cd",
version ? "0.2.0",
src ? null,
vendorHash ? "sha256-xiiMcjo+hRllttjYXB3F2Ms2gX43r7/qgwxr4THNhsk=",
}: pkgs.buildGoModule {
inherit version vendorHash;
pname = "cloudexec";
src = if src != null then src else builtins.fetchGit {
url = "https://github.com/crytic/cloudexec";
rev = commitHash;
allRefs = true;
};
nativeBuildInputs = [
pkgs.git
pkgs.go_1_21
];
ldflags = [
"-X main.Version=${version}"
"-X main.Commit=${commitHash}"
"-X main.Date=now"
];
};
mkMedusa = {
commitHash ? "c58a72f2f9072c7b31d6a16f4771449e00607e4b",
version ? "0.1.8",
vendorHash ? "sha256-12Xkg5dzA83HQ2gMngXoLgu1c9KGSL6ly5Qz/o8U++8=",
src ? null,
crytic-compile ? packages.crytic-compile,
slither ? packages.slither,
}: pkgs.buildGoModule {
pname = "medusa";
inherit version vendorHash;
src = if src != null then src else builtins.fetchGit {
url = "https://github.com/crytic/medusa";
rev = commitHash;
allRefs = true;
};
nativeBuildInputs = [
crytic-compile
slither
pkgs.solc
pkgs.nodejs
];
doCheck = false; # tests require `npm install` which can't run in isolated build env
};
mkEchidna = {
commitHash ? "6d5ac38f9132938210c325d17fd6672543dfc9c4",
}: (
builtins.getFlake "github:crytic/echidna/${commitHash}"
).packages.${system}.echidna;
mkVscode = {
extensions ? [],
}: pkgs.vscode-with-extensions.override {
vscode = pkgs.vscodium;
vscodeExtensions = with pkgs.vscode-extensions; extensions ++ [
jnoortheen.nix-ide
mads-hartmann.bash-ide-vscode
ms-python.python
naumovs.color-highlight
oderwat.indent-rainbow
yzhang.markdown-all-in-one
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [{
name = "weaudit"; publisher = "trailofbits"; version = "1.1.0";
sha256 = "sha256-XHif6JzZJvQiToIn3mnBznp9ct8wlWOyBVncHU4ZDgo=";
} {
name = "sarif-explorer"; publisher = "trailofbits"; version = "1.2.4";
sha256 = "sha256-BwJEapf0HRaUKHxA5V8QDAv3dEDGSxlE9a7dOnaN4h4=";
} {
name = "flowbookmark"; publisher = "DeepakPahawa"; version = "5.0.0";
sha256 = "sha256-iLMEZR3yT0Ua1TJxQlEFXe6RH+vaCF8h9JUjXY5EOjg=";
} {
name = "solidity"; publisher = "juanblanco"; version = "0.0.174";
sha256 = "sha256-+fHycRl++Ate7NoQFaLmHynWNC+T4zjsPlFwvpnEMrk=";
}
];
};
};
packages = {
cloudexec = lib.mkCloudexec {};
crytic-compile = lib.mkCryticCompile {};
echidna = lib.mkEchidna {};
medusa = lib.mkMedusa {};
slither = lib.mkSlither {};
solc-select = lib.mkSolcSelect {};
vscode = lib.mkVscode {};
};
apps = {
cloudexec = { program = "${packages.cloudexec}/bin/cloudexec"; type = "app"; };
crytic-compile = { program = "${packages.crytic-compile}/bin/crytic-compile"; type = "app"; };
echidna = { program = "${packages.echidna}/bin/echidna"; type = "app"; };
medusa = { program = "${packages.medusa}/bin/medusa"; type = "app"; };
slither = { program = "${packages.slither}/bin/slither"; type = "app"; };
solc-select = { program = "${packages.solc-select}/bin/solc-select"; type = "app"; };
vscode = { program = "${packages.vscode}/bin/vscode"; type = "app"; };
};
devShells.default = pkgs.mkShell {
buildInputs = with packages; [
cloudexec
crytic-compile
echidna
medusa
slither
solc-select
vscode
];
};
}
);
}