Skip to content

Commit

Permalink
feat: finish initial local installer script
Browse files Browse the repository at this point in the history
  • Loading branch information
Swarsel committed Dec 18, 2024
1 parent ffb331f commit 1df9a45
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions SwarselSystems.org
Original file line number Diff line number Diff line change
Expand Up @@ -3040,11 +3040,24 @@ This program sets up a new NixOS host.
git clone https://github.com/Swarsel/.dotfiles.git
fi

local_keys=$(ssh-add -L)
pub_key=$(cat /home/"$target_user"/.dotfiles/secrets/keys/ssh/nbl-imba-2.pub)
read -ra pub_arr <<< "$pub_key"

cd .dotfiles
if [[ $local_keys == *"${pub_arr[1]}"* ]]; then
yellow "The ssh key for this configuration is not available."
green "Adjusting flake.nix so that the configuration is buildable"
sed -i '/nix-secrets = {/,/^[[:space:]]*};/d' flake.nix
fi
sudo nixos-generate-config --dir /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/
git add /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/hardware-configuration.nix
green "Installing flake $target_flake"
sudo nixos-rebuild --show-trace --flake .#"$target_flake" --keep-going switch
yellow "Please keep in mind that this is only a demo of the configuration. Things might break unexpectedly."
git restore --staged /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/hardware-configuration.nix
git restore /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/hardware-configuration.nix
git restore /home/"$target_user"/.dotfiles/flake.nix
#+end_src


Expand Down
13 changes: 13 additions & 0 deletions scripts/swarsel-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,21 @@ if [ ! -d /home"$target_user"/.dotfiles ]; then
git clone https://github.com/Swarsel/.dotfiles.git
fi

local_keys=$(ssh-add -L)
pub_key=$(cat /home/"$target_user"/.dotfiles/secrets/keys/ssh/nbl-imba-2.pub)
read -ra pub_arr <<< "$pub_key"

cd .dotfiles
if [[ $local_keys == *"${pub_arr[1]}"* ]]; then
yellow "The ssh key for this configuration is not available."
green "Adjusting flake.nix so that the configuration is buildable"
sed -i '/nix-secrets = {/,/^[[:space:]]*};/d' flake.nix
fi
sudo nixos-generate-config --dir /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/
git add /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/hardware-configuration.nix
green "Installing flake $target_flake"
sudo nixos-rebuild --show-trace --flake .#"$target_flake" --keep-going switch
yellow "Please keep in mind that this is only a demo of the configuration. Things might break unexpectedly."
git restore --staged /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/hardware-configuration.nix
git restore /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/hardware-configuration.nix
git restore /home/"$target_user"/.dotfiles/flake.nix

0 comments on commit 1df9a45

Please sign in to comment.