-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmk-solc-static-pkg.nix
76 lines (67 loc) · 2.15 KB
/
mk-solc-static-pkg.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
{
lib,
stdenv,
fetchurl,
autoPatchelfHook,
solc_ver,
solc_sha256,
solc-macos-amd64-list,
...
}:
let
pname = "solc-static";
version = solc_ver;
meta = with lib; {
description = "Static binary of compiler for Ethereum smart contract language Solidity";
homepage = "https://github.com/ethereum/solidity";
license = licenses.gpl3;
maintainers = with maintainers; [ hellwolf ];
mainProgram = "solc-${solc_ver}";
};
inherit (stdenv.hostPlatform) system;
solc-flavor =
{
x86_64-linux = "solc-static-linux";
x86_64-darwin = "solc-macos-amd64";
aarch64-darwin = "solc-macos-aarch64";
}
# We musnt' throw here, since nixos-rebuild seems not liking it.
.${system} or "unsupported-system";
# The official solc binaries for macOS started supporting Apple Silicon with
# v0.8.24. For earlier versions, the binaries from svm can be used.
# See https://github.com/alloy-rs/solc-builds
macosUniversalBuildUrl = "https://binaries.soliditylang.org/macosx-amd64/${
solc-macos-amd64-list.releases.${version}
}";
url =
if solc-flavor == "solc-static-linux" then
"https://github.com/ethereum/solidity/releases/download/v${version}/solc-static-linux"
else if solc-flavor == "solc-macos-amd64" then
macosUniversalBuildUrl
else if solc-flavor == "solc-macos-aarch64" && builtins.compareVersions solc_ver "0.8.5" > -1 then
if builtins.compareVersions solc_ver "0.8.24" == -1 then
"https://github.com/alloy-rs/solc-builds/raw/master/macosx/aarch64/solc-v${version}"
else
macosUniversalBuildUrl
else
throw "Unsupported version ${version} for ${system}";
in
if (builtins.hasAttr solc-flavor solc_sha256) then
(stdenv.mkDerivation rec {
inherit pname version meta;
src = fetchurl {
inherit url;
sha256 = solc_sha256.${solc-flavor};
};
dontUnpack = true;
nativeBuildInputs = lib.optionals (!stdenv.isDarwin) [ autoPatchelfHook ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp ${src} $out/bin/solc-${version}
chmod +x $out/bin/solc-${version}
runHook postInstall
'';
})
else
null