forked from dapphub/dapptools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
overlay.nix
162 lines (135 loc) · 5.19 KB
/
overlay.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
self: super:
let
lib = self.pkgs.lib;
stdenv = self.pkgs.stdenv;
in rec {
dapptoolsSrc = self.callPackage (import ./nix/dapptools-src.nix) {};
haskellPackages =
super.haskellPackages.override (old: {
overrides = lib.composeExtensions (old.overrides or (_: _: {})) (
import ./haskell.nix { inherit lib; pkgs = self;}
);
});
unwrappedHaskellPackages =
super.haskellPackages.override (old: {
overrides = lib.composeExtensions (old.overrides or (_: _: {})) (
import ./haskell.nix { inherit lib; pkgs = self; wrapped = false;}
);
});
sharedHaskellPackages =
super.haskellPackages.override (old: {
overrides = lib.composeExtensions (old.overrides or (_: _: {})) (
import ./haskell.nix { inherit lib; pkgs = self; wrapped = false; shared = true; }
);
});
solidityPackage = import ./nix/solidity-package.nix {
inherit (self) pkgs;
};
# experimental dapp builder, allows for easy overriding of phases
buildDappPackage = import ./nix/build-dapp-package.nix { inherit (self) pkgs; };
# Here we can make e.g. integration tests for Dappsys.
dapp-tests = import ./src/dapp-tests { inherit (self) pkgs; };
# These are tests that verify the correctness of hevm symbolic using various
# external test suites (e.g. the solc tests)
hevm-tests = import ./nix/hevm-tests { pkgs = self.pkgs; };
bashScript = { name, version ? "0", deps ? [], text, check ? true } :
self.pkgs.writeTextFile {
name = "${name}-${version}";
executable = true;
destination = "/bin/${name}";
text = ''
#!${self.pkgs.bash}/bin/bash
set -euo pipefail
shopt -s lastpipe
export PATH="${lib.makeBinPath deps}:/run/wrappers/bin"
${text}
'';
checkPhase = ''
${self.pkgs.bash}/bin/bash -n $out/bin/${name}
'' + (if check then ''
${self.pkgs.shellcheck}/bin/shellcheck -s bash $out/bin/${name}
'' else "");
};
solc-versions =
let
fetchSolcVersions = { owner, attr }:
super.lib.mapAttrs
(_: nixpkgs: (importNixpkgs { inherit owner; inherit (nixpkgs) rev sha256; }).solc)
(builtins.getAttr attr (import ./nix/solc-versions.nix));
importNixpkgs = { owner, rev, sha256 }:
import (self.pkgs.fetchFromGitHub {
inherit owner rev sha256;
repo = "nixpkgs";
}) { inherit (super) system; };
in
self.pkgs.recurseIntoAttrs (
fetchSolcVersions { owner = "NixOS"; attr = super.system; }
//
fetchSolcVersions { owner = "dapphub"; attr = "unreleased_" + super.system; }
);
solc = self.pkgs.runCommand "solc" { } "mkdir -p $out/bin; ln -s ${solc-static-versions.solc_0_8_6}/bin/solc-0.8.6 $out/bin/solc";
solc-static-versions =
let
make-solc-drv = _: solc:
self.callPackage (
import ./nix/solc-static.nix {
path = solc.path;
version = solc.version;
sha256 = solc.sha256;
}) {};
in builtins.mapAttrs make-solc-drv
(builtins.getAttr super.system (import ./nix/solc-static-versions.nix));
# uses solc, z3 and cvc4 from nix
hevm = self.pkgs.haskell.lib.justStaticExecutables self.haskellPackages.hevm;
# uses solc, z3 and cvc4 from PATH
hevmUnwrapped = self.pkgs.haskell.lib.justStaticExecutables self.unwrappedHaskellPackages.hevm;
libff = self.callPackage (import ./nix/libff.nix) {};
jays = (
self.pkgs.haskell.lib.justStaticExecutables
(self.haskellPackages.callCabal2nix "jays" (./src/jays) {})
).overrideAttrs (_: { postInstall = "cp $out/bin/{jays,jshon}"; });
# Override buggy jshon program with Haskell-based replacement.
jshon = self.jays;
seth = self.callPackage (import ./src/seth) {};
dapp = self.callPackage (import ./src/dapp) {};
ethsign = (self.callPackage (import ./src/ethsign) {});
token = self.callPackage (import ./src/token) {};
# We use this to run private testnets without
# the pesky transaction size limit.
go-ethereum-unlimited = (self.callPackage (import ./nix/geth.nix) {}).overrideAttrs (geth: rec {
name = "${geth.pname}-unlimited-${geth.version}";
preConfigure = ''
# Huge transaction calldata
substituteInPlace core/tx_pool.go --replace 'return ErrOversizedData' ""
# Huge contracts
substituteInPlace params/protocol_params.go --replace \
'MaxCodeSize = 24576' \
'MaxCodeSize = 1000000'
# Huge block gas limit in --dev mode
substituteInPlace core/genesis.go --replace \
'GasLimit: 11500000,' \
'GasLimit: 0xffffffffffffffff,'
'';
});
qrtx = self.bashScript {
name = "qrtx";
version = "0";
deps = with self.pkgs; [qrencode feh vim gnused coreutils];
text = ''
sed 's/^0x//' | tr -d '[:space:]' | xxd -r -p | base64 -w0 |
qrencode -s 1 -o - | feh -ZB white --force-aliasing -
'';
};
qrtx-term = self.bashScript {
name = "qrtx-term";
version = "0";
deps = with self.pkgs; [qrencode vim gnused coreutils];
text = ''
sed 's/^0x//' | tr -d '[:space:]' | xxd -r -p | base64 -w0 |
qrencode -t ANSIUTF8
'';
};
secp256k1 = super.secp256k1.overrideDerivation (_: {
dontDisableStatic = true;
});
}