summaryrefslogtreecommitdiffstats
path: root/shell.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-07-23 01:03:53 +0200
committertv <tv@krebsco.de>2017-07-23 01:36:02 +0200
commitdc0ca967cb3399fd66e8d759ee6fc1211c1403de (patch)
tree963bc6a8046cb4bdb535a69fcbc71c70ce926626 /shell.nix
parent4b894507b2fef23e68097bd2b758acf151ab7993 (diff)
shell: add quote command
Diffstat (limited to 'shell.nix')
-rw-r--r--shell.nix32
1 files changed, 20 insertions, 12 deletions
diff --git a/shell.nix b/shell.nix
index deca2ca3a..d40f65902 100644
--- a/shell.nix
+++ b/shell.nix
@@ -67,6 +67,18 @@ let
exec ${pkgs.jq}/bin/jq -enrf "$script" --arg target "$1" \
'';
+ # usage: quote [ARGS...]
+ cmds.quote = pkgs.writeDash "cmds.quote" ''
+ set -efu
+ prefix=
+ for x; do
+ y=$(${pkgs.jq}/bin/jq -nr --arg x "$x" '$x | @sh "\(.)"')
+ echo -n "$prefix$y"
+ prefix=' '
+ done
+ echo
+ '';
+
init.args = pkgs.writeText "init.args" /* sh */ ''
args=$(${pkgs.utillinux}/bin/getopt -n "$command" -s sh \
-o s:t:u: \
@@ -117,21 +129,17 @@ let
'';
proxy = pkgs.writeDash "init.env.proxy" ''
set -efu
- q() {
- ${pkgs.jq}/bin/jq -nr --arg x "$*" '$x | @sh "\(.)"'
- }
exec ${pkgs.openssh}/bin/ssh \
"$target_user@$target_host" -p "$target_port" \
cd "$target_path/stockholm" \; \
- NIX_PATH=$(q "$target_path") \
- STOCKHOLM_VERSION=$STOCKHOLM_VERSION \
- nix-shell \
- --run $(q \
- system=$system \
- target=$target \
- using_proxy=true \
- "$*"
- )
+ NIX_PATH=$(quote "$target_path") \
+ STOCKHOLM_VERSION=$(quote "$STOCKHOLM_VERSION") \
+ nix-shell --run "$(quote "
+ system=$(quote "$system") \
+ target=$(quote "$target") \
+ using_proxy=true \
+ $(quote "$@")
+ ")"
'';
};