Skip to content

Commit

Permalink
extract nix darwin install
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmccracken committed Nov 4, 2023
1 parent bcc11b2 commit 6998214
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 12 deletions.
19 changes: 13 additions & 6 deletions bootstrap-workstation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ function nix_darwin_rebuild_flake() {
}
# 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 @@ -343,12 +355,7 @@ is_linux && {

is_mac && {
info installing darwin-nix
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
info finished installing darwin-nix
}

Expand Down
22 changes: 22 additions & 0 deletions lib/shell/setup/install_doom_emacs_no_nix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# [[file:../../../workstation.org::*Install doom emacs without nix][Install doom emacs without nix:2]]
source ~/workstation/lib/shell/foundation.sh

function install_doom_emacs_no_nix() {
{
cd $WORKSTATION_EMACS_CONFIG_DIR
[[ "$(git remote get-url origin)" == 'https://github.com/hlissner/doom-emacs' ]]
} || {
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 | $WORKSTATION_EMACS_CONFIG_DIR/bin/doom install" || exit 0
$WORKSTATION_EMACS_CONFIG_DIR/bin/doom sync
echo FINISHED INSTALLING DOOM;
}
}
install_doom_emacs_no_nix
# Install doom emacs without nix:2 ends here
23 changes: 23 additions & 0 deletions lib/shell/setup/install_nix_darwin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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}

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

nix_darwin_rebuild_flake
}

install_nix_darwin
# Install nix-darwin:2 ends here
41 changes: 35 additions & 6 deletions workstation.org
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ fi

«nix_darwin_rebuild_flake_function»

«install_nix_darwin_function»

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

is_mac && {
info installing darwin-nix
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
info finished installing darwin-nix
}

Expand Down Expand Up @@ -664,6 +661,38 @@ function install_doom_emacs_no_nix() {
echo FINISHED INSTALLING DOOM;
}
}
#+end_src

#+begin_src sh :tangle ./lib/shell/setup/install_doom_emacs_no_nix.sh :shebang "#!/usr/bin/env bash" :noweb yes
source ~/workstation/lib/shell/foundation.sh

«install_doom_emacs_no_nix_function»
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

«nix_darwin_rebuild_flake_function»
«install_nix_darwin_function»
install_nix_darwin

#+end_src
* Nix components
** Home Manager
Expand Down

0 comments on commit 6998214

Please sign in to comment.