Skip to content

Commit 571639a

Browse files
author
Damon Chen
committed
Override dotenv in start-cronos/start-chainmain
This make these two script-bins defined in `scripts.nix` always use the same yaml and dotenv file, for metting the "re-producibility" requirement during one/same `nix-shell` environment. These script-bins are wrappers of pystarport with fixed yaml and dotenv. If you want to create the cronos/chainmain instance with different configurations, you should avoid using the script-bins. Please run the scripts directly, or use `pystarport` step by step. Besides, if you change the yaml or dotenv, you need to exit and re-enter the nix-shell. So that the modified yaml or dotenv are copied to nix store, and their paths can be rewritten into these two script-bins.
1 parent 8adea89 commit 571639a

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

nix/default.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import sources.nixpkgs {
2424
import ./scripts.nix {
2525
inherit pkgs;
2626
config = {
27-
chainmain-config = builtins.toString ../scripts/chainmain-devnet.yaml;
28-
cronos-config = builtins.toString ../scripts/cronos-devnet.yaml;
29-
hermes-config = builtins.toString ../scripts/hermes.toml;
30-
geth-genesis = builtins.toString ../scripts/geth-genesis.json;
31-
dotenv = builtins.toString ../scripts/.env;
27+
chainmain-config = ../scripts/chainmain-devnet.yaml;
28+
cronos-config = ../scripts/cronos-devnet.yaml;
29+
hermes-config = ../scripts/hermes.toml;
30+
geth-genesis = ../scripts/geth-genesis.json;
31+
dotenv = builtins.path { name = "dotenv"; path = ../scripts/.env; };
3232
};
3333
})
3434
(_: pkgs: {

nix/scripts.nix

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
}: rec {
88
start-chainmain = pkgs.writeShellScriptBin "start-chainmain" ''
99
export PATH=${pkgs.pystarport}/bin:${chainmain}/bin:$PATH
10-
source ${config.dotenv}
11-
${../scripts/start-chainmain} ${config.chainmain-config} $@
10+
${../scripts/start-chainmain} ${config.chainmain-config} ${config.dotenv} $@
1211
'';
1312
start-cronos = pkgs.writeShellScriptBin "start-cronos" ''
1413
# rely on environment to provide cronosd
1514
export PATH=${pkgs.pystarport}/bin:$PATH
16-
source ${config.dotenv}
17-
${../scripts/start-cronos} ${config.cronos-config} $@
15+
${../scripts/start-cronos} ${config.cronos-config} ${config.dotenv} $@
1816
'';
1917
start-geth = pkgs.writeShellScriptBin "start-geth" ''
2018
export PATH=${pkgs.go-ethereum}/bin:$PATH

scripts/start-chainmain

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ if [ -z "$CONFIG" ]; then
88
fi
99
shift
1010

11+
DOTENV=$1
12+
if [ -z "$DOTENV" ]; then
13+
echo "No dotenv file supplied"
14+
exit 1
15+
fi
16+
shift
1117

1218
DATA=$1
1319
if [ -z "$DATA" ]; then
@@ -16,8 +22,10 @@ if [ -z "$DATA" ]; then
1622
fi
1723
shift
1824

19-
# `pystarport serve` don't work for integration test for some weird reason
20-
echo 'config'$CONFIG
21-
echo 'data'$DATA
22-
pystarport init --config $CONFIG --data $DATA $@
25+
echo 'pystarport:'
26+
echo ' config: '$CONFIG
27+
echo ' dotenv: '$DOTENV
28+
echo ' data: '$DATA
29+
30+
pystarport init --config $CONFIG --dotenv $DOTENV --data $DATA $@
2331
supervisord -c $DATA/tasks.ini

scripts/start-cronos

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@ if [ -z "$CONFIG" ]; then
88
fi
99
shift
1010

11+
DOTENV=$1
12+
if [ -z "$DOTENV" ]; then
13+
echo "No dotenv file supplied"
14+
exit 1
15+
fi
16+
shift
17+
1118
DATA=$1
1219
if [ -z "$DATA" ]; then
1320
echo "No data directory supplied"
1421
exit 1
1522
fi
1623
shift
1724

18-
# `pystarport serve` don't work for integration test for some weird reason
19-
pystarport init --config $CONFIG --data $DATA $@
25+
echo 'pystarport:'
26+
echo ' config: '$CONFIG
27+
echo ' dotenv: '$DOTENV
28+
echo ' data: '$DATA
29+
30+
pystarport init --config $CONFIG --dotenv $DOTENV --data $DATA $@
2031
supervisord -c $DATA/tasks.ini

0 commit comments

Comments
 (0)