Unfuck secrets

Don't worry why all the commit hashes suddenly changed, it's fine.

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-02-19 13:06:35 +00:00
parent 5f905e76c6
commit 7737abc45e
7 changed files with 205 additions and 32 deletions

View File

@@ -64,7 +64,7 @@ prepare_disk() {
copy_keys() {
mkdir -p "$root/persist/etc/ssh"
cp "$flake/hosts/$host/secrets/ssh_host_ed25519_key" "$root/persist/etc/ssh/ssh_host_ed25519_key"
cp -f "$flake/hosts/$host/secrets/ssh_host_ed25519_key" "$root/persist/etc/ssh/ssh_host_ed25519_key"
for path in "$flake/hosts/$host/users"/*; do
if [[ -z "$key" ]]; then
@@ -74,11 +74,14 @@ copy_keys() {
local user
user=$(basename "$path")
mkdir -p "$root/persist/home/$user/.config/sops-nix"
cp "$flake/secrets/$key/key.txt" "$root/persist/home/$user/.config/sops-nix/key.txt"
chown -R "$(cat "$flake/hosts/$host/users/$user/uid"):100" "$root/persist/home/$user"
cp -f "$flake/secrets/$key/key.txt" "$root/persist/home/$user/.config/sops-nix/key.txt"
done
}
set_permissions() {
chown -R "$(cat "$flake/hosts/$host/users/$user/uid"):100" "$root/persist/home/$user"
}
install() {
nixos-install --root "$root" --flake "$flake#$host" --no-root-passwd
}
@@ -139,12 +142,14 @@ main() {
install)
prepare_disk "destroy,format,mount"
copy_keys
set_permissions
install
if [[ "$copy_config_flag" == "true" ]]; then copy_config; fi
if [[ "$reboot_flag" == "true" ]]; then finish; fi
;;
repair)
prepare_disk "mount"
copy_keys
install
if [[ "$reboot_flag" == "true" ]]; then finish; fi
;;