From f147297dac82112eab1e8d32bce4708b77dd5251 Mon Sep 17 00:00:00 2001 From: kat witch Date: Fri, 26 Mar 2021 22:37:35 +0000 Subject: [PATCH] nyx: Added a debug option. cmd_ prefixes added. --- nyx | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/nyx b/nyx index a5e631f9..aa69ec21 100755 --- a/nyx +++ b/nyx @@ -2,37 +2,45 @@ set -eu usage() { - echo example: $0 build samhain boot + echo example: $0 build samhain boot } -deploy() { - HOST=$1 - if [ $# -gt 2 ]; then - METHOD=$2 - else - METHOD="switch" - fi - - bash <(nix eval --raw deploy.${HOST} -f .) ${METHOD} +eval_setup() { + HOST=$1 + if [ $# -gt 2 ]; then + METHOD=$2 + else + METHOD="switch" + fi } -install() { - HOST=$1 - nix build -f . hosts.$HOST.config.system.build.toplevel - CLOSURE=$(readlink result) - nix-store --export $(nix-store -qR ./result) | ssh root@$HOST nix-store --import --store /mnt - ssh root@$HOST nixos-install --system $CLOSURE +cmd_deploy() { + eval_setup $@ + bash <(nix eval --raw deploy.${HOST} -f .) ${METHOD} +} + +cmd_debug() { + eval_setup $@ + nix eval --raw deploy.$HOST -f . +} + +cmd_install() { + HOST=$1 + nix build -f . hosts.$HOST.config.system.build.toplevel + CLOSURE=$(readlink result) + nix-store --export $(nix-store -qR ./result) | ssh root@$HOST nix-store --import --store /mnt + ssh root@$HOST nixos-install --system $CLOSURE } main() { - if [ $# -lt 2 ]; then - usage - else - CMD=$1 - shift + if [ $# -lt 2 ]; then + usage + else + CMD=$1 + shift - $CMD $@ - fi + cmd_$CMD $@ + fi } main "$@"