mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 09:07:21 +01:00
feat: finish initial local installer script
This commit is contained in:
parent
ffb331ff3e
commit
d33e6eb1f3
2 changed files with 35 additions and 5 deletions
|
|
@ -2976,7 +2976,7 @@ This program sets up a new NixOS host.
|
|||
}
|
||||
#+end_src
|
||||
|
||||
**** install
|
||||
**** swarsel-install
|
||||
|
||||
This program sets up a new NixOS host.
|
||||
|
||||
|
|
@ -3035,16 +3035,31 @@ This program sets up a new NixOS host.
|
|||
|
||||
cd /home/"$target_user"
|
||||
|
||||
if [ ! -d /home"$target_user"/.dotfiles ]; then
|
||||
if [ ! -d /home/"$target_user"/.dotfiles ]; then
|
||||
green "Cloning repository from GitHub"
|
||||
git clone https://github.com/Swarsel/.dotfiles.git
|
||||
fi
|
||||
|
||||
local_keys=$(ssh-add -L || true)
|
||||
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
|
||||
git add 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
|
||||
sudo nixos-rebuild --show-trace --flake .#"$target_flake" boot
|
||||
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 --staged /home/"$target_user"/.dotfiles/flake.nix
|
||||
git restore /home/"$target_user"/.dotfiles/flake.nix
|
||||
#+end_src
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,13 +52,28 @@ done
|
|||
|
||||
cd /home/"$target_user"
|
||||
|
||||
if [ ! -d /home"$target_user"/.dotfiles ]; then
|
||||
if [ ! -d /home/"$target_user"/.dotfiles ]; then
|
||||
green "Cloning repository from GitHub"
|
||||
git clone https://github.com/Swarsel/.dotfiles.git
|
||||
fi
|
||||
|
||||
local_keys=$(ssh-add -L || true)
|
||||
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
|
||||
git add 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
|
||||
sudo nixos-rebuild --show-trace --flake .#"$target_flake" boot
|
||||
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 --staged /home/"$target_user"/.dotfiles/flake.nix
|
||||
git restore /home/"$target_user"/.dotfiles/flake.nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue