From 1cdec23e1a3a7f06a0a30cf036d7355ea601fc40 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Wed, 25 Dec 2024 16:21:32 +0100 Subject: build(scripts/deploy): Init This documents the commands used for the first deployment (i.e., with a full, disko-driven, disk formatting step). --- notes/deploy.md | 23 +++++++++++++++++++---- scripts/deploy.sh | 16 ++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100755 scripts/deploy.sh diff --git a/notes/deploy.md b/notes/deploy.md index 2b274b5..8d159b1 100644 --- a/notes/deploy.md +++ b/notes/deploy.md @@ -1,8 +1,23 @@ -# Full redeployment +# Full redeployment or first deployment -After a complete server purge just load up the newest NixOS ISO, set the root password and run: +This requires a root password and _some_ Linux distribution running on it. + +We assume that following variables are set. + +```bash +HOST="" # e.g., server1 +SSH_URL="" # e.g., root@server1.vhack.eu +``` + +## Generate a networking configuration + +```bash +scp scripts/mk_network_config.sh "$SSH_URL:/root/" +ssh "$SSH_URL" /root/mk_networking_config.sh > "hosts/by-name/$HOST/networking.nix" +``` + +## Re-deploy ```bash -ipv4_address=$(dig +short ""); # ipv6 seems to fail in this context -nix run github:numtide/nixos-anywhere -- --flake .# root@"$ipv4_address" +./scripts/deploy.sh "$SSH_URL" "$HOST" ``` diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 0000000..5c7b0e6 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +[ "$#" -ne 2 ] && { + echo "Usage: $1 " + exit 2 +} +ssh_url="$1" +host_name="$2" +root="$(git rev-parse --show-toplevel)" + +nix run github:numtide/nixos-anywhere -- \ + --flake ".#$host_name" \ + --target-host "$ssh_url" \ + --generate-hardware-config nixos-generate-config "$root/hosts/by-name/$host_name/hardware_config_$ssh_url.nix" + +# vim: ft=sh -- cgit 1.4.1