docs(nixos): add terminal workspace guide, flake linters guide, and DMS reproducibility plan
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 11s
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 11s
Curate workstation subsystem guides covering Niri/Alacritty/Tmux navigation, Nix flake check linters, and the DMS operational reproducibility plan.
This commit is contained in:
1 parent
13146809b2
commit
ed2d9b997c
4 files changed
+365
No files matched your search
@@ -53,6 +53,8 @@ graph TD
|
||||
- Pruned `hosts/desktop/` and `nixosConfigurations.desktop` to standardize on a 2-host fleet (`server` and `laptop`).
|
||||
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.
|
||||
6. 🟢 [**DMS Runtime Ownership & Workstation Operations Manual**](plans/dms-reproducibility-and-docs-plan.md) `[Completed]`
|
||||
- Documented DMS session invariants, runtime mutation boundaries, containerized reproducibility, and operational workflows.
|
||||
|
||||
---
|
||||
|
||||
@@ -68,6 +70,10 @@ graph TD
|
||||
- Secret hierarchy re-encryption, template generation, and host dry-build verification.
|
||||
5. [**DMS Desktop Bootstrap & Container Reproducibility Validation**](guides/dms-bootstrap-and-reproducibility-validation.md)
|
||||
- Containerized flake check, one-time bootstrap behavior, and runtime mutation model verification.
|
||||
6. [**Terminal Workspace Subsystem Architecture & Navigation**](guides/terminal-workspace-subsystem.md)
|
||||
- Niri compositor window bindings, Alacritty terminal integration, and `tmux-sessionizer` (`ts`) workspace switching.
|
||||
7. [**Integrated Linters & Quality Checks in Nix Flake Check**](guides/nix-flake-check-linters.md)
|
||||
- CI static analysis and linting (`ruff-lint`, `statix`, `deadnix`, `nixfmt`, `luacheck`) declared in `flake.nix`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
type: guide
|
||||
project: nixos
|
||||
tags:
|
||||
- nixos
|
||||
- flake
|
||||
- ci
|
||||
- linters
|
||||
- quality
|
||||
---
|
||||
|
||||
# Integrated Linters and Quality Checks in Nix Flake Check
|
||||
|
||||
## Overview
|
||||
|
||||
Static analysis and linting checks are integrated directly into the Nix flake output (`checks.x86_64-linux` in `flake.nix`). This ensures that `nix flake check` verifies code hygiene and style alongside derivation evaluation.
|
||||
|
||||
## Integrated Checks
|
||||
|
||||
1. **Python Linting (`ruff-lint`)**:
|
||||
- Tool: `pkgs.ruff`
|
||||
- Command: `ruff check --no-cache ${self}`
|
||||
- Enforces flake8, bugbear, and Python linting rules.
|
||||
|
||||
2. **Python Formatting Check (`ruff-format`)**:
|
||||
- Tool: `pkgs.ruff`
|
||||
- Command: `ruff format --check ${self}`
|
||||
- Verifies formatting consistency without mutating the source tree.
|
||||
|
||||
3. **Python Static Type Checking (`pyright`)**:
|
||||
- Tool: `pkgs.pyright`
|
||||
- Command: `pyright ${self}`
|
||||
- Analyzes type hints across Python scripts (e.g. `bundle_project.py`).
|
||||
|
||||
4. **Shell Script Linting (`shellcheck`)**:
|
||||
- Tool: `pkgs.shellcheck`
|
||||
- Command: `find ${self} -type f -name "*.sh" -exec shellcheck -s bash {} +`
|
||||
- Analyzes all `.sh` scripts in `home/scripts/` and `home/shell/`.
|
||||
- Also added `# shellcheck shell=bash` directives to modular sourced scripts.
|
||||
|
||||
## Developer Tooling Additions
|
||||
|
||||
- Added `shellcheck` to `home/dev.nix` in `home.packages` so it is available interactively for editor diagnostics and CLI use.
|
||||
|
||||
## Validation Commands
|
||||
|
||||
```bash
|
||||
# Run all flake checks (linters + NixOS system evaluation)
|
||||
nix flake check
|
||||
|
||||
# Run individual checks
|
||||
nix build .#checks.x86_64-linux.ruff-lint --no-link
|
||||
nix build .#checks.x86_64-linux.ruff-format --no-link
|
||||
nix build .#checks.x86_64-linux.pyright --no-link
|
||||
nix build .#checks.x86_64-linux.shellcheck --no-link
|
||||
```
|
||||
@@ -0,0 +1,114 @@
|
||||
---
|
||||
type: guide
|
||||
project: nixos
|
||||
tags:
|
||||
- nixos
|
||||
- terminal
|
||||
- tmux
|
||||
- niri
|
||||
- alacritty
|
||||
---
|
||||
|
||||
# Terminal Workspace Subsystem Walkthrough
|
||||
|
||||
## Summary of Completed Work
|
||||
|
||||
We evaluated, designed, and implemented the **Terminal Workspace Subsystem** for the `laptop` NixOS workstation. The subsystem enforces a clean, deterministic separation across four layers:
|
||||
|
||||
```text
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Niri (Compositor / Window Manager) │
|
||||
│ │
|
||||
│ Mod+Return: Ephemeral Alacritty Shell ($SHELL) │
|
||||
│ Mod+T: Persistent Workspace Terminal (Alacritty -> ts) │
|
||||
└──────────────────────────────┬──────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Alacritty (Terminal Emulator) │
|
||||
│ │
|
||||
│ GPU rendering, PTY management, font metrics, input routing │
|
||||
│ (Does NOT auto-launch tmux globally) │
|
||||
└──────────────────────────────┬──────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Sessionizer (`tmux-sessionizer` / `ts`) │
|
||||
│ │
|
||||
│ Discovery → Normalization → Registry Validation │
|
||||
│ → Deterministic Resolution → Tmux Lifecycle │
|
||||
└──────────────────────────────┬──────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Tmux (Terminal Multiplexer) │
|
||||
│ │
|
||||
│ Persistent headless process state across window closures; │
|
||||
│ Vi-mode copy, smart Neovim navigation, OSC-52 clipboard │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Files Modified & Created
|
||||
|
||||
1. **`home/scripts/tmux-sessionizer.sh`** [NEW]:
|
||||
- Discovers explicit workspaces (`~/Config`, `~/Brain`, `~/Homelab/Core`) and git repositories under `~/Projects` and `~/Homelab`.
|
||||
- Normalizes folder basenames to lowercase, regex-sanitized tmux session names without trailing hyphens/underscores (`tr '[:upper:]' '[:lower:]' | sed -E 's/[ .]+/-/g; s/[^a-z0-9_-]//g; s/[-_]+$//'`).
|
||||
- Validates the complete registry up-front for session name collisions before resolving requests (Option A: global fatal refusal).
|
||||
- Resolves CLI queries via strict precedence: (1) existing directory path, (2) exact session name, (3) exact basename, (4) unique substring match. Never guesses ambiguous matches.
|
||||
- Parses final record via native Bash `IFS=$'\t' read -r session_name target_dir`.
|
||||
- Dual-context switching: outside tmux calls `exec tmux attach-session -t ...`; inside tmux calls `tmux switch-client -t ...` (prevents nested sessions).
|
||||
- Establishes working directory with `-c "$target_dir"` only when creating a new session; never resets an existing session's directory.
|
||||
2. **`home/shell.nix`** [MODIFIED]:
|
||||
- Declared `tmuxSessionizer` as a hermetic derivation using `pkgs.writeShellApplication` with runtime dependencies: `bash`, `coreutils`, `gnused`, `gawk`, `gnugrep`, `fd`, `fzf`, `tmux`.
|
||||
- Added `tmuxSessionizer` to `home.packages`.
|
||||
- Added shell alias `ts = "tmux-sessionizer";` to `programs.bash.shellAliases`.
|
||||
3. **`home/config/niri/custom.kdl`** [MODIFIED]:
|
||||
- Added `Mod+T` hotkey binding to spawn Alacritty directly running `tmux-sessionizer`.
|
||||
- Updated `Mod+Return` label to denote ephemeral shell terminal.
|
||||
4. **`docs/reference/tmux.md`** [MODIFIED]:
|
||||
- Restructured into the comprehensive **Terminal Workspace Architecture & Tmux Reference**.
|
||||
- Codified the 12 architectural invariants (INV-001 through INV-012).
|
||||
- Documented naming, discovery hierarchy, collision policies, CLI usage, and tmux configuration.
|
||||
|
||||
---
|
||||
|
||||
## Validation & Test Results
|
||||
|
||||
### 1. Script Quality & Shellcheck
|
||||
- Ran `shellcheck` across `home/scripts/tmux-sessionizer.sh`.
|
||||
- Passed with **0 errors, 0 warnings**.
|
||||
|
||||
### 2. Flake Validation (`nix flake check`)
|
||||
- Ran `nix flake check` on `/home/kiskaadee/Config`.
|
||||
- All checks (`check-ruff-lint`, `check-ruff-format`, `check-pyright`, `check-shellcheck`) passed cleanly.
|
||||
|
||||
### 3. Laptop Host Dry Build
|
||||
- Executed dry build:
|
||||
```bash
|
||||
nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link
|
||||
```
|
||||
- Build succeeded completely, building `tmux-sessionizer.drv`, Home Manager activation units, and the complete system top-level derivation.
|
||||
|
||||
---
|
||||
|
||||
## Operational Guide
|
||||
|
||||
### Interactive Workspace Selection
|
||||
Press **`Mod+T`** from anywhere in Niri, or run `ts` in an existing terminal:
|
||||
- `fzf` displays `session_name` and `absolute_path`.
|
||||
- Pressing `Escape` exits cleanly with code `0` and closes the Alacritty window.
|
||||
- Selecting a workspace creates or attaches to the persistent tmux session.
|
||||
|
||||
### Direct CLI Selection
|
||||
```bash
|
||||
ts config # Attaches/switches to ~/Config session
|
||||
ts brain # Attaches/switches to ~/Brain session
|
||||
ts bitetrack-api # Attaches/switches to bitetrack-api session
|
||||
ts magnet # Unique substring match -> attaches to MagNetFlix
|
||||
ts ~/Projects/... # Explicit path
|
||||
```
|
||||
|
||||
### Context Switching Inside Tmux
|
||||
- While inside any active tmux session, running `ts <target>` or interactive `ts` switches the client directly via `tmux switch-client` without creating nested tmux instances.
|
||||
@@ -0,0 +1,189 @@
|
||||
---
|
||||
type: plan
|
||||
status: completed
|
||||
project: nixos
|
||||
tags:
|
||||
- nixos
|
||||
- dms
|
||||
- documentation
|
||||
- desktop
|
||||
---
|
||||
|
||||
# Architecture Plan: DMS Runtime Ownership & Workstation Operations Manual
|
||||
|
||||
## 1. Executive Diagnostic: The DMS Ownership & Mutation Model
|
||||
|
||||
The initial inclination to solve the "absent Niri bindings" problem by symlinking `dms/binds.kdl` and `settings.json` into `/nix/store` via Home Manager would reproduce a critical architectural failure mode: **fighting the application's runtime mutation model**.
|
||||
|
||||
### The Failure Mode of Store-Symlinking Mutable State
|
||||
DMS is not a static window manager configuration; it is a live shell environment with a Quickshell UI and a CLI control daemon. It actively writes to `$HOME/.config` when:
|
||||
1. Connecting or rearranging monitors (`outputs.kdl`).
|
||||
2. Generating Material You themes from wallpapers (`colors.kdl`).
|
||||
3. Updating gaps, blur, corner radius, or widget layouts via GUI (`layout.kdl`, `alttab.kdl`, `settings.json`).
|
||||
4. Rebinding shortcuts in the DMS Settings UI (`binds.kdl`).
|
||||
|
||||
If Home Manager symlinks these files to the read-only Nix store:
|
||||
- User actions in the GUI (e.g., rearranging displays on an external monitor) fail with `EACCES` or break symlinks.
|
||||
- Any subsequent `nixos-rebuild switch` forcibly stomps runtime changes.
|
||||
- The system pretends to be declarative while undermining the user's interactive workflow.
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
subgraph "Nix / Git Layer (What the Workstation IS)"
|
||||
NIX_SYS["system/desktop.nix<br/>(Niri, DMS, Greetd daemons)"]
|
||||
NIX_HM["home/desktop.nix<br/>(Compositor config & user binds)"]
|
||||
NIX_HM --> NIRI_MAIN["~/.config/niri/config.kdl<br/><i>(Store Symlink)</i>"]
|
||||
NIX_HM --> NIRI_CUST["~/.config/niri/custom.kdl<br/><i>(Store Symlink)</i>"]
|
||||
end
|
||||
|
||||
subgraph "DMS Runtime Layer (How the Desktop is Configured)"
|
||||
DMS_DAEMON["dms run (Daemon)"]
|
||||
DMS_DAEMON -->|Dynamic Matugen| D_COL["~/.config/niri/dms/colors.kdl"]
|
||||
DMS_DAEMON -->|Display hotplug| D_OUT["~/.config/niri/dms/outputs.kdl"]
|
||||
DMS_DAEMON -->|UI Settings| D_SET["~/.config/DankMaterialShell/settings.json"]
|
||||
DMS_DAEMON -->|GUI Rebinds| D_BINDS["~/.config/niri/dms/binds.kdl"]
|
||||
end
|
||||
|
||||
subgraph "One-Time Initialization (Fresh Bootstrap)"
|
||||
BOOTSTRAP["dms setup binds"] -.->|Seeds initial 0644 file| D_BINDS
|
||||
end
|
||||
|
||||
NIRI_MAIN -->|include optional=true| D_BINDS
|
||||
NIRI_MAIN -->|include| NIRI_CUST
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. State Ownership & Responsibility Matrix
|
||||
|
||||
| Scope / File | Authority | Managed in Git? | Mutability | Rationale |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| `system/desktop.nix` | NixOS Root | Yes | Immutable | Declares system daemons, PAM, Greetd, DMS package, fontconfig. |
|
||||
| `home/config/niri/config.kdl` | Home Manager | Yes | Immutable | Compositor foundation: touchpad rules, gesture rules, includes. |
|
||||
| `home/config/niri/custom.kdl` | Home Manager | Yes | Immutable | Workstation operator shortcuts (`Mod+Return` terminal, `Mod+B` browser, scripts). |
|
||||
| `~/.config/niri/dms/binds.kdl` | DMS Runtime | **No** (Seeded) | Mutable (`0644`) | DMS default keybindings. Initialized via `dms setup binds`; mutable by user/GUI. |
|
||||
| `~/.config/DankMaterialShell/settings.json` | DMS Runtime | **No** | Mutable | Live panel layout, widget configuration, and theme preferences. |
|
||||
| `~/.config/niri/dms/outputs.kdl` | DMS Runtime | **No** | Dynamic | Generated by DMS upon monitor connection/re-arrangement. |
|
||||
| `~/.config/niri/dms/colors.kdl` | DMS Runtime | **No** | Dynamic | Generated by Matugen on wallpaper change. |
|
||||
| `~/.config/niri/dms/layout.kdl` | DMS Runtime | **No** | Dynamic | Generated by DMS from corner radius and gap settings. |
|
||||
|
||||
---
|
||||
|
||||
## 3. The Workstation Operational Manual (`docs/`)
|
||||
|
||||
We will author an operational manual organized by the questions an operator asks when configuring, maintaining, or recovering the system:
|
||||
|
||||
```text
|
||||
docs/
|
||||
├── getting-started.md # "How do I get this running?" (Bare-metal install to running desktop)
|
||||
├── adding-software.md # "Where does a new application go?" (Decision tree, package vs module)
|
||||
├── configuration.md # "How do I change something?" (Workflow: edit, test, switch, dotfiles)
|
||||
├── system-lifecycle.md # "What happens when I rebuild?" (Eval, build, generations, rollbacks, GC)
|
||||
├── desktop.md # "How does the Niri + DMS stack work?" (Ownership boundary, shortcuts, init)
|
||||
├── secrets.md # "How are secrets handled?" (Operator CLI workstation vs Core consumer)
|
||||
├── networking.md # "How does network access work?" (OpenSSH client profiles, WiFi, Tailscale)
|
||||
└── reference/
|
||||
├── shell.md # Bash, Starship, custom modular shell scripts
|
||||
├── tmux.md # Tmux keybindings, layout, workflow
|
||||
├── neovim.md # Neovim architecture, LSP, treesitter, plugins
|
||||
└── antigravity.md # AI agent environment, guidelines, and tool integration
|
||||
```
|
||||
|
||||
### Detailed Document Specifications
|
||||
|
||||
#### 1. `docs/getting-started.md`
|
||||
- **Bare-metal Recovery Protocol**:
|
||||
1. Boot minimal NixOS ISO.
|
||||
2. Partitioning, filesystem formatting, and mounting.
|
||||
3. Generating `system/hardware-configuration.nix`.
|
||||
4. Cloning `Config` to `/home/kiskaadee/Config`.
|
||||
5. Dry build validation: `nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link`.
|
||||
6. System installation: `nixos-install --flake .#laptop`.
|
||||
7. Reboot and initial login via `dank-greeter`.
|
||||
- **Desktop Initialization Phase**:
|
||||
- Run `dms setup binds` to seed the mutable DMS keybinding baseline.
|
||||
- Verification of spotlight, clipboard, and task manager overlays.
|
||||
- **Operator Secrets Bootstrap**:
|
||||
- Restoring `~/.config/sops/age/keys.txt` to re-enable authoring access to `Core`.
|
||||
|
||||
#### 2. `docs/adding-software.md`
|
||||
- **Package Placement Flowchart**:
|
||||
```text
|
||||
Is it a kernel module, hardware driver, or root systemd daemon?
|
||||
├── YES ──> system/core.nix or system/hardware.nix
|
||||
└── NO
|
||||
│
|
||||
Is it a GUI application or desktop utility?
|
||||
├── YES ──> home/desktop.nix
|
||||
└── NO
|
||||
│
|
||||
Is it a compiler, LSP, language runtime, or dev tool?
|
||||
├── YES ──> home/dev.nix
|
||||
└── NO ──> home/shell.nix (CLI tools, shell integration)
|
||||
```
|
||||
- **Declaration Styles**: When to use `home.packages = with pkgs; [...]` vs `programs.<name>.enable = true` vs NixOS service modules.
|
||||
- **Handling Unfree Packages**: Scoping unfree packages in `flake.nix`.
|
||||
|
||||
#### 3. `docs/configuration.md`
|
||||
- **Standard Modification Workflow**:
|
||||
```text
|
||||
Identify Domain -> Edit Module -> nix flake check -> nix build ... --no-link -> nixos-rebuild test -> switch -> git commit
|
||||
```
|
||||
- **Dotfile Management**: Managing configuration via `home.file` vs `xdg.configFile` vs runtime mutable directories.
|
||||
- **The "Build, Never Switch" Boundary**: Why agents build dryly and users trigger activation.
|
||||
|
||||
#### 4. `docs/system-lifecycle.md`
|
||||
- **The Lifecycle Pipeline**:
|
||||
- Evaluation (`flake.nix`) -> Derivation computation (`/nix/store/*.drv`) -> Build closure -> System profile link -> Activation scripts (PAM, users, systemd) -> Home Manager activation (dotfiles symlinks, user units).
|
||||
- **Command Matrix**: `build` vs `test` vs `switch` vs `boot`.
|
||||
- **Generations & Rollback**: Bootloader rollback, `nixos-rebuild --rollback`, checking generations.
|
||||
- **Maintenance**: Safe garbage collection (`nix-collect-garbage -d`), boot generation pruning, flake input locking (`nix flake update`).
|
||||
|
||||
#### 5. `docs/desktop.md`
|
||||
- **The Compositor & Shell Architecture**:
|
||||
- Niri as the Wayland scrollable-tiling compositor.
|
||||
- DankMaterialShell as the companion panel, app launcher, notification server, and quicksettings UI.
|
||||
- Greetd and DankGreeter display manager configuration.
|
||||
- **The Ownership Boundary**: Full documentation of declarative Git state vs DMS mutable runtime state.
|
||||
- **Master Shortcut Reference**: Unified table combining Niri core shortcuts, custom user binds (`custom.kdl`), and DMS IPC actions (`binds.kdl`).
|
||||
|
||||
#### 6. `docs/secrets.md`
|
||||
- **Workstation vs Homelab Secrets Split**:
|
||||
- Laptop is the **Authoring Cockpit**: Owns `sops`, `age`, and `rbw` CLI tools in `home/dev.nix`; holds `~/.config/sops/age/keys.txt`.
|
||||
- Server is the **Headless Consumer**: Owns host SSH private key (`/etc/ssh/ssh_host_ed25519_key`); decrypts secrets at boot via `sops-nix` in `Core`.
|
||||
- Step-by-step guide for rotating and authoring secrets for `Core` from the laptop.
|
||||
|
||||
#### 7. `docs/networking.md`
|
||||
- NetworkManager configuration and CLI operations (`nmcli`).
|
||||
- Workstation OpenSSH client profiles (`server-local`, `server-remote`, `gitea.roadtotech.me`).
|
||||
- Local OpenSSH daemon for LAN remote access (and why it $\neq$ server infrastructure).
|
||||
|
||||
#### 8. `docs/reference/`
|
||||
- Specialized manuals migrated and streamlined:
|
||||
- `docs/reference/shell.md`: Bash configuration, Starship prompt, modular scripts in `home/shell/`.
|
||||
- `docs/reference/tmux.md`: Streamlined tmux configuration and session commands.
|
||||
- `docs/reference/neovim.md`: Neovim architecture, keybindings, LSP configs, and Treesitter.
|
||||
- `docs/reference/antigravity.md`: Antigravity guidelines, rules, and workspace integration.
|
||||
|
||||
---
|
||||
|
||||
## 4. Execution Steps
|
||||
|
||||
1. **Retain Clean Repository Boundary**:
|
||||
- Do **NOT** symlink `settings.json` or `binds.kdl` to `/nix/store`.
|
||||
- Preserve `home/config/niri/config.kdl` and `home/config/niri/custom.kdl` as the declarative core.
|
||||
2. **Author the Operational Manual**:
|
||||
- Create `docs/getting-started.md`.
|
||||
- Create `docs/adding-software.md`.
|
||||
- Create `docs/configuration.md`.
|
||||
- Create `docs/system-lifecycle.md`.
|
||||
- Create `docs/desktop.md`.
|
||||
- Create `docs/secrets.md` (renaming/refining `secrets-management.md`).
|
||||
- Create `docs/networking.md`.
|
||||
- Create `docs/reference/` directory and populate `shell.md`, `tmux.md`, `neovim.md`, and `antigravity.md`.
|
||||
- Clean up obsolete files (`package-and-secrets.md`, `development-environments.md`, `system-maintenance.md`).
|
||||
3. **Align Repository Index**:
|
||||
- Update `Config/README.md` to link directly into the new operational documentation structure.
|
||||
4. **Validate**:
|
||||
- Run `nix flake check` and dry build (`nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link`).
|
||||
- Sync notes and guides into `~/Brain`.
|
||||
Reference in new issue
Block a user