Skip to content

Commit

Permalink
Merge pull request input-output-hk#2926 from input-output-hk/fix/ddw-…
Browse files Browse the repository at this point in the history
…1027-initial-nix-shell-command
  • Loading branch information
danielmain authored Mar 21, 2022
2 parents 00372b5 + b613d1d commit 77bcc54
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ If you get SSL error when running `nix-shell` (SSL peer certificate or SSH remot

1. Run `yarn nix:selfnode` from `daedalus`.
2. Run `yarn dev` from the subsequent `nix-shell` (use `KEEP_LOCAL_CLUSTER_RUNNING` environment variable to keep the local cluster running after Daedalus exits: `KEEP_LOCAL_CLUSTER_RUNNING=true yarn dev`)
1. Alternatively: run `yarn nix:selfnode yarn dev` to achieve the same thing in a single command. Note: after `yarn dev` exits, you will still remain in the `nix-shell`.
3. Once Daedalus has started and has gotten past the loading screen run the following commands from a new terminal window if you wish to import funded wallets:
- Byron wallets: `yarn byron:wallet:importer`
- Shelley wallets: `yarn shelley:wallet:importer`
Expand Down Expand Up @@ -94,31 +95,37 @@ If you get SSL error when running `nix-shell` (SSL peer certificate or SSH remot

1. Run `yarn nix:mainnet` from `daedalus`.
2. Run `yarn dev` from the subsequent `nix-shell`
3. Or in one command: `yarn nix:mainnet yarn dev`

#### Flight

1. Run `yarn nix:flight` from `daedalus`.
2. Run `yarn dev` from the subsequent `nix-shell`
3. Or in one command: `yarn nix:flight yarn dev`

#### Testnet

1. Run `yarn nix:testnet` from `daedalus`.
2. Run `yarn dev` from the subsequent `nix-shell`
3. Or in one command: `yarn nix:testnet yarn dev`

#### Staging

1. Run `yarn nix:staging` from `daedalus`.
2. Run `yarn dev` from the subsequent `nix-shell`
3. Or in one command: `yarn nix:staging yarn dev`

#### Shelley QA

1. Run `yarn nix:shelley_qa` from `daedalus`.
2. Run `yarn dev` from the subsequent `nix-shell`
3. Or in one command: `yarn nix:shelley_qa yarn dev`

#### Alonzo Purple

1. Run `yarn nix:alonzo_purple` from `daedalus`.
2. Run `yarn dev` from the subsequent `nix-shell`
3. Or in one command: `yarn nix:alonzo_purple yarn dev`

#### Native token metadata server

Expand Down
33 changes: 33 additions & 0 deletions nix/yarn-nix-shell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# This small wrapper over `nix-shell`, called from package.json
# (e.g. `yarn nix:testnet`) allows to specify an initial command to be
# run inside the `nix-shell` once its ready, e.g.:
#
# $ yarn nix:testnet yarn dev
#
# After the command finishes, you will still be left inside the
# nix-shell.

if [ $# -lt 2 ] ; then
echo >&2 'fatal: usage: '"$0"' <network> <cluster> [<initial command> ...]'
exit 1
fi

NETWORK="$1" ; shift
cluster="$1" ; shift

# Unfortunately, we need to shell-escape the command:
# cf. <https://github.com/NixOS/nixpkgs/blob/877eb10cfbdb3e3d54bdc7a7f6fd3c4b4e6396da/lib/strings.nix#L310-L328>
command=''
while [ $# -gt 0 ] ; do
command="$command '""${1//\'/\'\\\'\'}""'" ; shift
done

if [ -z "$command" ] ; then
command=':' # no-op, if no command
fi

export NETWORK
# `return` will make the user stay in `nix-shell` after the initial command finishes:
exec nix-shell --argstr nodeImplementation cardano --argstr cluster "$cluster" --command "$command ; return"
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
"themes:update": "gulp build:themes && ts-node -r esm ./dist/scripts/update.js && yarn prettier --loglevel warn --write source/renderer/app/themes/daedalus/*.ts",
"themes:copy": "ts-node -r @babel/register -r @babel/polyfill source/renderer/app/themes/utils/copyTheme.ts && yarn prettier --loglevel warn --write source/renderer/app/themes/daedalus/*.ts",
"clear:cache": "gulp clear:cache",
"nix:alonzo_purple": "NETWORK=alonzo_purple nix-shell --argstr nodeImplementation cardano --argstr cluster alonzo_purple",
"nix:mainnet": "NETWORK=mainnet nix-shell --argstr nodeImplementation cardano --argstr cluster mainnet",
"nix:flight": "NETWORK=mainnet nix-shell --argstr nodeImplementation cardano --argstr cluster mainnet_flight",
"nix:selfnode": "NETWORK=selfnode nix-shell --argstr nodeImplementation cardano --argstr cluster selfnode",
"nix:shelley_qa": "NETWORK=shelley_qa nix-shell --argstr nodeImplementation cardano --argstr cluster shelley_qa",
"nix:staging": "NETWORK=staging nix-shell --argstr nodeImplementation cardano --argstr cluster staging",
"nix:testnet": "NETWORK=testnet nix-shell --argstr nodeImplementation cardano --argstr cluster testnet",
"nix:alonzo_purple": "./nix/yarn-nix-shell.sh alonzo_purple alonzo_purple",
"nix:mainnet": "./nix/yarn-nix-shell.sh mainnet mainnet",
"nix:flight": "./nix/yarn-nix-shell.sh mainnet mainnet_flight",
"nix:selfnode": "./nix/yarn-nix-shell.sh selfnode selfnode",
"nix:shelley_qa": "./nix/yarn-nix-shell.sh shelley_qa shelley_qa",
"nix:staging": "./nix/yarn-nix-shell.sh staging staging",
"nix:testnet": "./nix/yarn-nix-shell.sh testnet testnet",
"byron:wallet:importer": "ts-node utils/api-importer/byron-wallet-importer.ts",
"shelley:wallet:importer": "ts-node utils/api-importer/shelley-wallet-importer.ts",
"mary:wallet:importer": "ts-node utils/api-importer/mary-wallet-importer.ts",
Expand Down

0 comments on commit 77bcc54

Please sign in to comment.