nix/docs/setup-no-usb.sh

65 lines
1.9 KiB
Bash
Raw Normal View History

2024-03-15 02:28:10 +01:00
#!/usr/bin/env bash
pushd /etc/nixos/git
# Home-Manager Setup
echo ">>> Setting up Home Manager..... "
sudo mkdir /nix/var/nix/profiles/per-user/albert
# For some reason the syncthing folder takes this over and makes it owned by root
sudo mkdir /home/albert/.config
sudo chown albert:albert /home/albert/.config
sudo chown -R albert:root /nix/var/nix/profiles/per-user/albert
home-manager switch -b backup --flake /etc/nixos/git
source ~/.bashrc
# Import and trust the GPG key
echo ">>> Setting up user GPG key..... "
gpg --import ~/privkey.asc
echo -e "5\ny\n" | gpg --command-fd 0 --expert --edit-key albert@sysctl.io trust
# Setup SOPS
echo "Setting up SOPS keys..... "
echo ">>> !!!!!"
echo ">>> !!!!!"
echo ">>> !!!!!"
echo ">>> !!!!! Copy this signature to .sops.yaml: "
echo ">>> !!!!!"
echo ">>> !!!!!"
echo ">>> !!!!!"
# Currently only RSA keys are allowed
sudo ssh-to-pgp \
-comment "Generated `date +%Y.%m.%d`" \
-email "root@`hostname`" \
-i /etc/ssh/ssh_host_rsa_key \
-o /etc/nixos/git/keys/hosts/$(hostname).asc
# Set up ssh keys
echo ">>> Setting up SSH Keys..... "
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""
echo "" >> ./keys/ssh/keys.txt
echo "# (`date`) `whoami`@`hostname`" >> ./keys/ssh/keys.txt
cat /home/albert/.ssh/id_ed25519.pub >> ./keys/ssh/keys.txt
# echo ">>> Setting up Distributed Build SSH Keys..... "
# sudo ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ""
# echo "" >> ./keys/ssh/builder-keys.txt
# echo "# (`date`) root@`hostname`" >> ./keys/ssh/builder-keys.txt
# sudo cat /root/.ssh/id_ed25519.pub >> ./keys/ssh/builder-keys.txt
# Add all changes to git and and push
echo ">>> Pushing to git..... "
git add keys/hosts/`hostname`.asc
git commit -am "Setup: `hostname`"
git push
echo
echo
echo ">>> Complete. Once '.sops.yaml' is updated, "
echo ">>> run 'update-secrets' and reboot."
echo
echo
echo ">>> Reminder: Upload these changes to git"
popd