From bcc11b22036b2f02bace1482ae2cc5d324f39159 Mon Sep 17 00:00:00 2001 From: Joel McCracken Date: Sat, 4 Nov 2023 00:29:27 -0400 Subject: [PATCH] argument parsing must come first --- bootstrap-workstation.sh | 58 ++++++++++++++++++++-------------------- workstation.org | 20 +++++++------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/bootstrap-workstation.sh b/bootstrap-workstation.sh index 30bb320e..2d9c14c6 100755 --- a/bootstrap-workstation.sh +++ b/bootstrap-workstation.sh @@ -9,35 +9,6 @@ # [[file:workstation.org::*Bootstraping Script][Bootstraping Script:1]] set -xeuo pipefail -# [[file:../../workstation.org::workstation_foundation][workstation_foundation]] - -export WORKSTATION_DIR="$HOME/workstation" -export WORKSTATION_HOST_SETTINGS_SRC_DIR=$WORKSTATION_DIR/hosts/$WORKSTATION_NAME -export WORKSTATION_HOST_CURRENT_SETTINGS_DIR=$WORKSTATION_DIR/hosts/current -export WORKSTATION_EMACS_CONFIG_DIR=~/.config/emacs -export WORKSTATION_GIT_ORIGIN='git@github.com:joelmccracken/workstation.git' -export WORKSTATION_GIT_ORIGIN_PUB='https://github.com/joelmccracken/workstation.git' - -sourceIfExists () { - if [ -f "$1" ]; then - source "$1" - fi -} - -if [ -z "${WORKSTATION_NAME+x}" ] ; then - if [ -f "$WORKSTATION_HOST_CURRENT_SETTINGS_DIR/settings.sh" ]; then - source "~/$WORKSTATION_HOST_CURRENT_SETTINGS_DIR/settings.sh" - fi -fi - -# workstation_foundation ends here -# These are the various versions of things that should be installed. Keeping them -# in one place like this make them easier to keep track of. -# [[file:../../../workstation.org::workstation_setup_versions][workstation_setup_versions]] -export WORKSTATION_NIX_PM_VERSION=nix-2.11.1 -export WORKSTATION_NIX_DARWIN_VERSION=f6648ca0698d1611d7eadfa72b122252b833f86c -export WORKSTATION_HOME_MANAGER_VERSION=0f4e5b4999fd6a42ece5da8a3a2439a50e48e486 -# workstation_setup_versions ends here # Script should be passed a single argument, which is name of this workstation. # When using script to set up a workstation, the "name" of the workstation should @@ -69,6 +40,35 @@ if [ -z "${2+x}" ]; then else export WORKSTATION_BOOTSTRAP_COMMIT="$2" fi +# [[file:../../workstation.org::workstation_foundation][workstation_foundation]] + +export WORKSTATION_DIR="$HOME/workstation" +export WORKSTATION_HOST_SETTINGS_SRC_DIR=$WORKSTATION_DIR/hosts/$WORKSTATION_NAME +export WORKSTATION_HOST_CURRENT_SETTINGS_DIR=$WORKSTATION_DIR/hosts/current +export WORKSTATION_EMACS_CONFIG_DIR=~/.config/emacs +export WORKSTATION_GIT_ORIGIN='git@github.com:joelmccracken/workstation.git' +export WORKSTATION_GIT_ORIGIN_PUB='https://github.com/joelmccracken/workstation.git' + +sourceIfExists () { + if [ -f "$1" ]; then + source "$1" + fi +} + +if [ -z "${WORKSTATION_NAME+x}" ] ; then + if [ -f "$WORKSTATION_HOST_CURRENT_SETTINGS_DIR/settings.sh" ]; then + source "~/$WORKSTATION_HOST_CURRENT_SETTINGS_DIR/settings.sh" + fi +fi + +# workstation_foundation ends here +# These are the various versions of things that should be installed. Keeping them +# in one place like this make them easier to keep track of. +# [[file:../../../workstation.org::workstation_setup_versions][workstation_setup_versions]] +export WORKSTATION_NIX_PM_VERSION=nix-2.11.1 +export WORKSTATION_NIX_DARWIN_VERSION=f6648ca0698d1611d7eadfa72b122252b833f86c +export WORKSTATION_HOME_MANAGER_VERSION=0f4e5b4999fd6a42ece5da8a3a2439a50e48e486 +# workstation_setup_versions ends here # hereafter, we use many helper functions. Here they are defined up front, # as some of them are used throughout the other code. diff --git a/workstation.org b/workstation.org index 8b14e78e..8b165186 100644 --- a/workstation.org +++ b/workstation.org @@ -167,16 +167,6 @@ set -xeuo pipefail This portion of the document explains the various execution steps of bootstrap. Each of these steps are executed sequentially. -*** Foundations -#+begin_src shell :noweb yes -«workstation_foundation» -#+end_src -*** Set Version Settings -#+begin_src shell :noweb yes -# These are the various versions of things that should be installed. Keeping them -# in one place like this make them easier to keep track of. -«workstation_setup_versions» -#+end_src *** Argument Parsing #+begin_src shell # Script should be passed a single argument, which is name of this workstation. @@ -211,6 +201,16 @@ else export WORKSTATION_BOOTSTRAP_COMMIT="$2" fi #+end_src +*** Foundations +#+begin_src shell :noweb yes +«workstation_foundation» +#+end_src +*** Set Version Settings +#+begin_src shell :noweb yes +# These are the various versions of things that should be installed. Keeping them +# in one place like this make them easier to keep track of. +«workstation_setup_versions» +#+end_src *** Helper and Component Functions #+begin_src shell :noweb yes # hereafter, we use many helper functions. Here they are defined up front,