shell: add --force-populate flag
This commit is contained in:
parent
cfff3729ea
commit
252d45d212
19
shell.nix
19
shell.nix
|
@ -6,7 +6,8 @@ let
|
||||||
# high level commands
|
# 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" ''
|
cmds.deploy = pkgs.writeDash "cmds.deploy" ''
|
||||||
set -efu
|
set -efu
|
||||||
|
|
||||||
|
@ -20,7 +21,8 @@ let
|
||||||
exec ${utils.deploy}
|
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" ''
|
cmds.install = pkgs.writeBash "cmds.install" ''
|
||||||
set -efu
|
set -efu
|
||||||
|
|
||||||
|
@ -61,7 +63,8 @@ let
|
||||||
exec nixos-install
|
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 */ ''
|
cmds.test = pkgs.writeDash "cmds.test" /* sh */ ''
|
||||||
set -efu
|
set -efu
|
||||||
|
|
||||||
|
@ -142,11 +145,13 @@ let
|
||||||
init.args = pkgs.writeText "init.args" /* sh */ ''
|
init.args = pkgs.writeText "init.args" /* sh */ ''
|
||||||
args=$(${pkgs.utillinux}/bin/getopt -n "$command" -s sh \
|
args=$(${pkgs.utillinux}/bin/getopt -n "$command" -s sh \
|
||||||
-o s:t:u: \
|
-o s:t:u: \
|
||||||
-l system:,target:,user: \
|
-l force-populate,system:,target:,user: \
|
||||||
-- "$@")
|
-- "$@")
|
||||||
if \test $? != 0; then exit 1; fi
|
if \test $? != 0; then exit 1; fi
|
||||||
eval set -- "$args"
|
eval set -- "$args"
|
||||||
|
force_populate=false;
|
||||||
while :; do case $1 in
|
while :; do case $1 in
|
||||||
|
--force-populate) force_populate=true; shift;;
|
||||||
-s|--system) system=$2; shift 2;;
|
-s|--system) system=$2; shift 2;;
|
||||||
-t|--target) target=$2; shift 2;;
|
-t|--target) target=$2; shift 2;;
|
||||||
-u|--user) user=$2; shift 2;;
|
-u|--user) user=$2; shift 2;;
|
||||||
|
@ -177,7 +182,11 @@ let
|
||||||
source_file=$user/1systems/$system/source.nix
|
source_file=$user/1systems/$system/source.nix
|
||||||
source=$(get-source "$source_file")
|
source=$(get-source "$source_file")
|
||||||
qualified_target=$target_user@$target_host:$target_port$target_path
|
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
|
if \test "$target_local" != true; then
|
||||||
exec ${pkgs.openssh}/bin/ssh \
|
exec ${pkgs.openssh}/bin/ssh \
|
||||||
|
|
Loading…
Reference in a new issue