mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 15:11:34 +01:00
install-anywhere: Work in completely temporary directory
This commit is contained in:
parent
2182e06bb6
commit
e3479f2070
1 changed files with 17 additions and 18 deletions
|
|
@ -19,7 +19,7 @@ _: {
|
||||||
|
|
||||||
host="$1"
|
host="$1"
|
||||||
destination="$2"
|
destination="$2"
|
||||||
root="/tmp/anywhere/$host"
|
root="$(mktemp --directory)"
|
||||||
|
|
||||||
impermanence="$(nix eval ".#nixosConfigurations.$host.config.custom.persistence.enable")"
|
impermanence="$(nix eval ".#nixosConfigurations.$host.config.custom.persistence.enable")"
|
||||||
if [ "$impermanence" = true ]; then
|
if [ "$impermanence" = true ]; then
|
||||||
|
|
@ -28,7 +28,6 @@ _: {
|
||||||
ssh_dir="$root/etc/ssh"
|
ssh_dir="$root/etc/ssh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$ssh_dir/ssh_host_ed25519_key" ]; then
|
|
||||||
echo "==> Generating new SSH host keys..."
|
echo "==> Generating new SSH host keys..."
|
||||||
mkdir --parents "$ssh_dir"
|
mkdir --parents "$ssh_dir"
|
||||||
ssh-keygen -C "root@$host" -f "$ssh_dir/ssh_host_ed25519_key" -N "" -q
|
ssh-keygen -C "root@$host" -f "$ssh_dir/ssh_host_ed25519_key" -N "" -q
|
||||||
|
|
@ -38,21 +37,21 @@ _: {
|
||||||
echo "$new_age_key" > "hosts/$host/keys/age.pub"
|
echo "$new_age_key" > "hosts/$host/keys/age.pub"
|
||||||
|
|
||||||
echo "==> Updating SOPS secrets..."
|
echo "==> Updating SOPS secrets..."
|
||||||
if BW_SESSION="$(bw unlock --raw || bw login --raw)"; then
|
BW_SESSION="$(bw unlock --raw || bw login --raw)"
|
||||||
export BW_SESSION
|
export BW_SESSION
|
||||||
fi
|
|
||||||
SOPS_AGE_KEY="$(bw get notes 'admin age-key')"
|
SOPS_AGE_KEY="$(bw get notes 'admin age-key')"
|
||||||
export SOPS_AGE_KEY
|
export SOPS_AGE_KEY
|
||||||
SOPS_CONFIG="$(nix build .#sops-config --print-out-paths)"
|
SOPS_CONFIG="$(nix build .#sops-config --print-out-paths)"
|
||||||
export SOPS_CONFIG
|
export SOPS_CONFIG
|
||||||
sops updatekeys --yes "hosts/$host/secrets.json"
|
sops updatekeys --yes "hosts/$host/secrets.json"
|
||||||
fi
|
|
||||||
|
|
||||||
echo "==> Installing system..."
|
echo "==> Installing system..."
|
||||||
nix run github:nix-community/nixos-anywhere -- \
|
nix run github:nix-community/nixos-anywhere -- \
|
||||||
--extra-files "$root" \
|
--extra-files "$root" \
|
||||||
--flake ".#$host" \
|
--flake ".#$host" \
|
||||||
--target-host "$destination"
|
--target-host "$destination"
|
||||||
|
|
||||||
|
rm -rf "$root"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue