Skip to content

Commit

Permalink
migrate link-dotfiles to workstation.org
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmccracken committed Nov 15, 2023
1 parent 7e2de9f commit 167f089
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 20 deletions.
20 changes: 10 additions & 10 deletions bootstrap-workstation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -433,19 +433,19 @@ echo "'ws install' process completed"
info linking dotfiles that should be symlinked
bash ~/workstation/bin/link-dotfiles.sh -f -c
bash ~/workstation/lib/shell/setup/link-dotfiles.sh -f -c
info finished linking dotfiles
set +e
echo "Running final installs (install)"
if is_linux; then
echo "is linux, installing ripgrep, fdfind, etc via apt";
time sudo apt-get install ripgrep fd-find zsh make libtool libvterm-dev;
echo "done running final installs";
else
echo "linux not detected, no final installs necessary";
fi
# set +e
# echo "Running final installs (install)"
# if is_linux; then
# echo "is linux, installing ripgrep, fdfind, etc via apt";
# time sudo apt-get install ripgrep fd-find zsh make libtool libvterm-dev;
# echo "done running final installs";
# else
# echo "linux not detected, no final installs necessary";
# fi
initial_bitwarden_sync
Expand Down
3 changes: 3 additions & 0 deletions bin/link-dotfiles.sh → lib/shell/setup/link-dotfiles.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
# Linking dotfiles

# [[file:../../../workstation.org::*Linking dotfiles][Linking dotfiles:1]]
source ~/workstation/lib/shell/funcs.sh

export FORCE=false;
Expand Down Expand Up @@ -105,3 +107,4 @@ ln_norm Brewfile.lock.json
ln_norm bitbar

ln_dotfile_n config/git
# Linking dotfiles:1 ends here
129 changes: 119 additions & 10 deletions workstation.org
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ echo "'ws install' process completed"
#+begin_src shell :noweb yes

info linking dotfiles that should be symlinked
bash ~/workstation/bin/link-dotfiles.sh -f -c
bash ~/workstation/lib/shell/setup/link-dotfiles.sh -f -c
info finished linking dotfiles

#+end_src
Expand All @@ -421,15 +421,15 @@ TODO fix these, should move to home manager.

#+begin_src shell :noweb yes

set +e
echo "Running final installs (install)"
if is_linux; then
echo "is linux, installing ripgrep, fdfind, etc via apt";
time sudo apt-get install ripgrep fd-find zsh make libtool libvterm-dev;
echo "done running final installs";
else
echo "linux not detected, no final installs necessary";
fi
# set +e
# echo "Running final installs (install)"
# if is_linux; then
# echo "is linux, installing ripgrep, fdfind, etc via apt";
# time sudo apt-get install ripgrep fd-find zsh make libtool libvterm-dev;
# echo "done running final installs";
# else
# echo "linux not detected, no final installs necessary";
# fi

#+end_src
*** set up workstation secrets
Expand Down Expand Up @@ -768,6 +768,115 @@ function initial_bitwarden_sync() {
«initial_bitwarden_sync_function»
initial_bitwarden_sync

#+end_src
*** Linking dotfiles
#+begin_src sh :tangle ./lib/shell/setup/link-dotfiles.sh :shebang "#!/usr/bin/env bash" :noweb yes
source ~/workstation/lib/shell/funcs.sh

export FORCE=false;
export VERBOSE=false;
export CHECK=false;

function error() {
printf "$@" >&2
exit 1
}

function handle_force() {
if [ "$FORCE" = "true" ]; then
mv_dated_backup "$1"
fi
}

function verbose() {
if [ "$VERBOSE" = "true" ]; then
echo "$@"
fi
}

function check () {
if [ "$CHECK" = "true" ] || [ "$VERBOSE" = "true" ]; then
echo "$@"
fi
}


function ln_helper() {
dest=~/$2$1
src=~/workstation/dotfiles/$1
curr=$(readlink -f "$dest")

if [ -L "$dest" ] && [ "$curr" = "$src" ]; then
check "OK: $dest already points to $src"
else
check "NOT OK: $dest does not point to $src"
if [ "$CHECK" = "true" ] && ! [ "$FORCE" = "true" ]; then
exit 11
fi

handle_force $dest
ln -s "$src" "$dest"
fi
}

function ln_dotfile() {
ln_helper $1 "."
}

function ln_norm() {
ln_helper $1 ""
}

function ln_dotfile_n() {
src=~/workstation/dotfiles/$1
dest=~/.$1
destdir=$(dirname dest)

if [ ! -d $destdir ]; then
mkdir -p $destdir
fi

ln_helper $1 "."
}

while (( $# > 0 )); do
opt="$1"
shift

case $opt in
-f)
FORCE=true
;;
-v)
VERBOSE=true
;;
-c)
CHECK=true
;;
*)
error "%s: error, unknown option '%s'" "$0" "$opt"
exit 1
;;
esac
done

ln_dotfile bashrc
ln_dotfile ghci
ln_dotfile gitconfig
ln_dotfile hammerspoon
ln_dotfile nix-channels
ln_dotfile npmrc
ln_dotfile reddup.yml
ln_dotfile zshrc
ln_dotfile zshrc.aeglos.sh
ln_dotfile doom.d

ln_norm Brewfile
ln_norm Brewfile.lock.json
ln_norm bitbar

ln_dotfile_n config/git

#+end_src

* Nix components
Expand Down

0 comments on commit 167f089

Please sign in to comment.