Skip to content

Commit

Permalink
use a few more scripts on system
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmccracken committed Nov 17, 2023
1 parent d62d1c5 commit 35758db
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 76 deletions.
24 changes: 1 addition & 23 deletions bootstrap-workstation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,28 +258,6 @@ function ensure_nix_installed () {
}
# ensure_nix_installed_function ends here

# [[file:workstation.org::nix_darwin_rebuild_flake_function][nix_darwin_rebuild_flake_function]]
function nix_darwin_rebuild_flake() {
nix build --extra-experimental-features "nix-command flakes" \
~/workstation\#darwinConfigurations.${WORKSTATION_NAME}.system
./result/sw/bin/darwin-rebuild switch --flake ~/workstation#${WORKSTATION_NAME}

rm -rf ./result
}
# nix_darwin_rebuild_flake_function ends here

# [[file:workstation.org::install_nix_darwin_function][install_nix_darwin_function]]

function install_nix_darwin() {
cd $WORKSTATION_DIR
nix-build https://github.com/LnL7/nix-darwin/archive/${WORKSTATION_NIX_DARWIN_VERSION}.tar.gz -A installer
./result/bin/darwin-installer

nix_darwin_rebuild_flake
}

# install_nix_darwin_function ends here

info starting workstation bootstrap
is_mac && {
info ensuring xcode is installed
Expand Down Expand Up @@ -364,7 +342,7 @@ is_linux && {

is_mac && {
info installing darwin-nix
install_nix_darwin
~/workstation/lib/shell/setup/install_nix_darwin.sh
info finished installing darwin-nix
}

Expand Down
28 changes: 9 additions & 19 deletions lib/shell/setup/install_nix_darwin.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
#!/usr/bin/env bash
# [[file:../../../workstation.org::*Install nix-darwin][Install nix-darwin:2]]
source ~/workstation/lib/shell/foundation.sh
source ~/workstation/lib/shell/setup/workstation_setup_verions.sh

function nix_darwin_rebuild_flake() {
nix build --extra-experimental-features "nix-command flakes" \
~/workstation\#darwinConfigurations.${WORKSTATION_NAME}.system
./result/sw/bin/darwin-rebuild switch --flake ~/workstation#${WORKSTATION_NAME}
# Install nix-darwin

rm -rf ./result
}

function install_nix_darwin() {
cd $WORKSTATION_DIR
nix-build https://github.com/LnL7/nix-darwin/archive/${WORKSTATION_NIX_DARWIN_VERSION}.tar.gz -A installer
./result/bin/darwin-installer
# [[file:../../../workstation.org::*Install nix-darwin][Install nix-darwin:1]]
source ~/workstation/lib/shell/foundation.sh
source ~/workstation/lib/shell/setup/workstation_setup_versions.sh

nix_darwin_rebuild_flake
}
cd $WORKSTATION_DIR
nix-build https://github.com/LnL7/nix-darwin/archive/${WORKSTATION_NIX_DARWIN_VERSION}.tar.gz -A installer
./result/bin/darwin-installer

install_nix_darwin
# Install nix-darwin:2 ends here
source ~/workstation/lib/shell/setup/nix-darwin-rebuild-flake.sh
# Install nix-darwin:1 ends here
12 changes: 12 additions & 0 deletions lib/shell/setup/nix-darwin-rebuild-flake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# command to have darwin build and switch to next generation

# [[file:../../../workstation.org::*command to have darwin build and switch to next generation][command to have darwin build and switch to next generation:1]]
set -u # error in case WORKSTATION_NAME is not set

nix build --extra-experimental-features "nix-command flakes" \
~/workstation\#darwinConfigurations.${WORKSTATION_NAME}.system
./result/sw/bin/darwin-rebuild switch --flake ~/workstation#${WORKSTATION_NAME}

rm -rf ./result
# command to have darwin build and switch to next generation:1 ends here
46 changes: 12 additions & 34 deletions workstation.org
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,6 @@ fi

«ensure_nix_installed_function»

«nix_darwin_rebuild_flake_function»

«install_nix_darwin_function»

#+end_src
*** Log that bootstrap is starting
#+begin_src shell
Expand Down Expand Up @@ -366,7 +362,7 @@ is_linux && {

is_mac && {
info installing darwin-nix
install_nix_darwin
~/workstation/lib/shell/setup/install_nix_darwin.sh
info finished installing darwin-nix
}

Expand Down Expand Up @@ -685,27 +681,16 @@ install_doom_emacs_no_nix
#+end_src

*** Install nix-darwin
#+name: install_nix_darwin_function
#+begin_src shell

function install_nix_darwin() {
cd $WORKSTATION_DIR
nix-build https://github.com/LnL7/nix-darwin/archive/${WORKSTATION_NIX_DARWIN_VERSION}.tar.gz -A installer
./result/bin/darwin-installer

nix_darwin_rebuild_flake
}

#+end_src

#+begin_src sh :tangle ./lib/shell/setup/install_nix_darwin.sh :shebang "#!/usr/bin/env bash" :noweb yes

source ~/workstation/lib/shell/foundation.sh
source ~/workstation/lib/shell/setup/workstation_setup_verions.sh
source ~/workstation/lib/shell/setup/workstation_setup_versions.sh

cd $WORKSTATION_DIR
nix-build https://github.com/LnL7/nix-darwin/archive/${WORKSTATION_NIX_DARWIN_VERSION}.tar.gz -A installer
./result/bin/darwin-installer

«nix_darwin_rebuild_flake_function»
«install_nix_darwin_function»
install_nix_darwin
source ~/workstation/lib/shell/setup/nix-darwin-rebuild-flake.sh

#+end_src
*** Install home manager
Expand Down Expand Up @@ -894,21 +879,14 @@ to be set, which provides the 'identity' of the current machine -- not all
machines have the same home manager configurations. This environment variable is
set by other mechanisms withing the workstation system.
*** command to have darwin build and switch to next generation
#+begin_src sh :shebang "#!/usr/bin/env bash" :tangle ./bin/nix-darwin-rebuild-flake.sh :noweb yes
#+begin_src sh :shebang "#!/usr/bin/env bash" :tangle ./lib/shell/setup/nix-darwin-rebuild-flake.sh :noweb yes
set -u # error in case WORKSTATION_NAME is not set
«nix_darwin_rebuild_flake_function»
nix_darwin_rebuild_flake_function
#+end_src

#+name: nix_darwin_rebuild_flake_function
#+begin_src sh
function nix_darwin_rebuild_flake() {
nix build --extra-experimental-features "nix-command flakes" \
~/workstation\#darwinConfigurations.${WORKSTATION_NAME}.system
./result/sw/bin/darwin-rebuild switch --flake ~/workstation#${WORKSTATION_NAME}
nix build --extra-experimental-features "nix-command flakes" \
~/workstation\#darwinConfigurations.${WORKSTATION_NAME}.system
./result/sw/bin/darwin-rebuild switch --flake ~/workstation#${WORKSTATION_NAME}

rm -rf ./result
}
rm -rf ./result
#+end_src
* Post-bootstrap setup
* Manual installation and setup
Expand Down

0 comments on commit 35758db

Please sign in to comment.