summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoradikro <adikro@disroot.org>2026-03-13 23:41:17 +0100
committeradikro <adikro@disroot.org>2026-03-13 23:41:17 +0100
commitf0c0e311c003057f24d8045509a627ad2acab978 (patch)
treea1955fe601c487aab46fa47838cd25b8273508ac /scripts
parentffefb53956c38909da77fe7ebbbb5d8b5dd823b9 (diff)
removing obsolete stuff
Diffstat (limited to 'scripts')
-rw-r--r--scripts/default.nix33
-rw-r--r--scripts/install.sh88
-rw-r--r--scripts/setup.sh98
3 files changed, 0 insertions, 219 deletions
diff --git a/scripts/default.nix b/scripts/default.nix
deleted file mode 100644
index 983216d..0000000
--- a/scripts/default.nix
+++ /dev/null
@@ -1,33 +0,0 @@
-{ pkgs }:
-let
- commonInputs = with pkgs; [
- git
- gnupg
- sops
- nix
- coreutils
- util-linux
- nixos-facter
- ];
-in
-{
- install = pkgs.writeShellApplication {
- name = "nixos-install";
- runtimeInputs = commonInputs ++ [ pkgs.disko-install ];
- text = builtins.readFile ./install.sh;
- };
-
- setup = pkgs.writeShellApplication {
- name = "nixos-setup";
- runtimeInputs =
- commonInputs
- ++ (with pkgs; [
- ssh-to-age
- ripgrep
- sd
- nh
- fd
- ]);
- text = builtins.readFile ./setup.sh;
- };
-}
diff --git a/scripts/install.sh b/scripts/install.sh
deleted file mode 100644
index 8a8c3d7..0000000
--- a/scripts/install.sh
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-# --- Defaults ---
-HOSTNAME=""
-DISKS=()
-KEY_LOCATION="./private.asc"
-REPO_URL="https://codeberg.org/adikro/nixos-config.git"
-TEMP_CONFIG="/tmp/config/etc/nixos"
-USE_FACTER=true
-WRITE_EFI=true
-
-# --- Parse Arguments ---
-PARSED_ARGS=$(getopt -o h:d:r:k:gn --long hostname:,disk:,repo:,key:,generate-config,no-efi -- "$@")
-eval set -- "$PARSED_ARGS"
-
-while true; do
- case "$1" in
- -h|--hostname) HOSTNAME="$2"; shift 2 ;;
- -d|--disk) DISKS+=("$2"); shift 2 ;;
- -r|--repo) REPO_URL="$2"; shift 2 ;;
- -k|--key) KEY_LOCATION="$2"; shift 2 ;;
- -g|--generate-config) USE_FACTER=false; shift ;;
- -n|--no-efi) WRITE_EFI=false; shift ;;
- --) shift; break ;;
- *) echo "Internal error!"; exit 1 ;;
- esac
-done
-
-# --- Validation ---
-if [[ -z "$HOSTNAME" || ${#DISKS[@]} -eq 0 ]]; then
- echo "Usage: sudo nix run .#install -- -h <name> -d main:/dev/nvme0n1 [-d storage:/dev/sda]"
- exit 1
-fi
-
-if [[ ! -f "$KEY_LOCATION" ]]; then
- echo "Error: Private key not found at $KEY_LOCATION. Cannot proceed without GPG."
- exit 1
-fi
-
-# --- Summary & Confirmation ---
-echo "------------------------------------------------------------"
-echo "INSTALLATION PLAN"
-echo " Hostname: $HOSTNAME"
-echo " Target Disks:"
-for disk in "${DISKS[@]}"; do echo " - $disk"; done
-echo "------------------------------------------------------------"
-read -p "Warning: This will format the disks listed above. Proceed? (y/N): " confirm
-[[ "$confirm" != [yY] ]] && exit 1
-
-echo "### 1. Importing GPG Key ###"
-export GPG_TTY=$(tty)
-gpg --import "$KEY_LOCATION"
-
-echo "### 2. Cloning Configuration ###"
-sudo rm -rf "$TEMP_CONFIG"
-git clone "$REPO_URL" "$TEMP_CONFIG"
-cd "$TEMP_CONFIG"
-
-echo "### 3. Hardware Configuration ###"
-HOST_DIR="./hosts/$HOSTNAME"
-mkdir -p "$HOST_DIR"
-
-if [ "$USE_FACTER" = true ]; then
- nixos-facter -o "$HOST_DIR/facter.json"
- git add "$HOST_DIR/facter.json"
-else
- sudo nixos-generate-config --no-filesystems --root /tmp/nixos-gen-root
- mv /tmp/nixos-gen-root/etc/nixos/hardware-configuration.nix "$HOST_DIR/hardware-configuration.nix"
- git add "$HOST_DIR/hardware-configuration.nix"
-fi
-
-echo "### 4. SOPS Key Extraction ###"
-if printf '%s\n' "${DISKS[@]}" | rg -qv "^main:"; then
- sops -d --extract '["crypt_key"]' secrets/secrets.yaml > /tmp/crypt.key
-fi
-
-echo "### 5. Disko Install ###"
-DISKO_ARGS=(--flake ".#$HOSTNAME")
-for pair in "${DISKS[@]}"; do
- IFS=":" read -r D_NAME D_DEV <<< "$pair"
- DISKO_ARGS+=(--disk "$D_NAME" "$D_DEV")
-done
-[[ "$WRITE_EFI" == true ]] && DISKO_ARGS+=(--write-efi-boot-entries)
-
-sudo disko-install "${DISKO_ARGS[@]}"
-
-echo "INSTALL COMPLETE. Reboot and run setup script."
diff --git a/scripts/setup.sh b/scripts/setup.sh
deleted file mode 100644
index fb9a603..0000000
--- a/scripts/setup.sh
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-# --- Defaults ---
-HOSTNAME=$(hostname)
-USB_DEVICE=""
-REPO_URL="git@codeberg.org:adikro/nixos-config.git"
-KEY_LOCATION=""
-USE_FACTER=true
-
-# --- Parse Arguments ---
-PARSED_ARGS=$(getopt -o u:h:r:k:g --long usb:,hostname:,repo:,key:,generate-config -- "$@")
-eval set -- "$PARSED_ARGS"
-
-while true; do
- case "$1" in
- -u|--usb) USB_DEVICE="$2"; shift 2 ;;
- -h|--hostname) HOSTNAME="$2"; shift 2 ;;
- -r|--repo) REPO_URL="$2"; shift 2 ;;
- -k|--key) KEY_LOCATION="$2"; shift 2 ;;
- -g|--generate-config) USE_FACTER=false; shift ;;
- --) shift; break ;;
- *) echo "Internal error!"; exit 1 ;;
- esac
-done
-
-echo "### 1. GPG Key Preparation ###"
-export GPG_TTY=$(tty)
-
-if [[ -n "$KEY_LOCATION" ]]; then
- gpg --import "$KEY_LOCATION"
-elif [[ -n "$USB_DEVICE" ]]; then
- echo "Mounting $USB_DEVICE..."
- sudo mkdir -p /mnt/usb
- findmnt -rno SOURCE "$USB_DEVICE" >/dev/null || sudo mount "$USB_DEVICE" /mnt/usb
-
- echo "Searching USB for private.asc..."
- KEY_FILE=$(sudo fd -H -t f "private.asc" /mnt/usb --max-results 1)
-
- if [[ -n "$KEY_FILE" ]]; then
- KEY_DIR=$(dirname "$KEY_FILE")
- echo "Found keys in $KEY_DIR. Importing..."
- (
- cd "$KEY_DIR"
- gpg --import private.asc
- [[ -f "public.asc" ]] && gpg --import public.asc
- [[ -f "trust.txt" ]] && gpg --import-ownertrust trust.txt
- )
- else
- echo "Error: private.asc not found on $USB_DEVICE"
- sudo umount /mnt/usb; exit 1
- fi
- sudo umount /mnt/usb
-else
- gpg -K | grep -q "sec" || { echo "No keys found. Use --usb or --key."; exit 1; }
-fi
-
-echo "### 2. Repo Setup ###"
-sudo mkdir -p /etc/nixos
-sudo chown -R "$USER":users /etc/nixos
-[[ ! -d "/etc/nixos/.git" ]] && git clone "$REPO_URL" /etc/nixos
-cd /etc/nixos
-
-echo "### 3. Hardware Refresh ###"
-HOST_DIR="./hosts/$HOSTNAME"
-mkdir -p "$HOST_DIR"
-if [ "$USE_FACTER" = true ]; then
- nixos-facter -o "$HOST_DIR/facter.json"
-else
- sudo nixos-generate-config --no-filesystems --root /
- mv /etc/nixos/hardware-configuration.nix "$HOST_DIR/hardware-configuration.nix"
-fi
-
-echo "### 4. SOPS Rotation ###"
-NEW_AGE=$(ssh-to-age < /etc/ssh/ssh_host_ed25519_key.pub)
-if grep -q "&host_$HOSTNAME" .sops.yaml; then
- sd "(&host_$HOSTNAME\s+-) age1.*" "\$1 $NEW_AGE" .sops.yaml
-else
- sd "(keys:\n)" "\$1 - &host_$HOSTNAME $NEW_AGE\n" .sops.yaml
- sd "(age:\n(.*\n)*?\s+age:\n)" "\$1 - *host_$HOSTNAME\n" .sops.yaml
-fi
-
-sops updatekeys secrets/secrets.yaml -y
-
-echo "### 5. System Rebuild ###"
-git add .
-nh os switch . -u -H "$HOSTNAME"
-
-echo "### 6. Git Finalization ###"
-[[ $(git remote) =~ "origin" ]] && git remote rename origin codeberg
-git remote set-url codeberg "$REPO_URL"
-git add .
-git commit -m "chore($HOSTNAME): hardware refresh and sops rotation" || echo "No changes."
-
-read -p "Push to Codeberg? (y/N): " push_confirm
-[[ "$push_confirm" == [yY] ]] && git push -u codeberg main
-
-echo "SETUP COMPLETE. Rebooting is recommended."