From 252d45d212ad0b67336636914a721eb08b5df1c3 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 27 Jul 2017 20:43:17 +0200 Subject: shell: add --force-populate flag --- shell.nix | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/shell.nix b/shell.nix index fda48a1a7..57690d398 100644 --- a/shell.nix +++ b/shell.nix @@ -6,7 +6,8 @@ let # high level commands # - # usage: deploy [--user=USER] --system=SYSTEM [--target=TARGET] + # usage: deploy [--force-populate] [--user=USER] + # --system=SYSTEM [--target=TARGET] cmds.deploy = pkgs.writeDash "cmds.deploy" '' set -efu @@ -20,7 +21,8 @@ let exec ${utils.deploy} ''; - # usage: install [--user=USER] --system=SYSTEM --target=TARGET + # usage: install [--force-populate] [--user=USER] + # --system=SYSTEM --target=TARGET cmds.install = pkgs.writeBash "cmds.install" '' set -efu @@ -61,7 +63,8 @@ let exec nixos-install ''; - # usage: test [--user=USER] --system=SYSTEM --target=TARGET + # usage: test [--force-populate] [--user=USER] + # --system=SYSTEM --target=TARGET cmds.test = pkgs.writeDash "cmds.test" /* sh */ '' set -efu @@ -142,11 +145,13 @@ let init.args = pkgs.writeText "init.args" /* sh */ '' args=$(${pkgs.utillinux}/bin/getopt -n "$command" -s sh \ -o s:t:u: \ - -l system:,target:,user: \ + -l force-populate,system:,target:,user: \ -- "$@") if \test $? != 0; then exit 1; fi eval set -- "$args" + force_populate=false; while :; do case $1 in + --force-populate) force_populate=true; shift;; -s|--system) system=$2; shift 2;; -t|--target) target=$2; shift 2;; -u|--user) user=$2; shift 2;; @@ -177,7 +182,11 @@ let source_file=$user/1systems/$system/source.nix source=$(get-source "$source_file") qualified_target=$target_user@$target_host:$target_port$target_path - echo "$source" | populate "$qualified_target" + if test "$force_populate" = true; then + echo "$source" | populate --force "$qualified_target" + else + echo "$source" | populate "$qualified_target" + fi if \test "$target_local" != true; then exec ${pkgs.openssh}/bin/ssh \ -- cgit v1.2.3