forked from dfinity/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
distributed-canisters.nix
42 lines (35 loc) · 1.06 KB
/
distributed-canisters.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
{ pkgs ? import ./nix {}
}:
let
distributed = lib.noNixFiles (lib.gitOnlySource ./src/distributed);
lib = pkgs.lib;
in
pkgs.runCommandNoCCLocal "distributed-canisters" {
moc = pkgs.motoko;
base = pkgs.sources.motoko-base;
} ''
mkdir -p $out
for canister_dir in $(find ${distributed} -mindepth 1 -maxdepth 1 -type d); do
canister_name=$(basename $canister_dir)
build_dir=$out/$canister_name
mkdir -p $build_dir
$moc/bin/moc \
$canister_dir/Main.mo \
-o $build_dir/$canister_name.did \
--idl \
--package base $base
$moc/bin/moc \
$canister_dir/Main.mo \
-o $build_dir/$canister_name.wasm \
-c --release \
--package base $base
done
for canister_wasm in ${distributed}/*.wasm; do
canister_name=$(basename -s .wasm $canister_wasm)
canister_did=$(dirname $canister_wasm)/$canister_name.did
build_dir=$out/$canister_name
mkdir -p $build_dir
cp $canister_wasm $out/$canister_name/$canister_name.wasm
cp $canister_did $out/$canister_name/$canister_name.did
done
''