diff --git a/AGENTS.md b/AGENTS.md index 0a661f5..2fdf139 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -47,7 +47,9 @@ nix develop nix run github:serokell/deploy-rs -- .#cryodev-main # Manual deployment via SSH -nixos-rebuild switch --flake .# --target-host root@ +nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" ``` ## Code Style & Conventions diff --git a/digest.txt b/digest.txt index c456c9f..e11d733 100644 --- a/digest.txt +++ b/digest.txt @@ -1,5 +1,5 @@ Directory structure: -└── cryodev/ +└── cryodev-server/ ├── README.md ├── AGENTS.md ├── constants.nix @@ -7,6 +7,9 @@ Directory structure: ├── flake.nix ├── .sops.yaml ├── apps/ + │ ├── install/ + │ │ ├── default.nix + │ │ └── install.sh │ └── rebuild/ │ ├── default.nix │ └── rebuild.sh @@ -333,7 +336,9 @@ nix develop nix run github:serokell/deploy-rs -- .#cryodev-main # Manual deployment via SSH -nixos-rebuild switch --flake .# --target-host root@ +nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" ``` ## Code Style & Conventions @@ -1240,6 +1245,7 @@ FILE: flake.nix }; in { + install = mkApp "install"; rebuild = mkApp "rebuild"; } ); @@ -1325,21 +1331,216 @@ FILE: flake.nix FILE: .sops.yaml ================================================ keys: - - &admin_key age1e8p35795htf7twrejyugpzw0qja2v33awcw76y4gp6acnxnkzq0s935t4t # Admin key (Steffen) + - &admin_key age1e8p35795htf7twrejyugpzw0qja2v33awcw76y4gp6acnxnkzq0s935t4t + - &cryodev-main_key age1y6hushuapy0k04mrvvpev0t8lq44w904r596jus44nhkflky0yhqgq2xx6 creation_rules: - path_regex: hosts/cryodev-main/secrets.yaml$ key_groups: - age: - - *admin_key - # - *server_key # Add server key here once obtained + - *admin_key + - *cryodev-main_key - path_regex: hosts/cryodev-pi/secrets.yaml$ key_groups: - age: - - *admin_key + - *admin_key # - *pi_key # Add pi key here once obtained +================================================ +FILE: apps/install/default.nix +================================================ +{ + writeShellApplication, + git, + ... +}: + +let + name = "install"; + text = builtins.readFile ./${name}.sh; +in +writeShellApplication { + inherit name text; + meta.mainProgram = name; + + runtimeInputs = [ + git + ]; +} + + + +================================================ +FILE: apps/install/install.sh +================================================ +#!/usr/bin/env bash + +# NixOS install script + + +### VARIABLES ### + +ASK_VERIFICATION=1 # Default to ask for verification +CONFIG_DIR="/tmp/nixos" # Directory to copy flake to / clone flake into +GIT_BRANCH="main" # Default Git branch +GIT_REPO="" # Git repository URL +HOSTNAME="" # Hostname +MNT="/mnt" # root mount point +SEPARATOR="________________________________________" # line separator + +### FUNCTIONS ### + +# Function to display help information +Show_help() { + echo "Usage: $0 [-r REPO] [-n HOSTNAME] [-b BRANCH] [-y] [-h]" + echo + echo "Options:" + echo " -r, --repo REPO Your NixOS configuration Git repository URL" + echo " -n, --hostname HOSTNAME Specify the hostname for the NixOS configuration" + echo " -b, --branch BRANCH Specify the Git branch to use (default: $GIT_BRANCH)" + echo " -y, --yes Do not ask for user verification before proceeding" + echo " -h, --help Show this help message and exit" +} + +# Function to format, partition, and mount disks for $HOSTNAME using disko +Run_disko() { + echo "$SEPARATOR" + echo "Running disko..." + nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode disko "$CONFIG_DIR"/hosts/"$HOSTNAME"/disks.nix +} + +# Function to format, partition, and mount disks for $HOSTNAME using a partitioning script +Run_script() { + echo "$SEPARATOR" + echo "Running partitioning script..." + bash "$CONFIG_DIR"/hosts/"$HOSTNAME"/disks.sh +} + +# Function to check mount points and partitioning +Check_partitioning() { + echo "$SEPARATOR" + echo "Printing mount points and partitioning..." + mount | grep "$MNT" + lsblk -f + [[ "$ASK_VERIFICATION" == 1 ]] && read -rp "Verify the mount points and partitioning. Press Ctrl+c to cancel or Enter to continue..." +} + +# Function to generate hardware configuration +Generate_hardware_config() { + [[ "$ASK_VERIFICATION" == 1 ]] && read -rp "No hardware configuration found. Press Ctrl+c to cancel or Enter to generate one..." + + echo "$SEPARATOR" + echo "Generating hardware configuration..." + nixos-generate-config --root "$MNT" --show-hardware-config > "$CONFIG_DIR"/hosts/"$HOSTNAME"/hardware.nix + + # Check if hardware configuration has been generated + if [[ ! -f "$CONFIG_DIR"/hosts/"$HOSTNAME"/hardware.nix ]]; then + echo "Error: Hardware configuration cannot be generated." + exit 1 + fi + + # Add configuration to git + git -C "$CONFIG_DIR" add hosts/"$HOSTNAME"/hardware.nix + + echo "Hardware configuration generated successfully." +} + +# Function to install configuration for $HOSTNAME +Install() { + # Check if hardware configuration exists + [[ ! -f "$CONFIG_DIR"/hosts/"$HOSTNAME"/hardware.nix ]] && Generate_hardware_config + + echo "$SEPARATOR" + echo "Installing NixOS..." + nixos-install --root "$MNT" --no-root-password --flake "$CONFIG_DIR"#"$HOSTNAME" && echo "You can reboot the system now." +} + +### PARSE ARGUMENTS ### + +while [[ "$#" -gt 0 ]]; do + case $1 in + -r|--repo) GIT_REPO="$2"; shift ;; + -b|--branch) GIT_BRANCH="$2"; shift ;; + -y|--yes) ASK_VERIFICATION=0 ;; + -h|--help) Show_help; exit 0 ;; + -n|--hostname) HOSTNAME="$2"; shift ;; + *) echo "Unknown option: $1"; Show_help; exit 1 ;; + esac + shift +done + +### PREREQUISITES ### + +echo "$SEPARATOR" +mkdir -p "$CONFIG_DIR" + +# Clone NixOS configuration from $GIT_REPO if provided +if [[ -n "$GIT_REPO" ]]; then + # Clone Git repo if directory is empty + if [[ -z "$(ls -A "$CONFIG_DIR" 2>/dev/null)" ]]; then + echo "Cloning NixOS configuration repo..." + git clone --depth 1 -b "$GIT_BRANCH" "$GIT_REPO" "$CONFIG_DIR" + + # Check if git repository has been cloned + if [[ ! -d "$CONFIG_DIR"/.git ]]; then + echo "Error: Git repository could not be cloned." + exit 1 + fi + else + echo "$CONFIG_DIR is not empty. Skip cloning $GIT_REPO." + fi +fi + +if [[ ! -f "$CONFIG_DIR"/flake.nix ]]; then + echo "Error: $CONFIG_DIR does not contain 'flake.nix'." + exit 1 +fi + +### CHOOSE CONFIG ### + +# If hostname is not provided via options, prompt the user +if [[ -z "$HOSTNAME" ]]; then + # Get list of available hostnames + HOSTNAMES=$(ls "$CONFIG_DIR"/hosts) + + echo "$SEPARATOR" + echo "Please choose a hostname to install its NixOS configuration." + echo "$HOSTNAMES" + read -rp "Enter hostname: " HOSTNAME + + # Check if hostname is empty + if [[ -z "$HOSTNAME" ]]; then + echo "Error: Hostname cannot be empty." + exit 1 + fi +fi + +### INSTALLATION ### + +# Check if NixOS configuration exists +if [[ -d "$CONFIG_DIR"/hosts/"$HOSTNAME" ]]; then + + # Check for existing disko configuration + if [[ -f "$CONFIG_DIR"/hosts/"$HOSTNAME"/disks.nix ]]; then + Run_disko || ( echo "Error: disko failed." && exit 1 ) + # Check for partitioning script + elif [[ -f "$CONFIG_DIR"/hosts/"$HOSTNAME"/disks.sh ]]; then + Run_script || ( echo "Error: Partitioning script failed." && exit 1 ) + else + echo "Error: No disko configuration (disks.nix) or partitioning script (disks.sh) found for host '$HOSTNAME'." + exit 1 + fi + + Check_partitioning + Install || ( echo "Error: Installation failed." && exit 1 ) +else + echo "Error: Configuration for host '$HOSTNAME' does not exist." + exit 1 +fi + + + ================================================ FILE: apps/rebuild/default.nix ================================================ @@ -1885,7 +2086,9 @@ For hosts not using automated deployment: nix build .#nixosConfigurations..config.system.build.toplevel # Deploy with nixos-rebuild -nixos-rebuild switch --flake .# --target-host root@ +nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" # Or using deploy-rs nix run github:serokell/deploy-rs -- .# @@ -2012,38 +2215,44 @@ FILE: docs/getting-started/first-install.md ================================================ # Erstinstallation (x86_64 Server) -Diese Anleitung beschreibt die **manuelle Installation** eines neuen x86_64 Servers (z.B. cryodev-main). +Diese Anleitung beschreibt die **Erstinstallation** eines neuen x86_64 Servers (z.B. cryodev-main). -> **Für Raspberry Pi:** Siehe [Neuen Raspberry Pi hinzufügen](new-client.md) - dort wird ein SD-Image automatisch gebaut. +> **Fuer Raspberry Pi:** Siehe [SD-Image erstellen](sd-image.md). -## Übersicht +## Uebersicht Bei der Erstinstallation gibt es ein Henne-Ei-Problem: -- SOPS-Secrets werden mit dem SSH-Host-Key verschlüsselt +- SOPS-Secrets werden mit dem SSH-Host-Key verschluesselt - Der SSH-Host-Key wird erst bei der Installation generiert -- Daher: Erst installieren, dann Secrets konfigurieren +- Daher: **Erst ohne Secrets installieren, dann Secrets konfigurieren** -## Voraussetzungen +### Ablauf -- Bootbares NixOS ISO ([Minimal ISO](https://nixos.org/download/#nixos-iso)) -- Netzwerkverbindung -- Host-Konfiguration in `hosts//` (ohne secrets.yaml) +``` +1. Services deaktivieren (die Secrets brauchen) +2. NixOS installieren +3. SSH-Host-Key extrahieren, SOPS konfigurieren, Secrets erstellen +4. Services reaktivieren und deployen +``` ## Schritt 1: Host-Konfiguration vorbereiten +> Falls der Host bereits in `hosts/` und `flake.nix` existiert, ueberspringe 1.1-1.3. + ### 1.1 Template kopieren ```bash -cp -r templates/generic-server hosts/neuer-server +cp -r templates/generic-server hosts/ ``` ### 1.2 Hostname setzen -`hosts/neuer-server/networking.nix`: +`hosts//networking.nix`: ```nix { - networking.hostName = "neuer-server"; + networking.hostName = ""; + networking.domain = "cryodev.xyz"; } ``` @@ -2051,144 +2260,262 @@ cp -r templates/generic-server hosts/neuer-server ```nix nixosConfigurations = { - neuer-server = mkNixosConfiguration "x86_64-linux" [ ./hosts/neuer-server ]; + = mkNixosConfiguration "x86_64-linux" [ ./hosts/ ]; }; ``` -### 1.4 Placeholder secrets.yaml erstellen +### 1.4 Services temporaer deaktivieren -```bash -touch hosts/neuer-server/secrets.yaml +Alle Services, die SOPS-Secrets referenzieren, muessen fuer die Erstinstallation deaktiviert werden. Andernfalls schlaegt die Installation fehl, weil die Secrets noch nicht entschluesselt werden koennen. + +In `hosts//services/default.nix` die entsprechenden Imports auskommentieren: + +```nix +{ + imports = [ + # Deaktiviert bis SOPS-Secrets konfiguriert sind: + # ./forgejo.nix # braucht: forgejo-runner/token, forgejo/mail-pw + # ./headplane.nix # braucht: headplane/cookie_secret, headplane/agent_pre_authkey + # ./mailserver.nix # braucht: mailserver/accounts/* + # ./tailscale.nix # braucht: tailscale/auth-key + + # Diese Services brauchen keine Secrets: + ./headscale.nix + ./netdata.nix + ./nginx.nix + ./openssh.nix + ./sops.nix + ]; +} ``` -### 1.5 SOPS-Secrets temporär deaktivieren +Zusaetzlich in `hosts//services/sops.nix` die Secrets-Definitionen auskommentieren: -In `hosts/neuer-server/default.nix` alle `sops.secrets.*` Referenzen auskommentieren oder mit `lib.mkIf false` umgeben, bis die echten Secrets existieren. +```nix +sops = { + defaultSopsFile = ../secrets.yaml; + # secrets = { + # "forgejo-runner/token" = { }; + # "tailscale/auth-key" = { }; + # }; +}; +``` -## Schritt 2: Zielmaschine vorbereiten +### 1.5 Konfiguration testen + +```bash +nix eval .#nixosConfigurations..config.system.build.toplevel.name +``` + +## Schritt 2: Installation durchfuehren ### 2.1 NixOS ISO booten -Von USB/CD booten. +Vom [NixOS Minimal ISO](https://nixos.org/download/#nixos-iso) booten (USB/CD). -### 2.2 Root-Passwort setzen (für SSH) +### 2.2 Netzwerk und SSH einrichten ```bash -passwd +passwd # Root-Passwort setzen fuer SSH-Zugang +ip a # IP-Adresse ermitteln ``` -### 2.3 IP-Adresse ermitteln +Optional per SSH verbinden (bequemer): ```bash -ip a +ssh -o StrictHostKeyChecking=no root@ ``` -### 2.4 Per SSH verbinden (optional) +### 2.3 Installieren ```bash -ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no nixos@ -sudo -i +nix --experimental-features "nix-command flakes" run \ + git+#apps.x86_64-linux.install -- \ + -n \ + -r ``` -## Schritt 3: Installation durchführen - -### 3.1 Repository klonen +Alternativ, falls das Repository bereits unter `/tmp/nixos` geklont wurde: ```bash -nix-shell -p git -git clone /tmp/nixos -cd /tmp/nixos +nix --experimental-features "nix-command flakes" run /tmp/nixos#install -- -n ``` -### 3.2 Disk-Konfiguration anpassen - -**Wichtig:** Die Disk-ID muss zur Hardware passen! - -```bash -# Verfügbare Disks anzeigen -lsblk -o NAME,SIZE,MODEL,SERIAL -ls -la /dev/disk/by-id/ -``` - -In `hosts/neuer-server/disks.sh` oder `disks.nix` die richtige Disk-ID eintragen. - -### 3.3 Install-Script ausführen - -```bash -bash scripts/install.sh -n neuer-server -``` +> **Hinweis:** Die Disk-ID in `hosts//disks.sh` muss zur Hardware passen. +> Pruefen mit `ls -la /dev/disk/by-id/`. Das Script: -1. Partitioniert die Disk (via disko oder disks.sh) -2. Generiert hardware.nix (falls nicht vorhanden) -3. Installiert NixOS +1. Klont das Repository (bei `-r`) +2. Partitioniert die Disk (via `disks.nix` oder `disks.sh`) +3. Generiert `hardware.nix` (falls nicht vorhanden) +4. Installiert NixOS -### 3.4 Reboot +### 2.4 Reboot ```bash -umount -Rl /mnt reboot ``` -## Schritt 4: Nach dem ersten Boot +## Schritt 3: SOPS-Secrets konfigurieren -### 4.1 Einloggen +Nach dem ersten Boot einloggen (Passwort: `changeme`, sofort aendern mit `passwd`). -Standard-Passwort: `changeme` +### 3.1 SSH-Host-Key zu Age-Key konvertieren -```bash -passwd # Sofort ändern! -``` - -### 4.2 SSH-Host-Key zu Age-Key konvertieren +Auf dem **neuen Server**: ```bash nix-shell -p ssh-to-age --run 'cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age' ``` -**Ausgabe notieren!** (z.B. `age1abc123...`) +Ausgabe notieren (z.B. `age1abc123...`). -### 4.3 Auf Entwicklungsrechner: SOPS konfigurieren +Alternativ remote: -`.sops.yaml` bearbeiten: +```bash +nix-shell -p ssh-to-age --run 'ssh-keyscan -p 2299 -t ed25519 | ssh-to-age' +``` + +### 3.2 .sops.yaml aktualisieren + +Auf dem **Entwicklungsrechner** den neuen Host-Key in `.sops.yaml` eintragen: ```yaml keys: - - &admin_key age1e8p35795htf7twrejyugpzw0qja2v33awcw76y4gp6acnxnkzq0s935t4t - - &neuer_server_key age1abc123... # Key von oben + - &admin_key age1e8p... # Dein lokaler Admin-Key + - &hostname_key age1abc... # Key von Schritt 3.1 creation_rules: - - path_regex: hosts/neuer-server/secrets.yaml$ + - path_regex: hosts//secrets.yaml$ key_groups: - age: - - *admin_key - - *neuer_server_key + - *admin_key + - *hostname_key ``` -### 4.4 Secrets erstellen +### 3.3 Secrets erstellen + +Secrets-Datei oeffnen: ```bash -sops hosts/neuer-server/secrets.yaml +sops hosts//secrets.yaml ``` -Mindestens den Tailscale Auth-Key eintragen (siehe nächster Schritt). +Die folgende Tabelle zeigt alle Secrets fuer **cryodev-main** und wie sie generiert werden: -### 4.5 SOPS-Referenzen wieder aktivieren +#### Sofort erstellbare Secrets -Die in Schritt 1.5 auskommentierten `sops.secrets.*` Referenzen wieder aktivieren. +Diese Secrets haben keine Abhaengigkeiten und koennen direkt generiert werden: -### 4.6 Konfiguration deployen +| Secret | Befehl | +|--------|--------| +| `headplane/cookie_secret` | `openssl rand -hex 16` | +| `mailserver/accounts/admin` | `mkpasswd -sm bcrypt` (Passwort merken!) | +| `mailserver/accounts/forgejo` | `mkpasswd -sm bcrypt` (Passwort merken!) | +| `forgejo/mail-pw` | Klartext-Passwort das zum bcrypt-Hash von `mailserver/accounts/forgejo` passt | + +#### Secrets die laufende Services brauchen + +Diese Secrets koennen erst erstellt werden, nachdem die entsprechenden Services laufen. Bis dahin **Platzhalter** eintragen (z.B. `placeholder`): + +| Secret | Befehl | Voraussetzung | +|--------|--------|---------------| +| `tailscale/auth-key` | `sudo headscale preauthkeys create --expiration 99y --reusable --user default` | Headscale laeuft | +| `headplane/agent_pre_authkey` | `sudo headscale users create headplane-agent && sudo headscale preauthkeys create --expiration 99y --user headplane-agent` | Headscale laeuft | +| `forgejo-runner/token` | Forgejo Admin Panel > Actions > Runners > Create Runner | Forgejo laeuft | + +#### Beispiel secrets.yaml (Klartext vor Verschluesselung) + +```yaml +tailscale: + auth-key: "placeholder" +forgejo-runner: + token: "placeholder" +headplane: + cookie_secret: "a1b2c3d4e5f6..." + agent_pre_authkey: "placeholder" +mailserver: + accounts: + admin: "$2b$05$..." + forgejo: "$2b$05$..." +forgejo: + mail-pw: "das-klartext-passwort" +``` + +### 3.4 Services reaktivieren + +Auf dem **Entwicklungsrechner** die in Schritt 1.4 auskommentierten Imports in `hosts//services/default.nix` wieder aktivieren: + +```nix +{ + imports = [ + ./forgejo.nix + ./headplane.nix + ./headscale.nix + ./mailserver.nix + ./netdata.nix + ./nginx.nix + ./openssh.nix + ./sops.nix + ./tailscale.nix + ]; +} +``` + +Ebenso in `hosts//services/sops.nix` die Secrets-Definitionen wieder einkommentieren. + +### 3.5 Deployen ```bash -# Lokal bauen und per SSH deployen -nixos-rebuild switch --flake .#neuer-server --target-host root@ +nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" ``` -## Nächste Schritte +## Schritt 4: Platzhalter-Secrets ersetzen -- [Tailscale einrichten](../services/tailscale.md) - VPN-Verbindung -- [Netdata konfigurieren](../services/netdata.md) - Monitoring -- [CD einrichten](../deployment/cd.md) - Automatisches Deployment +Nachdem der Server mit Headscale und Forgejo laeuft, die Platzhalter durch echte Werte ersetzen: + +1. **Headscale-User anlegen** (auf dem Server): + + ```bash + sudo headscale users create default + sudo headscale users create headplane-agent + ``` + +2. **Preauth-Keys generieren**: + + ```bash + # Fuer Tailscale + sudo headscale preauthkeys create --expiration 99y --reusable --user default + + # Fuer Headplane Agent + sudo headscale preauthkeys create --expiration 99y --user headplane-agent + ``` + +3. **Forgejo-Runner-Token** ueber das Forgejo Admin Panel erstellen: + Administration > Actions > Runners > Create new Runner + +4. **Secrets aktualisieren**: + + ```bash + sops hosts//secrets.yaml + # Platzhalter durch echte Werte ersetzen + ``` + +5. **Erneut deployen**: + + ```bash + nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" + ``` + +## Naechste Schritte + +- [SOPS-Referenz](../services/sops.md) -- Detail-Dokumentation zur Secret-Verwaltung +- [SD-Image erstellen](sd-image.md) -- Raspberry Pi installieren +- [CD einrichten](../deployment/cd.md) -- Automatisches Deployment @@ -2441,7 +2768,9 @@ Da Comin auf dem Pi läuft, wird er die neue Konfiguration automatisch pullen. Alternativ manuell: ```bash -nixos-rebuild switch --flake .#neuer-pi --target-host root@ +nixos-rebuild switch --flake .#neuer-pi \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" ``` --- @@ -2696,7 +3025,9 @@ sops updatekeys hosts//secrets.yaml Dann Konfiguration neu deployen: ```bash -nixos-rebuild switch --flake .# --target-host root@ +nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" ``` ## Häufige Probleme @@ -4099,24 +4430,43 @@ FILE: hosts/cryodev-main/packages.nix ================================================ FILE: hosts/cryodev-main/secrets.yaml ================================================ -# SOPS encrypted secrets for cryodev-main -# This file should be encrypted with sops before committing -# See INSTRUCTIONS.md for setup instructions - -# Placeholder - replace with actual encrypted secrets -forgejo-runner: - token: ENC[AES256_GCM,data:placeholder,tag:placeholder,type:str] tailscale: - auth-key: ENC[AES256_GCM,data:placeholder,tag:placeholder,type:str] + auth-key: ENC[AES256_GCM,data:APMZrLYEqywYTmc=,iv:KiFwgR3UXLXCdl9DlR5tJOr8XUyQEeDomPx9hOREhnw=,tag:32quLtu74EIxAgmjH3hvIw==,type:str] +forgejo-runner: + token: ENC[AES256_GCM,data:/i9KVMeEXYwQnn0=,iv:pILMNbhDviifDUFRINi6n9dtGSAeqxKMdBgjYwtXXEM=,tag:JCj5v5BZdZteo0MdTVKREw==,type:str] headplane: - cookie_secret: ENC[AES256_GCM,data:placeholder,tag:placeholder,type:str] - agent_pre_authkey: ENC[AES256_GCM,data:placeholder,tag:placeholder,type:str] + cookie_secret: ENC[AES256_GCM,data:HICF31i6yCLZGNeOFYTR3Bp0a7i0UKOvGAvx/pD3NB4=,iv:ZtK8r1YUWnf5Af0Ls341k0w1mZm+D5Rb0E1uS5z/Gdo=,tag:vwM9+4dpcmnjn/wR6Ty/MQ==,type:str] + agent_pre_authkey: ENC[AES256_GCM,data:aYkPZTR4fwArcKQ=,iv:+OhbIpwsyCJ4i4k8eyCKYAHE25F4iUHfdM+CG0+BQd8=,tag:BkT73WPjOv5Lu6dCFBXxWg==,type:str] mailserver: accounts: - forgejo: ENC[AES256_GCM,data:placeholder,tag:placeholder,type:str] - admin: ENC[AES256_GCM,data:placeholder,tag:placeholder,type:str] + admin: ENC[AES256_GCM,data:gY2k3x3sA98yGNLcSWUr9aC0566MJM2UXhwLtWPUL3PRvxQt0XOzjeiC7ddgbqTAol4dBNeaV0zbFInD,iv:rxp0M9kHMgD73K+RDC562sUpXaJ067eU1CeciAke+LM=,tag:VKobduo/ZULAk17M9LD3bw==,type:str] + forgejo: ENC[AES256_GCM,data:brpyVL8THAQcwt7pVYnWviX3PZg1TzfnNEZw9rO/DuFj4sbzLPSPuxxfe6Jj2pwZ4IVoWmastKV3oTnr,iv:Imo6VPA4tqC4Ta8OEniCv0M+UCqQm8YcmE3kIG7G9aY=,tag:uoQ9o2cigN4XwRFnSvC5Lg==,type:str] forgejo: - mail-pw: ENC[AES256_GCM,data:placeholder,tag:placeholder,type:str] + mail-pw: ENC[AES256_GCM,data:ol8dGa6KydnxDR8ybEro6wOcsi6iwu3IMfgO5xTpz34=,iv:SHmku32PdtXjueIjakCTstspzTzCN+iQg7K5DUEJoYk=,tag:yW/Z84q+kUzfPhLQiwGxGA==,type:str] +sops: + age: + - recipient: age1e8p35795htf7twrejyugpzw0qja2v33awcw76y4gp6acnxnkzq0s935t4t + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA1QytQUlNqSlNPaEd6Mlp0 + UVo2WnNyamhxelBod2ZoRERaa1Z3L2NtbVFZCllHZGYxMWtqMGpxemI2bnlpMG5k + MklyMFkrdjd5eTlEUWJFMDBlRk1hQkEKLS0tIDhHWG9NVnd2czdBQVJ3VmdMOWNu + RVNlZVYxOGdZYnpSalF4WHo0SUVhakEKE7CyGNSk03dbSfXrw9n6fi87PYoqEAxI + t74NY/MxQt5gg0fJjtRbOj/cer0gaX86MvMSMJzREPEch5Q52gqKUw== + -----END AGE ENCRYPTED FILE----- + - recipient: age1y6hushuapy0k04mrvvpev0t8lq44w904r596jus44nhkflky0yhqgq2xx6 + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBMU1pUR1dxS3BHOGxiL3pj + emFaWGdNWmRxTVo4dkc1VDF4Sm8xVnVFQkJrCkRNcnNWODhGNHoxVGtGZWVpc1hn + N1JVbUY4c043b0JZVC84NlQzSGhnVzQKLS0tIG1EL3J1aWY0ZG95V0s4TTJmRnUy + MEpGbGlQbVRsM1NxN1JxY2J1MVNTTE0KuIvuM2c1VIXKv0LGLb0NwqtSyBYcRcb1 + uiIjNV0UzEt/WvnCeUTMPgIXBHk6jWcaKe13v6MHeha+/CVZ9Su/Lw== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2026-03-14T10:28:25Z" + mac: ENC[AES256_GCM,data:oeT8I9gMIAPnm8wlNUFjn/0UT6qfTA//fLp3USO33FMsNIOWmqt3kB4NsozS+n6ZeMxBVWQZPss8t819DYqv0xQarzfOqQe1idCGCB+7NBFcFP2VLFzkIH+9Wei9AJSlR3BRnzyVaQDi797P6pEXFn/IoQWPWZ8sX8ZKugOfY0w=,iv:RjsKhPcVZBHHLs1W3PDhcseGLV4eawafg0is6KrzhtE=,tag:ifkobUteslEZ78OvkZw8JQ==,type:str] + unencrypted_suffix: _unencrypted + version: 3.11.0 @@ -4734,11 +5084,13 @@ FILE: hosts/cryodev-pi/services/default.nix ================================================ { imports = [ + # TODO: Enable after first install when SOPS secrets are configured + # ./tailscale.nix + # ./netdata.nix + # ./comin.nix + ./nginx.nix ./openssh.nix - ./tailscale.nix - ./netdata.nix - ./comin.nix ]; } diff --git a/docs/deployment/cd.md b/docs/deployment/cd.md index 068b148..f50b568 100644 --- a/docs/deployment/cd.md +++ b/docs/deployment/cd.md @@ -152,7 +152,9 @@ For hosts not using automated deployment: nix build .#nixosConfigurations..config.system.build.toplevel # Deploy with nixos-rebuild -nixos-rebuild switch --flake .# --target-host root@ +nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" # Or using deploy-rs nix run github:serokell/deploy-rs -- .# diff --git a/docs/getting-started/first-install.md b/docs/getting-started/first-install.md index 1bf65b0..e8680bc 100644 --- a/docs/getting-started/first-install.md +++ b/docs/getting-started/first-install.md @@ -252,7 +252,9 @@ Ebenso in `hosts//services/sops.nix` die Secrets-Definitionen wieder e ### 3.5 Deployen ```bash -nixos-rebuild switch --flake .# --target-host root@ +nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" ``` ## Schritt 4: Platzhalter-Secrets ersetzen @@ -289,7 +291,9 @@ Nachdem der Server mit Headscale und Forgejo laeuft, die Platzhalter durch echte 5. **Erneut deployen**: ```bash - nixos-rebuild switch --flake .# --target-host root@ + nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" ``` ## Naechste Schritte diff --git a/docs/getting-started/new-client.md b/docs/getting-started/new-client.md index 1e495a6..abb6f60 100644 --- a/docs/getting-started/new-client.md +++ b/docs/getting-started/new-client.md @@ -244,7 +244,9 @@ Da Comin auf dem Pi läuft, wird er die neue Konfiguration automatisch pullen. Alternativ manuell: ```bash -nixos-rebuild switch --flake .#neuer-pi --target-host root@ +nixos-rebuild switch --flake .#neuer-pi \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" ``` --- diff --git a/docs/getting-started/reinstall.md b/docs/getting-started/reinstall.md index c1c7a31..8f5040b 100644 --- a/docs/getting-started/reinstall.md +++ b/docs/getting-started/reinstall.md @@ -142,7 +142,9 @@ sops updatekeys hosts//secrets.yaml Dann Konfiguration neu deployen: ```bash -nixos-rebuild switch --flake .# --target-host root@ +nixos-rebuild switch --flake .# \ + --target-host @ --use-remote-sudo \ + --ssh-option="-p 2299" ``` ## Häufige Probleme