forked from input-output-hk/daedalus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request input-output-hk#2926 from input-output-hk/fix/ddw-…
…1027-initial-nix-shell-command
- Loading branch information
Showing
3 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters