-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcardano-devnet.nix
73 lines (62 loc) · 2.69 KB
/
cardano-devnet.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
{ inputs, lib, ... }: {
options.perSystem = inputs.flake-parts.lib.mkPerSystemOption (_: {
options = {
cardano-devnet.initialFunds = lib.mkOption {
type = lib.types.attrsOf lib.types.ints.unsigned;
default = { };
example = {
"609783be7d3c54f11377966dfabc9284cd6c32fca1cd42ef0a4f1cc45b" = 900000000000;
};
};
};
});
config.perSystem = { system, pkgs, config, ... }:
let
CONFIG_DIR = ./devnet;
DEVNET_DIR = "./.devnet";
CARDANO_NODE_SOCKET_PATH = "${DEVNET_DIR}/node.socket";
cardano-node' = inputs.cardano-node.packages.${system}.cardano-node;
cardano-devnet = pkgs.writeShellApplication
{
name = "cardano-devnet";
runtimeInputs = [ cardano-node' ];
text = ''
export CARDANO_NODE_SOCKET_PATH=${CARDANO_NODE_SOCKET_PATH}
set -eo pipefail
set -ex
[ -d "${DEVNET_DIR}" ] && { echo "Cleaning up directory ${DEVNET_DIR}" ; rm -rf "${DEVNET_DIR}" ; }
mkdir -p ${DEVNET_DIR}
cp -af ${CONFIG_DIR}/config.json "${DEVNET_DIR}"
cp -af ${CONFIG_DIR}/genesis-alonzo.json "${DEVNET_DIR}"
cp -af ${CONFIG_DIR}/genesis-conway.json "${DEVNET_DIR}"
cp -af ${CONFIG_DIR}/vrf.skey "${DEVNET_DIR}"
cp -af ${CONFIG_DIR}/kes.skey "${DEVNET_DIR}"
jq '.startTime |= $start_time' \
--argjson start_time "$(date +%s)" \
< ${CONFIG_DIR}/genesis-byron.json \
> "${DEVNET_DIR}/genesis-byron.json"
jq '.systemStart |= $start_time | .initialFunds |= $funds' \
--arg start_time "$(date -u +%FT%TZ)" \
--argjson funds '${builtins.toJSON config.cardano-devnet.initialFunds}' \
< ${CONFIG_DIR}/genesis-shelley.json\
> "${DEVNET_DIR}/genesis-shelley.json"
find "${DEVNET_DIR}" -type f -name '*.skey' -exec chmod 0400 {} \;
mkdir "${DEVNET_DIR}/ipc"
cardano-node run \
--topology "${CONFIG_DIR}/topology.json" \
--database-path "${DEVNET_DIR}/chain" \
--socket-path "${CARDANO_NODE_SOCKET_PATH}" \
--port 3001 \
--config "${DEVNET_DIR}/config.json" \
--shelley-kes-key "${DEVNET_DIR}/kes.skey" \
--shelley-vrf-key "${DEVNET_DIR}/vrf.skey" \
--shelley-operational-certificate "${CONFIG_DIR}/opcert.cert" \
--byron-delegation-certificate "${CONFIG_DIR}/byron-delegation.cert" \
--byron-signing-key "${CONFIG_DIR}/byron-delegate.key"
'';
};
in
{
packages.cardano-devnet = cardano-devnet;
};
}