Skip to content

Commit

Permalink
finish switch from functions to executables
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmccracken committed Dec 31, 2023
1 parent 9399536 commit 603db94
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 61 deletions.
32 changes: 5 additions & 27 deletions bootstrap-workstation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,6 @@ function clone_repo_and_checkout_at() {
git remote set-url origin $4
}
# clone_repo_and_checkout_at_function ends here

# [[file:workstation.org::restart_nix_deamon_function][restart_nix_deamon_function]]
function restart_nix_daemon_linux() {
sudo systemctl restart nix-daemon.service;
}

function restart_nix_daemon_mac() {
set +e
sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
set -e
}

function restart_nix_daemon () {
if is_mac; then restart_nix_daemon_mac; fi
if is_linux; then restart_nix_daemon_linux; fi
}
# restart_nix_deamon_function ends here

info starting workstation bootstrap
is_mac && {
info ensuring xcode is installed
Expand Down Expand Up @@ -302,19 +283,16 @@ source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
set -u

~/workstation/lib/shell/setup/install_doom_emacs_no_nix.sh
info "building the 'ws' script"
~/workstation/lib/shell/setup/build_ws_tool.sh

echo "building the 'ws' script"
cd ~/workstation/wshs
nix build --no-link -L .#"wshs:exe:bww" .#"wshs:exe:ws"
echo "running the 'ws install' process"
$(nix path-info .#"wshs:exe:ws")/bin/ws install -m "$WORKSTATION_NAME";
echo "'ws install' process completed"
info "running the 'ws install' process"
~/workstation/lib/shell/setup/ws_install.sh
info "'ws install' process completed"

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

cat <<-EOF
Expand Down
7 changes: 7 additions & 0 deletions lib/shell/setup/build_ws_tool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Build WS tool

# [[file:../../../workstation.org::*Build WS tool][Build WS tool:1]]
cd ~/workstation/wshs
nix build --no-link -L .#"wshs:exe:bww" .#"wshs:exe:ws"
# Build WS tool:1 ends here
17 changes: 7 additions & 10 deletions lib/shell/setup/restart_nix_deamon.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
# restart nix daemons
# Sometimes we need to restart the nix daemons, e.g. after editing the nix config
# file.


# External Script:

# [[file:../../../workstation.org::*restart nix daemons][restart nix daemons:2]]
# [[file:../../../workstation.org::*restart nix daemons][restart nix daemons:1]]
source ~/workstation/lib/shell/funcs.sh
function restart_nix_daemon_linux() {
sudo systemctl restart nix-daemon.service;
Expand All @@ -16,9 +16,6 @@ function restart_nix_daemon_mac() {
set -e
}

function restart_nix_daemon () {
if is_mac; then restart_nix_daemon_mac; fi
if is_linux; then restart_nix_daemon_linux; fi
}
restart_nix_daemon
# restart nix daemons:2 ends here
if is_mac; then restart_nix_daemon_mac; fi
if is_linux; then restart_nix_daemon_linux; fi
# restart nix daemons:1 ends here
7 changes: 7 additions & 0 deletions lib/shell/setup/ws_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Run WS install

# [[file:../../../workstation.org::*Run WS install][Run WS install:1]]
cd ~/workstation/wshs
$(nix path-info .#"wshs:exe:ws")/bin/ws install -m "$WORKSTATION_NAME";
# Run WS install:1 ends here
43 changes: 19 additions & 24 deletions workstation.org
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ fi
«is_git_repo_cloned_at_function»

«clone_repo_and_checkout_at_function»

«restart_nix_deamon_function»

#+end_src
*** Log that bootstrap is starting
#+begin_src shell
Expand Down Expand Up @@ -377,22 +374,19 @@ management.
#+end_src
*** set up 'ws' workstation tool
#+begin_src shell :noweb yes
info "building the 'ws' script"
~/workstation/lib/shell/setup/build_ws_tool.sh

echo "building the 'ws' script"
cd ~/workstation/wshs
nix build --no-link -L .#"wshs:exe:bww" .#"wshs:exe:ws"
echo "running the 'ws install' process"
$(nix path-info .#"wshs:exe:ws")/bin/ws install -m "$WORKSTATION_NAME";
echo "'ws install' process completed"

info "running the 'ws install' process"
~/workstation/lib/shell/setup/ws_install.sh
info "'ws install' process completed"
#+end_src
*** link dotfiles into place
#+begin_src shell :noweb yes

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

#+end_src
*** set up workstation secrets
#+begin_src shell :noweb yes
Expand Down Expand Up @@ -567,8 +561,8 @@ emit_nix_conf_content | \
*** restart nix daemons
Sometimes we need to restart the nix daemons, e.g. after editing the nix config
file.
#+name: restart_nix_deamon_function
#+begin_src shell :noweb yes
#+begin_src sh :tangle ./lib/shell/setup/restart_nix_deamon.sh :shebang "#!/usr/bin/env bash" :noweb yes
source ~/workstation/lib/shell/funcs.sh
function restart_nix_daemon_linux() {
sudo systemctl restart nix-daemon.service;
}
Expand All @@ -580,17 +574,8 @@ function restart_nix_daemon_mac() {
set -e
}

function restart_nix_daemon () {
if is_mac; then restart_nix_daemon_mac; fi
if is_linux; then restart_nix_daemon_linux; fi
}
#+end_src

External Script:
#+begin_src sh :tangle ./lib/shell/setup/restart_nix_deamon.sh :shebang "#!/usr/bin/env bash" :noweb yes
source ~/workstation/lib/shell/funcs.sh
«restart_nix_deamon_function»
restart_nix_daemon
if is_mac; then restart_nix_daemon_mac; fi
if is_linux; then restart_nix_daemon_linux; fi
#+end_src
*** Install Nix
#+begin_src sh :tangle ./lib/shell/setup/ensure_nix_installed.sh :shebang "#!/usr/bin/env bash" :noweb yes
Expand Down Expand Up @@ -626,6 +611,16 @@ source ~/workstation/lib/shell/foundation.sh

#+end_src

*** Build WS tool
#+begin_src sh :tangle ./lib/shell/setup/build_ws_tool.sh :shebang "#!/usr/bin/env bash" :noweb yes
cd ~/workstation/wshs
nix build --no-link -L .#"wshs:exe:bww" .#"wshs:exe:ws"
#+end_src
*** Run WS install
#+begin_src sh :tangle ./lib/shell/setup/ws_install.sh :shebang "#!/usr/bin/env bash" :noweb yes
cd ~/workstation/wshs
$(nix path-info .#"wshs:exe:ws")/bin/ws install -m "$WORKSTATION_NAME";
#+end_src
*** Install nix-darwin
#+begin_src sh :tangle ./lib/shell/setup/install_nix_darwin.sh :shebang "#!/usr/bin/env bash" :noweb yes

Expand Down

0 comments on commit 603db94

Please sign in to comment.