Repository navigation
Expand file tree
/
Copy pathsdk.nix
More file actions
60 lines (60 loc) · 2.38 KB
/
Copy pathsdk.nix
File metadata and controls
60 lines (60 loc) · 2.38 KB
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
{ pkgs, src, customRustPlatform }:
with pkgs;
let
stdenv = llvmPackages.libcxxStdenv;
linker = callPackage ./nix/static-linker.nix { inherit stdenv; };
buildInputs = [ openssl-static ];
ic_btc_canister = builtins.fetchurl
"https://github.com/dfinity/bitcoin-canister/releases/latest/download/ic-btc-canister.wasm.gz";
dfx = (customRustPlatform.buildRustPackage {
name = "dfx";
inherit src buildInputs;
cargoBuildFlags = [ "-p" "dfx" "-p" "icx-asset" ];
nativeBuildInputs = [ perl pkg-config cmake binaryen python3 ];
preConfigure = ''
export DFX_VERSION=$(cat src/dfx/Cargo.toml |grep version|head -n1|sed -e 's/^.*"\(.*\)"/\1/')
export DFX_CONFIG_ROOT="$PWD"
export DFX_ASSETS="$PWD/dfx_assets"
mkdir -p "$DFX_ASSETS"
touch "$DFX_ASSETS/binary_cache.tgz"
tar -czf "$DFX_ASSETS"/assetstorage_canister.tgz -C $src/src/distributed assetstorage.did assetstorage.wasm.gz
tar -czf "$DFX_ASSETS"/wallet_canister.tgz -C $src/src/distributed wallet.did wallet.wasm.gz
tar -czf "$DFX_ASSETS"/ui_canister.tgz -C $src/src/distributed ui.did ui.wasm
DIR=`mktemp -d`
cp "${ic_btc_canister}" "$DIR/ic-btc-canister.wasm.gz"
tar -czf "$DFX_ASSETS"/btc_canister.tgz -C $DIR ic-btc-canister.wasm.gz
rm -rf "$DIR"
'' + lib.optionalString stdenv.isDarwin ''
echo CXX=${pkgs.cxx-wrapper}/bin/clang++wrapper
export CXX=${pkgs.cxx-wrapper}/bin/clang++wrapper
'';
postInstall = ''
mkdir -p $out/share/dfx-canisters/
cp $src/src/distributed/*.{wasm,did} $out/share/dfx-canisters/
'';
RUSTFLAGS = lib.optionals stdenv.isLinux [ "-Clinker=${linker}" ]
++ lib.optionals stdenv.isDarwin [
"-Lnative=${libiconv-static.out}/lib"
"-lstatic=iconv"
];
doCheck = false;
# Placeholder, to allow a custom importCargoLock below
cargoSha256 = lib.fakeHash;
}).overrideAttrs (_: {
cargoDeps = customRustPlatform.importCargoLock {
# allowBuiltinFetchGit = true;
lockFile = "${src}/Cargo.lock";
outputHashes = {
"ic-base-types-0.9.0" =
"sha256-u9zZBOnkOnLvKjhmqJzUcdgSoWn21VRrRRHLYvPuyiQ=";
"ic-certification-3.0.3" =
"sha256-IQOCbC7eZ5W+V0kdmvZkwCRIzQQfj/XMJkYx0mpPqnE=";
"pocket-ic-13.0.0" =
"sha256-QMJWB1yRAgrvmugmGqG6zvk7Z3hzXkGTsGej5EJ3z8g=";
};
};
});
in {
inherit dfx;
shell = dfx;
}