-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdefault.nix
157 lines (143 loc) · 5.07 KB
/
default.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
self: super:
let
error = message: builtins.throw ("[nixpkgs-dfinity-sdk] " + message);
sdkAttrSet = {
acceptLicenseAgreement ? false,
sdkSystem ? builtins.currentSystem
}: (
let
resolvedSystem =
if sdkSystem == "aarch64-darwin"
then "x86_64-darwin"
else sdkSystem;
makeVersion = { systems, version }: (
if !acceptLicenseAgreement then
error (builtins.concatStringsSep "\n" [
""
""
"You must accept the license agreement at https://sdk.dfinity.org/sdk-license-agreement.txt and indicate so by setting:"
""
" pkgs.dfinity-sdk { acceptLicenseAgreement = true; };"
""
])
else
self.stdenv.mkDerivation {
name = "dfinity-sdk-${version}-${resolvedSystem}";
src = self.fetchzip {
sha256 =
if builtins.hasAttr resolvedSystem systems
then systems.${resolvedSystem}.sha256
else error ("unsupported system: " + resolvedSystem);
stripRoot = false;
url = builtins.concatStringsSep "/" [
"https://sdk.dfinity.org"
"downloads"
"dfx"
version
"${resolvedSystem}"
"dfx-${version}.tar.gz"
];
};
nativeBuildInputs = [
self.makeWrapper
] ++ self.lib.optional self.stdenv.isLinux [
self.glibc.bin
self.patchelf
self.which
];
# Use `find $(dfx cache show) -type f -executable -print` on macOS to
# help discover what to symlink.
installPhase = ''
export HOME=$TMP
${self.lib.optionalString self.stdenv.isLinux ''
local LD_LINUX_SO=$(ldd $(which iconv)|grep ld-linux-x86|cut -d' ' -f3)
local IS_STATIC=$(ldd ./dfx | grep 'not a dynamic executable')
local USE_LIB64=$(ldd ./dfx | grep '/lib64/ld-linux-x86-64.so.2')
chmod +rw ./dfx
test -n "$IS_STATIC" || test -z "$USE_LIB64" || patchelf --set-interpreter "$LD_LINUX_SO" ./dfx
''}
./dfx cache install
local CACHE_DIR="$out/.cache/dfinity/versions/${version}"
mkdir -p "$CACHE_DIR"
cp --preserve=mode,timestamps -R $(./dfx cache show)/. $CACHE_DIR
mkdir -p $out/bin
for binary in dfx ic-ref ic-starter icx-proxy mo-doc mo-ide moc replica; do
${self.lib.optionalString self.stdenv.isLinux ''
local BINARY="$CACHE_DIR/$binary"
test -f "$BINARY" || continue
local IS_STATIC=$(ldd "$BINARY" | grep 'not a dynamic executable')
local USE_LIB64=$(ldd "$BINARY" | grep '/lib64/ld-linux-x86-64.so.2')
chmod +rw "$BINARY"
test -n "$IS_STATIC" || test -z "$USE_LIB64" || patchelf --set-interpreter "$LD_LINUX_SO" "$BINARY"
''}
ln -s $CACHE_DIR/$binary $out/bin/$binary
done
wrapProgram $CACHE_DIR/dfx --set DFX_CONFIG_ROOT $out
rm $out/bin/dfx
ln -s $CACHE_DIR/dfx $out/bin/dfx
'';
system = resolvedSystem;
inherit version;
}
);
sdk-0_6_21 = makeVersion {
systems = {
"x86_64-darwin" = {
sha256 = "0i92rwk5x13q7f7nyrgc896w2mlbk63lkgmlrvmyciwbggjiv4pc";
};
"x86_64-linux" = {
sha256 = "06akn065x7vaqy56v5jn551zbw5a0wfxvn13q0hpskm2iwrwrpnb";
};
};
version = "0.6.21";
};
sdk-0_7_0-beta_8 = makeVersion {
systems = {
"x86_64-darwin" = {
sha256 = "19zq8n5ahqmbyp1bvhzv06zfaimxyfgzvanwfkf5px7gb1jcqf0m";
};
"x86_64-linux" = {
sha256 = "0nl29155076k23fx1j0zb92cr4p0dh8fk5cnjr67dy3nwlbygh3x";
};
};
version = "0.7.0-beta.8";
};
sdk-0_8_4 = makeVersion {
systems = {
"x86_64-darwin" = {
sha256 = "JJzZzUJtrgmKJdxXGVJedhP5t9maxh3YjIq1xhTcvfU=";
};
"x86_64-linux" = {
sha256 = "yht96jUJ8gTK5Ual1ofItyRBnQ+qIrbk0lOlefu/L7I=";
};
};
version = "0.8.4";
};
sdk-0_9_2 = makeVersion {
systems = {
"x86_64-darwin" = {
# sha256 = self.lib.fakeSha256;
sha256 = "UITKzQ9XzlsyO4DU72Ah2VH8736eQeW8GL6hzJHTaYA=";
};
"x86_64-linux" = {
# sha256 = self.lib.fakeSha256;
sha256 = "41NP4AGp5Ve1Srm9a2jweOEEu6iKDGJEBr+SYtrqUSM=";
};
};
version = "0.9.2";
};
# https://sdk.dfinity.org/manifest.json
versions = {
latest = sdk-0_8_4;
"0.6.21" = sdk-0_6_21;
"0.7.0-beta.8" = sdk-0_7_0-beta_8;
"0.8.4" = sdk-0_8_4;
"0.9.2" = sdk-0_9_2;
};
in
versions // { inherit makeVersion; }
);
in
{
dfinity-sdk = sdkAttrSet;
}