docs(nixos): curate standalone workstation refactor plan and walkthrough from inbox
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 6s

This commit is contained in:
kiskaadee committed 2026-09-13 01:53:11 -05:00
1 parent ec3ce5a1c7
commit fb9e91480d
4 files changed
+222 -30

No files matched your search

+25 -24
View File
@@ -11,59 +11,60 @@ tags:
# ❄️ NixOS Fleet & Declarative System Configuration
## 🎯 Project Overview
This project documents the architecture, flake hierarchy, host specializations, module designs, and operational maintenance for the multi-machine NixOS fleet managed in [`/home/kiskaadee/Config`](file:///home/kiskaadee/Config).
This project documents the architecture, flake hierarchy, host specializations, module designs, and operational maintenance for the workstation NixOS configuration managed in [`/home/kiskaadee/Config`](file:///home/kiskaadee/Config).
The fleet operates under a unified Nix Flake repository supporting declarative system rebuilds, user-space management via Home Manager, and encrypted secrets via SOPS-nix.
Following the architectural decoupling of the homelab infrastructure into `Core`, `Config` functions as a dedicated standalone configuration for the mobile workstation (`laptop`), structured cleanly around system-level machine concerns (`system/`) and user-session domains (`home/`).
---
## 🏛️ System Topology & Host Matrix
## 🏛️ System Topology & Workstation Model
```mermaid
graph TD
Flake["Config Flake (flake.nix)"] --> Hosts["hosts/"]
Flake --> Modules["modules/"]
Flake["Config Flake (flake.nix)"] --> System["system/ (Privileged Root)"]
Flake --> Home["home/ (User Session)"]
Hosts --> Server["hosts/server (Headless 24/7 Server)"]
Hosts --> Laptop["hosts/laptop (Mobile Dev Workstation)"]
System --> CoreSys["core.nix (Nix, locale, users, security)"]
System --> MachSys["hardware.nix (Machine services, PipeWire, Docker)"]
System --> DeskSys["desktop.nix (greetd, display management)"]
Modules --> CoreMod["Core System Modules (nix, security, locale)"]
Modules --> UserMod["Home Manager Modules (shell, git, neovim)"]
Modules --> DesktopMod["Desktop Modules (niri, wayland, audio)"]
Server -.->|"headless, docker, sops"| CoreMod
Laptop -.->|"graphical, devtools"| DesktopMod
Laptop -.-> UserMod
Home --> DeskHome["desktop.nix (Niri, Wayland, Alacritty)"]
Home --> DevHome["dev.nix (Neovim, compilers, LSPs, CLI secrets)"]
Home --> ShellHome["shell.nix (Bash, Tmux, Git, aliases)"]
```
| Host | Role | Environment | Key Subsystems |
| Host / Scope | Role | Environment | Key Subsystems |
| :--- | :--- | :--- | :--- |
| **`server`** | 24/7 Homelab Host | Headless Server | Docker daemon, Traefik, Socket-Proxy, `homelab-gitops`, SOPS Age secrets, Dynu DDNS |
| **`laptop`** | Primary Workstation | Graphical Wayland | Niri / Hyprland, Waybar, Alacritty, DevShells, Git/SSH keys, local LLM/GUI clients |
| **`laptop`** (`Config`) | Mobile Dev Workstation | Graphical Wayland | Niri, Waybar, Alacritty, DevShells, Git/SSH keys, local LLM/GUI clients, CLI secrets tooling |
| **`server`** (`Core`) | 24/7 Homelab Host | Headless Server | Docker daemon, Traefik, Socket-Proxy, `homelab-gitops`, SOPS Age secrets, Dynu DDNS |
---
## 📑 Plans & Execution Roadmaps
1. 🟡 [**Decoupling Homelab Server & Standalone Workstation Architecture**](plans/server-decoupling-and-standalone-workstation.md) `[Active]`
1. 🟢 [**Decoupling Homelab Server & Standalone Workstation Architecture**](plans/server-decoupling-and-standalone-workstation.md) `[Completed]`
- Architectural blueprint and phased plan for removing `hosts/server/` from `Config`, eliminating the "multi-host tax", and re-aligning the repository as a dedicated Niri workstation.
2. 🟡 [**Adopting Official channels.nixos.org Tarballs**](plans/channel-tarball-migration-plan.md) `[Active]`
2. 🟢 [**Secrets Management Architecture & Workstation Boundary Refinement**](plans/secrets-architecture-and-workstation-cleanup.md) `[Completed]`
- Clean removal of `sops-nix` host stubs from `Config`, operator authoring vs runtime consumer key architecture, compositor cleanup, and filesystem decoupling.
3. 🟡 [**Adopting Official channels.nixos.org Tarballs**](plans/channel-tarball-migration-plan.md) `[Active]`
- Transitioning from GitHub-hosted Nixpkgs flake inputs to official `channels.nixos.org` zstd-compressed archives.
- Flake registry pinning and evaluation speedup analysis.
3. 🟢 [**Decommission Legacy Desktop Derivation**](plans/decommission-desktop-derivation.md) `[Completed]`
4. 🟢 [**Decommission Legacy Desktop Derivation**](plans/decommission-desktop-derivation.md) `[Completed]`
- Pruned `hosts/desktop/` and `nixosConfigurations.desktop` to standardize on a 2-host fleet (`server` and `laptop`).
4. 🟢 [**SOPS Secrets Restructuring & Multi-User Authelia Support**](plans/sops-restructuring-plan.md) `[Completed]`
5. 🟢 [**SOPS Secrets Restructuring & Multi-User Authelia Support**](plans/sops-restructuring-plan.md) `[Completed]`
- Migrated flat SOPS secrets to service-scoped namespaces and added declarative Nix user database rendering.
---
## 📑 Guides & Reference Documentation
1. [**Transitioning to Official channels.nixos.org Tarballs Walkthrough**](guides/channel-tarball-migration-walkthrough.md)
1. [**Standalone Workstation Architecture & Secrets Decoupling Walkthrough**](guides/standalone-workstation-walkthrough.md)
- Workstation refactor execution, Niri compositor cleanup, filesystem path decoupling, and verification results.
2. [**Transitioning to Official channels.nixos.org Tarballs Walkthrough**](guides/channel-tarball-migration-walkthrough.md)
- Flake input migration, base registry pinning, and dry-build verification.
2. [**Decommissioning the Legacy Desktop Derivation Walkthrough**](guides/desktop-decommission-walkthrough.md)
3. [**Decommissioning the Legacy Desktop Derivation Walkthrough**](guides/desktop-decommission-walkthrough.md)
- Host removal validation, architecture doc sync, and dry builds.
3. [**SOPS Secrets Restructuring & Multi-User Authelia Walkthrough**](guides/sops-restructuring-walkthrough.md)
4. [**SOPS Secrets Restructuring & Multi-User Authelia Walkthrough**](guides/sops-restructuring-walkthrough.md)
- Secret hierarchy re-encryption, template generation, and host dry-build verification.
---
@@ -0,0 +1,70 @@
---
type: guide
project: nixos
tags:
- nixos
- workstation
- refactor
- architecture
- walkthrough
---
# Walkthrough: Standalone Workstation Architecture & Secrets Decoupling
## Overview
Following the migration of homelab server infrastructure to the dedicated `Core` repository, the primary system configuration repository ([`/home/kiskaadee/Config`](file:///home/kiskaadee/Config)) was transformed from a multi-host fleet hierarchy into a standalone, domain-driven configuration for the mobile workstation (`laptop`).
Subsequently, all remaining workstation boundaries, compositor residue, and secrets architecture were refined, verified, and successfully activated on the host.
---
## 1. Secrets Architecture & Clean Decoupling
* **Clarified Roles**: The workstation acts strictly as the **administrative authoring station** for homelab credentials, while the server is a headless **consumer**.
* **Removed Host Secrets Stubs**:
* Deleted stale root `.sops.yaml`.
* Removed `sops-nix` flake input from `flake.nix`.
* **Preserved Operator Toolchain**: Retained `sops`, `age`, and `rbw` CLI packages in `home/dev.nix` so secrets in `Core/nixos/secrets.yaml` can continue to be edited and rotated locally.
* **Rewrote Runbook**: Updated `docs/secrets-management.md` with a clear GitOps diagram explaining the author-consumer split and step-by-step instructions for managing `Core` secrets from the laptop.
---
## 2. Compositor Cleanliness (Niri-Native)
* **Removed Hyprland Session Target**: Deleted `systemd.user.targets.hyprland-session` from `home/desktop.nix`.
* **Streamlined Screen Recorder**: Refactored `home/scripts/record.sh` to query Niri directly (`niri msg -j focused-output`) and removed all legacy `hyprctl` checks.
---
## 3. Decoupled Filesystem Paths
* **Eliminated Hard Runtime Path Dependency**:
* Removed `$HOME/Core/scripts` from `sessionPath` in `home/default.nix`.
* Removed `$HOME/Core/scripts` from the `PATH` export in `home/shell.nix`.
* Preserved only standard user binary paths (`$HOME/.local/bin` and `$HOME/.cargo/bin`).
---
## 4. Semantic & Documentation Precision
* **Machine Services & Peripherals**: Updated `system/hardware.nix` header to accurately reflect machine-level daemons (PipeWire, Docker, Bluetooth, power management, printing).
* **Updated Upstream DMS Options**: Removed deprecated `enableSystemMonitoring` and `enableClipboardPaste` from `system/desktop.nix` (now natively built into DMS).
* **Refined Architectural Principles in `architecture.md`**:
* Clarified that workstation OpenSSH remote access $\neq$ homelab server infrastructure.
* Refined "Git is the source of truth" to target reproducible configuration decisions, acknowledging runtime state (SSH keys, machine-id, caches).
* Formally documented the dual-composition model (`flake.nix` composing `system/` and `home/`).
* Rephrased package placement invariant around execution context.
* **Documentation Path Fixes**:
* Fixed stale `modules/user/terminal.nix` in `docs/tmux.md`.
* Fixed stale `modules/user/apps.nix` in `docs/development-environments.md` and `docs/package-and-secrets.md`.
---
## 5. Verification Results
| Validation Command | Status | Details |
| :--- | :--- | :--- |
| `nix flake check` | **PASSED** | Flake inputs, schema, and `laptop` configuration evaluated cleanly. |
| `nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` | **PASSED** | Complete dry build succeeded, compiling all derivations. |
| `sudo nixos-rebuild switch --flake .#laptop` | **PASSED** | System successfully activated into new generation without regressions. |
@@ -0,0 +1,120 @@
---
type: plan
status: completed
project: nixos
tags:
- nixos
- workstation
- sops
- secrets
- gitops
---
# Plan: Secrets Management Architecture & Workstation Boundary Refinement
## 1. Executive Summary & Diagnostic
The failure encountered when running:
```bash
ssh server-remote "sops ~/Core/nixos/secrets.yaml"
```
is **expected and secure by design**. It highlights the fundamental GitOps distinction between **Secret Authoring** and **Secret Consumption**.
```mermaid
graph LR
subgraph "Workstation (Operator / Author)"
LAPTOP_KEY["~/.config/sops/age/keys.txt<br/>(&laptop private key)"]
SOPS_CLI["sops CLI<br/>(home/dev.nix)"]
CORE_LOCAL["Core/nixos/secrets.yaml<br/>(Git clone on laptop)"]
LAPTOP_KEY --> SOPS_CLI
SOPS_CLI -->|Author & Encrypt| CORE_LOCAL
end
CORE_LOCAL -->|"git push / pull"| CORE_REMOTE["~/Core/nixos/secrets.yaml<br/>(Server clone)"]
subgraph "Server (Consumer / Runtime)"
HOST_SSH["/etc/ssh/ssh_host_ed25519_key<br/>(&server private key)"]
SOPS_NIX["sops-nix systemd service<br/>(Runs as root at boot)"]
RAM_FS["/run/secrets/*<br/>(Decrypted into RAM only)"]
CORE_REMOTE --> SOPS_NIX
HOST_SSH --> SOPS_NIX
SOPS_NIX --> RAM_FS
end
```
### Why It Failed on the Server
1. **The Server is a Consumer, Not an Author**: The server only possesses its host SSH private key (`/etc/ssh/ssh_host_ed25519_key`). This key is owned by `root:root` with permissions `0600`.
2. When SSHing as `kiskaadee` and running `sops`, the unprivileged user has no access to `/etc/ssh/ssh_host_ed25519_key` and has no `~/.config/sops/age/keys.txt`.
3. Systemd, running as root during system activation, is what reads `/etc/ssh/ssh_host_ed25519_key` to decrypt secrets into `/run/secrets/` for Docker and Traefik.
4. **Editing secrets locally on the workstation is the intended, standard GitOps workflow.** The workstation holds `~/.config/sops/age/keys.txt` (`&laptop`), allowing decryption, editing, and encryption of `Core/nixos/secrets.yaml` before pushing.
---
## 2. Industry Analysis: Is SOPS Good for a Homelab?
| Secret Management Pattern | How It Works | Suitability for Homelab | Verdict |
| :--- | :--- | :--- | :--- |
| **SOPS + age (GitOps)** | Ciphertext stored in Git; host SSH keys decrypt at boot; operator age key edits on laptop. | **Ideal**. Zero recurring costs, 100% reproducible from Git, offline-capable, native `sops-nix` integration. | **Industry Standard for NixOS & Kubernetes homelabs** |
| **HashiCorp Vault / OpenBao** | Centralized secrets daemon; dynamic leasing; token authentication. | **Poor**. High operational overhead, heavy resource footprint, chicken-and-egg unsealing problem on reboot. | Overkill for a single-server setup |
| **SaaS Secret Managers (Doppler / 1Password / Infisical)** | Secrets fetched over HTTP API at boot. | **Moderate**. Introduces an external internet dependency; boot fails if WAN is down or API is rate-limited. | Unnecessary external dependency |
| **Manual `.env` / Out-of-band Files** | Manually copying secrets onto the server via scp/rsync. | **Fragile**. Not declarative, breaks disaster recovery, easy to lose during reinstallation. | Antipattern |
**Conclusion**: **SOPS + age is the gold standard for NixOS homelabs.** It strikes the ideal balance: zero external dependencies, seamless disaster recovery from Git, and root-level automated decryption via host SSH keys.
---
## 3. What Does This Mean for `Config` (The Laptop)?
We strictly distinguish between **Secrets Tooling** and **Declarative System Secrets**:
1. **Secrets Tooling (Kept)**: The laptop is the administrative cockpit. It needs `sops`, `age`, and `rbw` installed as CLI packages in `home/dev.nix`, and the personal age key in `~/.config/sops/age/keys.txt`. This enables authoring and rotating secrets for `Core`.
2. **Declarative Host Secrets (`sops-nix` in `Config`)**:
- The laptop declares **zero** host secrets. It does not run headless server daemons, Docker credentials, or database connection strings.
- Retaining `sops-nix` as an imported NixOS module in `flake.nix` and keeping a stale `.sops.yaml` in `Config` creates an architectural ghost.
- **Resolution**:
- Remove `sops-nix` from `Config/flake.nix` and delete `Config/.sops.yaml`.
- Keep `sops`, `age`, and `rbw` in `home/dev.nix`.
- If the workstation ever requires declarative machine secrets in the future (e.g., enterprise VPN profiles or WiFi PSKs), `sops-nix` can be reintroduced with a single workstation-specific `.sops.yaml`.
---
## 4. Workstation Refinement Implementation
### Component A: Secrets & Flake Hygiene
- [x] **Clarify Secrets Architecture**: Document that `Core` owns homelab secrets, while `Config` owns administrative CLI tooling.
- [x] **Purge Stale Secrets Config**:
- Removed `sops-nix` flake input from `flake.nix`.
- Removed root `.sops.yaml` from `Config`.
- Retained `sops`, `age`, and `rbw` in `home/dev.nix`.
- Replaced `docs/secrets-management.md` with an operator runbook explaining how to manage `Core` secrets from the laptop.
### Component B: Compositor Cleanliness (Niri-Only)
- [x] **Remove Hyprland Residue**:
- In `home/desktop.nix`: Deleted `systemd.user.targets.hyprland-session`.
- In `home/scripts/record.sh`: Stripped `hyprctl` checks, leaving clean, optimized Niri logic.
### Component C: Boundary Decoupling (`$HOME/Core/scripts`)
- [x] **Eliminate Filesystem Coupling**:
- In `home/default.nix` and `home/shell.nix`: Removed `$HOME/Core/scripts` from `sessionPath` and `PATH`.
- Workstation path now strictly includes `$HOME/.local/bin` and `$HOME/.cargo/bin`.
### Component D: Semantic & Architectural Precision
- [x] **Precision in `architecture.md`**:
- Refined "Git is the source of truth" to specify *reproducible configuration decisions*, acknowledging runtime state (SSH keys, machine-id, caches).
- Documented dual-composition root (`flake.nix` -> `system/` + `home/`).
- Updated package placement invariant around ownership and execution context (privileged machine vs interactive user environment).
- Added explicit architectural clarification: *Workstation remote-access capabilities (OpenSSH) ≠ server infrastructure.*
- [x] **Semantic Header in `system/hardware.nix`**:
- Re-titled module scope from "Laptop Hardware" to "Machine Services & Peripherals" (to logically house PipeWire, Docker, Bluetooth, printing).
- [x] **Documentation Sweep**:
- Fixed stale `modules/user/terminal.nix` reference in `docs/tmux.md`.
- Purged lingering legacy references across all docs.
---
## 5. Verification
1. `nix flake check` — Flake inputs and schemas evaluated cleanly.
2. `nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` — Full dry build succeeded cleanly.
3. Live rebuild test and switch completed successfully.
@@ -1,6 +1,6 @@
---
type: plan
status: active
status: completed
project: nixos
tags:
- nixos
@@ -187,12 +187,13 @@ Phase 2: Workstation Architectural Consolidation
---
### Phase 2: Workstation Architectural Consolidation (Future Scope)
### Phase 2: Workstation Architectural Consolidation (Completed)
Once the server removal has stabilized:
1. Flatten `hosts/laptop/` into a unified system profile (`system/`).
2. Dissolve the 3 Home Manager tiers (`Tier 1 / Tier 2 / Tier 3`) into clean functional domains (`desktop`, `dev`, `shell`).
3. Consolidate package lists by domain, eliminating duplicated definitions.
1. Flattened `hosts/laptop/` into a unified system profile (`system/`).
2. Dissolved the 3 Home Manager tiers (`Tier 1 / Tier 2 / Tier 3`) into clean functional domains (`desktop`, `dev`, `shell`).
3. Consolidated package lists by domain, eliminating duplicated definitions.
4. Refined boundaries and secrets architecture per [`secrets-architecture-and-workstation-cleanup.md`](secrets-architecture-and-workstation-cleanup.md).
5. Comprehensive execution walkthrough documented in [`standalone-workstation-walkthrough.md`](../guides/standalone-workstation-walkthrough.md).
---