feat(nixos): add desktop decommission and SOPS restructuring plans and guides
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 5s

Document legacy desktop derivation retirement, SOPS hierarchical secrets restructuring, and provide execution walkthrough guides for NixOS fleet management.
This commit is contained in:
kiskaadee committed 2026-09-11 15:41:21 -05:00
1 parent 945b872d31
commit 719eda7d49
6 files changed
+619 -1

No files matched your search

+17 -1
View File
@@ -48,15 +48,31 @@ graph TD
1. 🟡 [**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.
2. 🟢 [**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`).
3. 🟢 [**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
*(Guides and deep-dive technical specifications for NixOS fleet management will be curated here as documentation expands).*
1. [**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)
- Host removal validation, architecture doc sync, and dry builds.
3. [**SOPS Secrets Restructuring & Multi-User Authelia Walkthrough**](guides/sops-restructuring-walkthrough.md)
- Secret hierarchy re-encryption, template generation, and host dry-build verification.
---
## 🏛️ Architectural Discussions & Records
* [Discussion: NixOS Monorepo vs. Multi-Repo Architecture for Homelab & Workstations](../../records/discussions/2026-09-nixos-monorepo-vs-multirepo-architecture.md)
---
## 🔗 Related Projects & Locations
* **Local Flake Repository**: [`/home/kiskaadee/Config`](file:///home/kiskaadee/Config)
* **Homelab Services Project**: [Homelab & Infrastructure Planning](../homelab/README.md)
@@ -0,0 +1,69 @@
---
type: guide
project: nixos
tags:
- nixos
- flake
- tarball
- hydra
---
# Walkthrough: Transitioning to Official `channels.nixos.org` Channel Tarballs
## Overview
We created an isolated branch `feat/channel-tarball-nixpkgs` to transition `nixpkgs` flake inputs from GitHub (`github:nixos/nixpkgs/nixos-unstable`) to the official project-hosted, zstd-compressed channel tarballs (`https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst`).
This change provides:
- **~20–33% smaller download sizes** via Zstandard (`.tar.zst`) compression.
- **Forge independence** from GitHub for the core Nixpkgs repository.
- **Immunity from GitHub API rate-limiting**.
- **System flake registry pinning** (`nix.registry.nixpkgs.flake = inputs.nixpkgs;`) so ad-hoc CLI commands (`nix run nixpkgs#...`) reuse the evaluated channel snapshot without external GitHub lookups.
---
## Changes Made
1. **Dedicated Branch**:
Created and checked out `feat/channel-tarball-nixpkgs` from `main` to ensure effortless rollback.
2. **System Flake Input**:
- `flake.nix`: Changed `nixpkgs.url` to `"https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst"`.
3. **Flake Registry Integration**:
- `modules/system/base.nix`: Added `inputs` to module arguments and configured `nix.registry.nixpkgs.flake = inputs.nixpkgs;`.
4. **Flake Lockfile**:
- `flake.lock`: Updated the `nixpkgs` input node from type `github` to type `tarball` (`https://releases.nixos.org/nixos/unstable/nixos-26.11pre1070770.8ce4ef6cb6f8/nixexprs.tar.zst`). No other input nodes were disturbed.
5. **Documentation & Dev Flake Examples**:
- `docs/development-environments.md`: Updated `devShell` example to recommend `https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst`.
- `docs/antigravity.md`: Updated example snippet to use the channel tarball.
---
## Verification Results
### 1. Flake Checks
```bash
nix flake check
```
- Evaluated outputs for `nixosConfigurations.server`, `nixosConfigurations.desktop`, and `nixosConfigurations.laptop`.
- Result: **All checks passed cleanly**.
### 2. Dry-Build Validation (`--no-link`)
In accordance with repository invariants (**Build, Never Switch**), all three downstream host configurations were compiled dryly without mutating the running system:
- **`desktop`**:
```bash
nix build .#nixosConfigurations.desktop.config.system.build.toplevel --no-link
```
Result: **Success** (`/nix/store/ijg6vq9q7by98dfs1vs2vkzlcmrdjgg7-nixos-system-desktop-26.11.20260910.8ce4ef6.drv`).
- **`laptop`**:
```bash
nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link
```
Result: **Success** (`/nix/store/x0jgx8hghmjbi0pd3cfs7qdc1p0k015b-nixos-system-laptop-26.11.20260910.8ce4ef6.drv`).
- **`server`**:
```bash
nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link
```
Result: **Success** (`/nix/store/kcbi75d4laqywwir3hvggwqngw33dvwm-nixos-system-server-26.11.20260910.8ce4ef6.drv`).
@@ -0,0 +1,62 @@
---
type: guide
project: nixos
tags:
- nixos
- flake
- refactor
---
# Walkthrough: Decommissioning the Legacy Desktop Derivation
## Overview
We cleanly decommissioned the legacy `desktop` host configuration (`nixosConfigurations.desktop` and `hosts/desktop/`) on the dedicated branch `refactor/decommission-desktop`.
With the dedicated `server` host handling all homelab services and `laptop` serving as the daily-driver workstation, the legacy dual-mode `desktop` host is no longer needed.
---
## Changes Made
1. **Branch Isolation**:
Created and checked out branch `refactor/decommission-desktop` from `main`.
2. **Flake Output Pruning**:
- `flake.nix`: Removed `nixosConfigurations.desktop`. The only active targets are now `server` and `laptop`.
3. **Directory Deletion**:
- Removed `hosts/desktop/` and all its legacy contents (Hyprland configuration, duplicated server configs, hardware configuration, and legacy secrets). All active homelab services remain fully preserved under `hosts/server/`.
4. **Architecture & Constitution Alignment**:
- `architecture.md`: Pruned `desktop` from the topology directory tree, Mermaid diagrams, placement guides, and invariants.
- `AGENTS.md`: Updated agent constitution, verification commands, and validation matrix to target `server` and `laptop`.
- `README.md`: Updated high-level overview, topology diagrams, and deployment guides to reflect the 2-host architecture (`server` and `laptop`).
- `docs/`: Updated references in `dynu-ip-monitor.md`, `package-and-secrets.md`, `secrets-management.md`, and `antigravity.md`.
---
## Verification Results
### 1. Attribute Check
```bash
nix eval .#nixosConfigurations --apply builtins.attrNames
```
- Result: `[ "laptop" "server" ]` (confirming `desktop` is cleanly removed).
### 2. Flake Validation
```bash
nix flake check
```
- Result: **All checks passed cleanly** for `nixosConfigurations.server` and `nixosConfigurations.laptop`.
### 3. Dry-Build Validation (`--no-link`)
- **`server`**:
```bash
nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link
```
Result: **Success (code 0)**.
- **`laptop`**:
```bash
nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link
```
Result: **Success (code 0)**.
@@ -0,0 +1,68 @@
---
type: guide
project: nixos
tags:
- nixos
- sops
- secrets
- authelia
---
# Walkthrough: SOPS Secrets Restructuring & Multi-User Authelia Support
Restructured the flat SOPS secrets into clean, service-first namespaces (`authelia/*`, `traefik/*`, `dynu/*`, `postgres/*`, `mongo/*`, `ollama/*`, `gitea/*`, `learning/*`, `system/*`) and added declarative multi-user support for Authelia in NixOS.
---
## What Changed
### 1. Re-encrypted Secrets (`~/Config/hosts/server/secrets.yaml`)
Restructured all flat keys into nested YAML mappings encrypted with Age:
* **`authelia/`**:
* `session_secret`, `storage_encryption_key`, `jwt_secret`
* `users/kiskaadee/password_hash`
* `users/misa/password_hash`
* `users/valenvg/password_hash`
* **`traefik/`**: `acme_email`
* **`dynu/`**: `api_key`, `user`, `domain`, `password`
* **`postgres/`**: `user`, `password`, `db`
* **`mongo/`**: `root_username`, `root_password`
* **`ollama/`**: `api_key`
* **`gitea/`**: `runner_token`
* **`learning/`**: `turso_db_url`, `turso_auth_token`
* **`system/`**: `gh_repo_token`, `pdf_decrypt_password`
### 2. Declarative Authelia User Schema (`~/Config/hosts/server/homeserver.nix`)
* Defined a declarative `autheliaUsers` map in Nix containing metadata (display name, email, group memberships) for `kiskaadee`, `misa`, and `valenvg`.
* Configured `sops.templates."users.yml"` to dynamically generate the Authelia user database at `/run/secrets/rendered/users.yml` using `config.sops.placeholder."authelia/users/<username>/password_hash"`.
* Updated all core secret placeholders (`authelia/*`, `traefik/*`, `dynu/*`).
### 3. Application & DDNS Modules
* **[`hosts/server/traefik-deployments.nix`](file:///home/kiskaadee/Config/hosts/server/traefik-deployments.nix)**: Updated secret references to service-scoped keys (`postgres/*`, `mongo/*`, `ollama/*`, `learning/*`, `gitea/*`).
* **[`hosts/server/dynu.nix`](file:///home/kiskaadee/Config/hosts/server/dynu.nix)**: Updated DDNS configuration placeholders to `dynu/*` and `system/pdf_decrypt_password`.
---
## Verification Results
### 1. SOPS Decryption & Round-trip Verification
Decrypted `secrets.yaml` with `sops -d` to confirm every value parses correctly into the target hierarchy.
### 2. NixOS Flake Dry-Build
Evaluated and built derivations for `server` host (`nixos-rebuild dry-build --flake .#server`), confirming all 4 templates (`users.yml`, `homeserver.env`, `traefik-deployments.env`, `ddclient.conf`) evaluate cleanly.
---
## Deployment Instructions
To activate the changes on the target server host:
```bash
cd ~/Config
sudo nixos-rebuild switch --flake .#server
```
Once activated, restart Authelia to load the new users database:
```bash
appctl restart authelia
```
@@ -0,0 +1,111 @@
---
type: plan
status: completed
project: nixos
tags:
- nixos
- flake
- cleanup
- refactor
---
# Implementation Plan: Decommission Legacy Desktop Derivation
## Goal Description
Decommission and remove the legacy `desktop` host configuration (`nixosConfigurations.desktop` and `hosts/desktop/`) from the repository.
Now that homelab services (`homeserver.nix`, `traefik-deployments.nix`, `dynu.nix`, SOPS secrets) have been completely stabilized on the dedicated `server` host, and the active workstation environment is running on `laptop`, the legacy dual-mode `desktop` derivation is obsolete and can be cleanly decommissioned.
---
## User Review Required
> [!IMPORTANT]
> **Branch Isolation**:
> All modifications and deletions will take place on a dedicated branch `refactor/decommission-desktop` branched off `main`, allowing effortless rollback or recovery at any time.
> [!WARNING]
> **Host Scope**:
> Deleting `hosts/desktop/` removes:
> - `hosts/desktop/configuration.nix` & `specialisation.server`
> - `hosts/desktop/hardware-configuration.nix`
> - `hosts/desktop/home.nix` & `hosts/desktop/config/hypr/`
> - Legacy duplicated homelab files (`homeserver.nix`, `traefik-deployments.nix`, `dynu.nix`, `monitor.py`, `secrets.yaml`)
>
> All homelab functionality already exists independently in `hosts/server/`.
---
## Proposed Changes
### 1. Branch Creation
- Create and switch to `refactor/decommission-desktop`.
---
### 2. Flake Configuration
#### [MODIFY] flake.nix
- Remove `nixosConfigurations.desktop` block (lines 95–121).
- Active hosts remaining in `flake.nix`: `server` and `laptop`.
---
### 3. File Deletion
#### [DELETE] hosts/desktop/
- Delete the entire `hosts/desktop/` directory and all its contents:
- `hosts/desktop/configuration.nix`
- `hosts/desktop/hardware-configuration.nix`
- `hosts/desktop/home.nix`
- `hosts/desktop/config/hypr/`
- `hosts/desktop/dynu.nix`
- `hosts/desktop/homeserver.nix`
- `hosts/desktop/traefik-deployments.nix`
- `hosts/desktop/monitor.py`
- `hosts/desktop/secrets.yaml`
- `hosts/desktop/ddclient.conf`
---
### 4. Architecture & Documentation Sync
#### [MODIFY] architecture.md
- Update topology diagram and description to reflect active hosts: `server` (Homelab) and `laptop` (Workstation).
- Remove references to desktop specialization invariant.
#### [MODIFY] AGENTS.md
- Update validation commands from `desktop` to `server` and `laptop`.
- Update host validation matrix to reflect active hosts.
#### [MODIFY] README.md
- Remove legacy `hosts/desktop/` references from the directory map and documentation.
---
## Verification Plan
### Automated Tests
1. **Flake Check**:
```bash
nix flake check
```
Ensures flake metadata and all remaining host configurations (`server` and `laptop`) evaluate without errors.
2. **Dry-Build System Targets (Build, Never Switch)**:
```bash
nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link
nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link
```
Both remaining hosts must compile cleanly.
3. **Verify Desktop Derivation Is Removed**:
```bash
nix eval .#nixosConfigurations --apply builtins.attrNames
```
Expected output: `[ "laptop" "server" ]`
### Manual Verification
1. `git status` inspection to ensure no untracked or unwanted deletions occurred.
2. Confirm `git log` and commit history on the dedicated branch.
@@ -0,0 +1,292 @@
---
type: plan
status: completed
project: nixos
tags:
- nixos
- sops
- secrets
- authelia
- security
---
# Implementation Plan: SOPS Secrets Restructuring & Multi-User Authelia Support
Restructure the flat SOPS secrets in the NixOS host repository into service-scoped hierarchical namespaces and introduce a declarative multi-user configuration for Authelia in NixOS.
---
## Proposed Architecture: Flat to Service-First Hierarchy
Currently, `hosts/server/secrets.yaml` is a flat key-value list (`dynu_api_key`, `postgres_password`, `authelia_user_kiskaadee_password_hash`). As services and users expand, this flat space becomes difficult to audit and maintain.
We are migrating to a **Service-First Namespace** where keys naturally mirror service boundaries:
```mermaid
graph TD
Root["hosts/server/secrets.yaml"] --> Authelia["authelia/"]
Root --> Traefik["traefik/"]
Root --> Dynu["dynu/"]
Root --> Database["postgres/ & mongo/"]
Root --> Apps["gitea/ & ollama/ & learning/"]
Root --> System["system/"]
Authelia --> AuthKeys["session_secret<br>storage_encryption_key<br>jwt_secret"]
Authelia --> Users["users/"]
Users --> U1["kiskaadee/password_hash"]
Users --> U2["misa/password_hash"]
Users --> U3["valenvg/password_hash"]
```
---
## User Review Required
> [!IMPORTANT]
> **SOPS Re-encryption Execution**:
> `hosts/server/secrets.yaml` is age-encrypted. The restructuring of the YAML keys must be executed via `sops hosts/server/secrets.yaml` using the configured age key (`~/.config/sops/age/keys.txt`).
> An unencrypted migration template will be provided so you can paste the new structure directly into `sops`.
> [!NOTE]
> **Authelia RBAC Scope**:
> As agreed, access control rules remain at `*.roadtotech.me: one_factor` for now. Role-based restrictions (e.g. limiting admin panels to the `admins` group) will be handled in a follow-up phase.
---
## Proposed Changes
### 1. Host NixOS Configuration (`~/Config`)
#### [MODIFY] `hosts/server/secrets.yaml`
Restructure keys from snake_case prefixes into nested service mappings:
```yaml
# ==============================================================================
# Homelab Server Secrets (SOPS-encrypted with Age)
# ==============================================================================
authelia:
session_secret: "<EXISTING_VALUE>"
storage_encryption_key: "<EXISTING_VALUE>"
jwt_secret: "<EXISTING_VALUE>" # formerly authelia_identity_validation_reset_password_jwt_secret
users:
kiskaadee:
password_hash: "$argon2id$v=19$m=65536,t=3,p=4$XUewW9HLpcJq9Yu6UOHL/w$i4rwAuWOEkHQMpEYot7WcAARX7PQ0qnJ7yH8cn5HxEs"
misa:
password_hash: "$argon2id$v=19$m=65536,t=3,p=4$B5z3JsSuL8/+gL6sMDbYmQ$R8Sc+LM9NE1JwKHqcvFCtuMpMV6mRi6AcrkokOuxMhY"
valenvg:
password_hash: "$argon2id$v=19$m=65536,t=3,p=4$D+/2velTM9OCNu2stE4fLQ$L+bfW0nSQ0yq8cApibPqflgzKg0RgOYTHjtkRqUkf9s"
traefik:
acme_email: "fcortesbio@gmail.com"
dynu:
api_key: "<EXISTING_VALUE>"
user: "kiskaadee"
domain: "roadtotech.me"
password: "<EXISTING_VALUE>"
postgres:
user: "kiskaadee"
password: "<EXISTING_VALUE>"
db: "pg_sandbox"
mongo:
root_username: "kiskaadee"
root_password: "<EXISTING_VALUE>"
ollama:
api_key: "<EXISTING_VALUE>"
gitea:
runner_token: "<EXISTING_VALUE>"
learning:
turso_db_url: "<EXISTING_VALUE>"
turso_auth_token: "<EXISTING_VALUE>"
system:
gh_repo_token: "<EXISTING_VALUE>"
pdf_decrypt_password: "1144095880"
```
---
#### [MODIFY] `hosts/server/homeserver.nix`
1. Define a declarative `autheliaUsers` attribute set in Nix for user metadata.
2. Dynamically render `sops.templates."users.yml"` by mapping over `autheliaUsers`.
3. Update `sops.secrets` to reference nested keys.
```nix
{ config, lib, pkgs, ... }:
let
# Declarative user database for Authelia
autheliaUsers = {
kiskaadee = {
displayName = "kiskaadee";
email = "fcortesbio@gmail.com";
groups = [ "admins" "dev" ];
passwordPlaceholder = config.sops.placeholder."authelia/users/kiskaadee/password_hash";
};
misa = {
displayName = "misa";
email = "icdf0728@gmail.com";
groups = [ "users" ];
passwordPlaceholder = config.sops.placeholder."authelia/users/misa/password_hash";
};
valenvg = {
displayName = "valenvg";
email = "vegavalentina069@gmail.com";
groups = [ "users" ];
passwordPlaceholder = config.sops.placeholder."authelia/users/valenvg/password_hash";
};
};
# Helper to render the YAML user block
renderUser = username: user: ''
${username}:
displayname: "${user.displayName}"
password: '${user.passwordPlaceholder}'
email: "${user.email}"
groups:
'' + (lib.concatMapStringsSep "\n" (g: " - ${g}") user.groups);
renderedUsersYaml = ''
users:
'' + (lib.concatStringsSep "\n\n" (lib.mapAttrsToList renderUser autheliaUsers)) + "\n";
in
{
sops.defaultSopsFile = ./secrets.yaml;
sops.defaultSopsFormat = "yaml";
sops.secrets = lib.genAttrs [
"dynu/api_key"
"traefik/acme_email"
"authelia/session_secret"
"authelia/storage_encryption_key"
"authelia/jwt_secret"
"authelia/users/kiskaadee/password_hash"
"authelia/users/misa/password_hash"
"authelia/users/valenvg/password_hash"
] (name: { owner = "kiskaadee"; });
sops.templates."homeserver.env" = {
owner = "kiskaadee";
content = lib.generators.toKeyValue {} {
DOMAIN = "roadtotech.me";
DOCKER_API_VERSION = "1.40";
DYNU_API_KEY = config.sops.placeholder."dynu/api_key";
ACME_EMAIL = config.sops.placeholder."traefik/acme_email";
AUTHELIA_SESSION_SECRET = config.sops.placeholder."authelia/session_secret";
AUTHELIA_STORAGE_ENCRYPTION_KEY = config.sops.placeholder."authelia/storage_encryption_key";
AUTHELIA_IDENTITY_VALIDATION_RESET_PASSWORD_JWT_SECRET = config.sops.placeholder."authelia/jwt_secret";
};
};
sops.templates."users.yml" = {
owner = "kiskaadee";
content = renderedUsersYaml;
};
# Systemd services remain unchanged
...
}
```
---
#### [MODIFY] `hosts/server/traefik-deployments.nix`
Update secrets mapping and environment placeholders to use `service/*`:
```nix
sops.secrets = lib.genAttrs [
"learning/turso_db_url"
"learning/turso_auth_token"
"mongo/root_username"
"mongo/root_password"
"ollama/api_key"
"postgres/user"
"postgres/password"
"postgres/db"
"gitea/runner_token"
] (name: { owner = "kiskaadee"; });
sops.templates."traefik-deployments.env" = {
owner = "kiskaadee";
content = lib.generators.toKeyValue {} {
...
GITEA_RUNNER_TOKEN = config.sops.placeholder."gitea/runner_token";
TURSO_DATABASE_URL = config.sops.placeholder."learning/turso_db_url";
TURSO_AUTH_TOKEN = config.sops.placeholder."learning/turso_auth_token";
MONGO_ROOT_USERNAME = config.sops.placeholder."mongo/root_username";
MONGO_ROOT_PASSWORD = config.sops.placeholder."mongo/root_password";
POSTGRES_USER = config.sops.placeholder."postgres/user";
POSTGRES_PASSWORD = config.sops.placeholder."postgres/password";
POSTGRES_DB = config.sops.placeholder."postgres/db";
OLLAMA_API_KEY = config.sops.placeholder."ollama/api_key";
...
};
};
```
---
#### [MODIFY] `hosts/server/dynu.nix`
Update DDNS secret keys:
```nix
sops.secrets."dynu/user" = { };
sops.secrets."dynu/domain" = { };
sops.secrets."dynu/password" = { };
sops.secrets."system/pdf_decrypt_password" = {
owner = "kiskaadee";
};
sops.templates."ddclient.conf" = {
content = builtins.replaceStrings
[ "@dynu_user@" "@dynu_password@" "@dynu_domain@" ]
[
config.sops.placeholder."dynu/user"
config.sops.placeholder."dynu/password"
config.sops.placeholder."dynu/domain"
]
(builtins.readFile ./ddclient.conf);
};
```
---
## Verification Plan
### Phase 1: NixOS Flake Evaluation & Secret Decryption
1. **Nix syntax & evaluation test**:
```bash
nixos-rebuild dry-build --flake /home/kiskaadee/Config#server
```
2. **Switch/Test Activation**:
```bash
sudo nixos-rebuild switch --flake /home/kiskaadee/Config#server
```
3. **Verify Rendered Files**:
- Check rendered environment:
```bash
head -n 10 /run/secrets/homeserver.env
```
- Check generated Authelia users database:
```bash
cat /run/secrets/users.yml
```
Verify all 3 users (`kiskaadee`, `misa`, `valenvg`) are present with valid Argon2id hash strings.
### Phase 2: Runtime Service Verification
1. **Restart Authelia to pick up new `users.yml`**:
```bash
appctl restart authelia
```
2. **Login Verification**:
- Verify `kiskaadee` login at `https://auth.roadtotech.me`.
- Verify `misa` login at `https://auth.roadtotech.me`.
- Verify `valenvg` login at `https://auth.roadtotech.me`.
3. **Verify other services**:
- Run `appctl status --core` to verify all services remain healthy.