nix/docs/setup.sh

33 lines
890 B
Bash
Raw Normal View History

2023-09-22 14:23:12 +02:00
#!/usr/bin/env bash
2023-09-18 09:16:55 +02:00
2023-09-22 14:09:37 +02:00
sudo mkdir /nix/var/nix/profiles/per-user/albert
pushd /etc/nixos/git
home-manager switch -b backup --flake .
2023-09-18 09:16:55 +02:00
source ~/.bashrc
# Import and trust the GPG key
read -p "Path to GPG Private Key: " gpgKey
gpg --import $gpgKey
echo -e "5\ny\n" | gpg --command-fd 0 --expert --edit-key 64F6C4EB46C4543A trust
# Setup SOPS
2023-09-22 14:09:37 +02:00
ssh-to-pgp -i /etc/ssh/ssh_host_rsa_key -o /etc/nixos/git/keys/hosts/$(hostname).asc
2023-09-19 10:01:58 +02:00
# Update your .sops.yaml with this key
2023-09-18 09:16:55 +02:00
sops-update secrets/secrets.yaml
2023-09-22 14:09:37 +02:00
for i in $(ls secrets/):
2023-09-18 09:16:55 +02:00
# Set up ssh keys
ssh-keygen -t rsa -b 8192 -f ~/.ssh/id_rsa -N ""
2023-09-22 14:09:37 +02:00
echo "" >> ./keys/ssh/keys.txt
echo "# `whoami`@`hostname`" >> ./keys/ssh/keys.txt
cat /home/albert/.ssh/id_rsa.pub >> ./keys/ssh/keys.txt
2023-09-18 09:16:55 +02:00
# Add all changes to git and and push
2023-09-19 10:01:58 +02:00
git add keys/hosts/`hostname`.asc
2023-09-22 14:09:37 +02:00
git commit -am "Setup: `whoami`@`hostname`"
2023-09-18 09:16:55 +02:00
git push
2023-09-22 14:09:37 +02:00
popd
echo
echo
echo "Complete."