From 4122727e1bd2ac44306fcfdb3fe405aa5c63647f Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Sat, 2 May 2020 17:52:50 +0200 Subject: [PATCH] Add build command --- nix-on-droid/nix-on-droid.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/nix-on-droid/nix-on-droid.sh b/nix-on-droid/nix-on-droid.sh index 3c94f5f..d40ac4b 100644 --- a/nix-on-droid/nix-on-droid.sh +++ b/nix-on-droid/nix-on-droid.sh @@ -13,6 +13,25 @@ function errorEcho() { >&2 echo $@ } +function setupPasstroughOpts() { + if [[ -v VERBOSE ]]; then + PASSTHROUGH_OPTS+=(--show-trace) + fi + + if [[ -n "$CONFIG_FILE" ]]; then + PASSTHROUGH_OPTS+=(--argstr config "$(realpath "$CONFIG_FILE")") + fi +} + + +function doBuild() { + echo "Building activation package..." + nix build \ + --file "" \ + ${PASSTHROUGH_OPTS[*]} \ + activationPackage +} + function doGenerations() { nix-env --profile $PROFILE_DIRECTORY --list-generations } @@ -45,6 +64,8 @@ function doHelp() { echo echo " rollback Rollback and activate configuration" echo + echo " build Build configuration" + echo echo " switch Build and activate configuration" echo echo " switch-generation NUM" @@ -52,14 +73,6 @@ function doHelp() { } function doSwitch() { - if [[ -v VERBOSE ]]; then - PASSTHROUGH_OPTS+=(--show-trace) - fi - - if [[ -n "$CONFIG_FILE" ]]; then - PASSTHROUGH_OPTS+=(--argstr config "$(realpath "$CONFIG_FILE")") - fi - echo "Building activation package..." nix build \ --no-link \ @@ -100,7 +113,7 @@ while [[ $# -gt 0 ]]; do opt="$1" shift case $opt in - generations|help|rollback|switch|switch-generation) + build|generations|help|rollback|switch|switch-generation) COMMAND="$opt" ;; -f|--file) @@ -147,12 +160,17 @@ while [[ $# -gt 0 ]]; do esac done +setupPasstroughOpts + if [[ -z $COMMAND ]]; then doHelp >&2 exit 1 fi case $COMMAND in + build) + doBuild + ;; generations) doGenerations ;;