Skip to content

Commit

Permalink
shuffle some more things, establish a foundation
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmccracken committed Nov 4, 2023
1 parent c9daa5e commit 908ae36
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 49 deletions.
4 changes: 2 additions & 2 deletions bin/tangle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@


# [[file:../workstation.org::*Makefile][Makefile:2]]
EMACS_CONFIG_DIR=~/.config/emacs;
$EMACS_CONFIG_DIR/bin/doomscript lib/emacs/tangle-file.el
source ~/workstation/lib/shell/foundation.sh
$WORKSTATION_EMACS_CONFIG_DIR/bin/doomscript lib/emacs/tangle-file.el
# Makefile:2 ends here
36 changes: 23 additions & 13 deletions bootstrap-workstation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ set -xeuo pipefail
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='[email protected]: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
Expand Down Expand Up @@ -54,11 +69,6 @@ if [ -z "${2+x}" ]; then
else
export WORKSTATION_BOOTSTRAP_COMMIT="$2"
fi
# having these variables here really just makes the code a bit more DRY

WS_ORIGIN='[email protected]:joelmccracken/workstation.git'
WS_ORIGIN_PUB='https://github.com/joelmccracken/workstation.git'
EMACS_CONFIG_DIR=~/.config/emacs
# hereafter, we use many helper functions. Here they are defined up front,
# as some of them are used throughout the other code.

Expand Down Expand Up @@ -176,17 +186,17 @@ function clone_repo_and_checkout_at() {
# [[file:workstation.org::install_doom_emacs_no_nix_function][install_doom_emacs_no_nix_function]]
function install_doom_emacs_no_nix() {
{
cd $EMACS_CONFIG_DIR
cd $WORKSTATION_EMACS_CONFIG_DIR
[[ "$(git remote get-url origin)" == 'https://github.com/hlissner/doom-emacs' ]]
} || {
mv_dated_backup $EMACS_CONFIG_DIR
time git clone --depth 1 https://github.com/doomemacs/doomemacs $EMACS_CONFIG_DIR/
mv_dated_backup $WORKSTATION_EMACS_CONFIG_DIR
time git clone --depth 1 https://github.com/doomemacs/doomemacs $WORKSTATION_EMACS_CONFIG_DIR/
# alternative: use this if encounter problems
# ~/.emacs.d/bin/doom -y install;
# time timeout 45m bash -c 'yes | ~/.emacs.d/bin/doom install' || exit 0
# time bash -c 'yes | ~/.emacs.d/bin/doom install' || exit 0
time timeout 60m bash -c "yes | $EMACS_CONFIG_DIR/bin/doom install" || exit 0
$EMACS_CONFIG_DIR/bin/doom sync
time timeout 60m bash -c "yes | $WORKSTATION_EMACS_CONFIG_DIR/bin/doom install" || exit 0
$WORKSTATION_EMACS_CONFIG_DIR/bin/doom sync
echo FINISHED INSTALLING DOOM;
}
}
Expand Down Expand Up @@ -273,9 +283,9 @@ is_linux && {
update_apt_install_git
info finished updating apt, installing git
}
is_git_repo_cloned_at $WORKSTATION_DIR $WS_ORIGIN || {
clone_repo_and_checkout_at $WORKSTATION_DIR $WS_ORIGIN_PUB \
$WORKSTATION_BOOTSTRAP_COMMIT $WS_ORIGIN
is_git_repo_cloned_at $WORKSTATION_DIR $WORKSTATION_GIT_ORIGIN || {
clone_repo_and_checkout_at $WORKSTATION_DIR $WORKSTATION_GIT_ORIGIN_PUB \
$WORKSTATION_BOOTSTRAP_COMMIT $WORKSTATION_GIT_ORIGIN
}
# at this point, this is hardly necessary; however, the gitignore file is handy
# i may explore getting rid of this repo entirely and just having a fresh
Expand Down
11 changes: 0 additions & 11 deletions dotfiles/zshrc.aeglos.sh

This file was deleted.

9 changes: 9 additions & 0 deletions lib/shell/foundation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
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='[email protected]: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
Expand Down
4 changes: 2 additions & 2 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ set +u
source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
set -u

EMACS_CONFIG_DIR=~/.config/emacs
source ~/workstation/lib/shell/foundation.sh

function find_emacs_init() {
init_file="";
for x in "$EMACS_CONFIG_DIR/early-init.el" "$EMACS_CONFIG_DIR/init.el"; do
for x in "$WORKSTATION_EMACS_CONFIG_DIR/early-init.el" "$WORKSTATION_EMACS_CONFIG_DIR/init.el"; do
if [[ -f "$x" ]]; then
init_file="$x"
break;
Expand Down
48 changes: 27 additions & 21 deletions workstation.org
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ tangle:
Which requires a shell script:

#+begin_src sh :shebang "#!/usr/bin/env bash" :tangle ./bin/tangle.sh
EMACS_CONFIG_DIR=~/.config/emacs;
$EMACS_CONFIG_DIR/bin/doomscript lib/emacs/tangle-file.el
source ~/workstation/lib/shell/foundation.sh
$WORKSTATION_EMACS_CONFIG_DIR/bin/doomscript lib/emacs/tangle-file.el
#+end_src

And a little emacs lisp that goes with the tangle process:
Expand Down Expand Up @@ -211,15 +211,6 @@ else
export WORKSTATION_BOOTSTRAP_COMMIT="$2"
fi
#+end_src

*** Setting some variables to keep things DRY
#+begin_src shell
# having these variables here really just makes the code a bit more DRY

WS_ORIGIN='[email protected]:joelmccracken/workstation.git'
WS_ORIGIN_PUB='https://github.com/joelmccracken/workstation.git'
EMACS_CONFIG_DIR=~/.config/emacs
#+end_src
*** Helper and Component Functions
#+begin_src shell :noweb yes
# hereafter, we use many helper functions. Here they are defined up front,
Expand Down Expand Up @@ -295,9 +286,9 @@ is_linux && {
#+end_src
*** check out correct workstation commit
#+begin_src shell :noweb yes
is_git_repo_cloned_at $WORKSTATION_DIR $WS_ORIGIN || {
clone_repo_and_checkout_at $WORKSTATION_DIR $WS_ORIGIN_PUB \
$WORKSTATION_BOOTSTRAP_COMMIT $WS_ORIGIN
is_git_repo_cloned_at $WORKSTATION_DIR $WORKSTATION_GIT_ORIGIN || {
clone_repo_and_checkout_at $WORKSTATION_DIR $WORKSTATION_GIT_ORIGIN_PUB \
$WORKSTATION_BOOTSTRAP_COMMIT $WORKSTATION_GIT_ORIGIN
}
#+end_src
*** check out the dotfiles repository
Expand Down Expand Up @@ -659,17 +650,17 @@ ensure_nix_installed
#+begin_src shell
function install_doom_emacs_no_nix() {
{
cd $EMACS_CONFIG_DIR
cd $WORKSTATION_EMACS_CONFIG_DIR
[[ "$(git remote get-url origin)" == 'https://github.com/hlissner/doom-emacs' ]]
} || {
mv_dated_backup $EMACS_CONFIG_DIR
time git clone --depth 1 https://github.com/doomemacs/doomemacs $EMACS_CONFIG_DIR/
mv_dated_backup $WORKSTATION_EMACS_CONFIG_DIR
time git clone --depth 1 https://github.com/doomemacs/doomemacs $WORKSTATION_EMACS_CONFIG_DIR/
# alternative: use this if encounter problems
# ~/.emacs.d/bin/doom -y install;
# time timeout 45m bash -c 'yes | ~/.emacs.d/bin/doom install' || exit 0
# time bash -c 'yes | ~/.emacs.d/bin/doom install' || exit 0
time timeout 60m bash -c "yes | $EMACS_CONFIG_DIR/bin/doom install" || exit 0
$EMACS_CONFIG_DIR/bin/doom sync
time timeout 60m bash -c "yes | $WORKSTATION_EMACS_CONFIG_DIR/bin/doom install" || exit 0
$WORKSTATION_EMACS_CONFIG_DIR/bin/doom sync
echo FINISHED INSTALLING DOOM;
}
}
Expand Down Expand Up @@ -800,6 +791,21 @@ This is the kind of thing that sets up the "foundation" for everything else.
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='[email protected]: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

#+end_src
** library of shell functions
Expand Down Expand Up @@ -898,11 +904,11 @@ set +u
source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
set -u

EMACS_CONFIG_DIR=~/.config/emacs
source ~/workstation/lib/shell/foundation.sh

function find_emacs_init() {
init_file="";
for x in "$EMACS_CONFIG_DIR/early-init.el" "$EMACS_CONFIG_DIR/init.el"; do
for x in "$WORKSTATION_EMACS_CONFIG_DIR/early-init.el" "$WORKSTATION_EMACS_CONFIG_DIR/init.el"; do
if [[ -f "$x" ]]; then
init_file="$x"
break;
Expand Down

0 comments on commit 908ae36

Please sign in to comment.