refactor: decouple sops-nix from workstation, update documentation, and clean up scripts
- Remove `sops-nix` input and integration modules from `flake.nix` and `flake.lock`. - Transition secrets management documentation (`docs/secrets-management.md`, `docs/package-and-secrets.md`) to reflect the workstation's role as an operator management station targeting the decoupled Core repository. - Remove obsolete `$HOME/Core/scripts` from user `sessionPath` in `home/default.nix` and `home/shell.nix`. - Clean up Hyprland code paths in the Niri-native `record.sh` utility. - Refine DMS options in `system/desktop.nix`.
This commit is contained in:
1 parent
4d9b5e6034
commit
7c5e14c905
16 files changed
+116
-192
No files matched your search
-12
@@ -1,12 +0,0 @@
|
|||||||
keys:
|
|
||||||
- &server age18q3lr2z4yeg2f86my42ym4hx0dvcwgjshmchyhdkgwvf4k37dsyq3mcjse
|
|
||||||
- &laptop age1pln9sxy5j93lklqklfwp3qepx7x4cs4y2w63n9y3ykt68qgra5ysqleesg
|
|
||||||
|
|
||||||
creation_rules:
|
|
||||||
- path_regex: hosts/(server|laptop)/secrets\.yaml$
|
|
||||||
key_groups:
|
|
||||||
- pgp: []
|
|
||||||
age:
|
|
||||||
- *server
|
|
||||||
- *laptop
|
|
||||||
|
|
||||||
@@ -126,6 +126,6 @@ sudo nixos-rebuild switch --flake ~/Config#laptop
|
|||||||
* [Package & Secrets Workflow Guide](docs/package-and-secrets.md) — Steps for adding custom applications and managing secrets.
|
* [Package & Secrets Workflow Guide](docs/package-and-secrets.md) — Steps for adding custom applications and managing secrets.
|
||||||
* [System Maintenance Guide](docs/system-maintenance.md) — Instructions for safe system updates, health checking, and garbage collection.
|
* [System Maintenance Guide](docs/system-maintenance.md) — Instructions for safe system updates, health checking, and garbage collection.
|
||||||
* [Declarative Development Environments](docs/development-environments.md) — How to use nix-shell, devShells, direnv, and uv for project isolation.
|
* [Declarative Development Environments](docs/development-environments.md) — How to use nix-shell, devShells, direnv, and uv for project isolation.
|
||||||
* [Secrets Management Details](docs/secrets-management.md) — Secure storage bootstrapping using `sops-nix` and `age`.
|
* [Secrets Management Guide](docs/secrets-management.md) — GitOps secrets workflow using SOPS and age for homelab Core management.
|
||||||
* [Tmux Terminal Multiplexer](docs/tmux.md) — Fast navigation bindings, layouts, and pane splits guide.
|
* [Tmux Terminal Multiplexer](docs/tmux.md) — Fast navigation bindings, layouts, and pane splits guide.
|
||||||
* [Google Antigravity Setup](docs/antigravity.md) — Technical instructions for packaging and using the Antigravity agent CLI on NixOS.
|
* [Google Antigravity Setup](docs/antigravity.md) — Technical instructions for packaging and using the Antigravity agent CLI on NixOS.
|
||||||
+33
-28
@@ -4,12 +4,13 @@
|
|||||||
|
|
||||||
This repository manages a purely declarative NixOS and Home Manager configuration for a standalone mobile workstation host (`laptop`).
|
This repository manages a purely declarative NixOS and Home Manager configuration for a standalone mobile workstation host (`laptop`).
|
||||||
|
|
||||||
1. **Git is the Source of Truth**: Every persistent system setting, user dotfile, and toolchain declaration must be declaratively defined within this repository.
|
1. **Git is the Source of Truth for Configuration**: Every persistent configuration decision intended to be reproducible is declaratively defined within this repository. Dynamic runtime state (SSH host private keys, machine-id, user application state, caches, browser profiles, and Docker volumes) lives outside the declarative boundary.
|
||||||
2. **Domain-Driven Cohesion**: Configuration is organized by functional domain (`core`, `hardware`, `desktop`, `dev`, `shell`) rather than artificial host tiers or defensive multi-machine boundaries.
|
2. **Domain-Driven Cohesion**: Configuration is organized by functional domain (`core`, `hardware`, `desktop`, `dev`, `shell`) rather than artificial multi-machine abstractions.
|
||||||
3. **Privilege Boundary Separation**:
|
3. **Privilege Boundary Separation**:
|
||||||
- **`system/` (Root/NixOS)**: Governs hardware, kernel, bootloader, base OS daemons, and system-level compositor enablement.
|
- **`system/` (Root/NixOS)**: Governs hardware, kernel, bootloader, base OS daemons, and system-level compositor enablement.
|
||||||
- **`home/` (User/Home Manager)**: Governs user dotfiles, application settings, toolchains, and desktop keybindings inside `/home/kiskaadee`.
|
- **`home/` (User/Home Manager)**: Governs user dotfiles, application settings, toolchains, and desktop keybindings inside `/home/kiskaadee`.
|
||||||
4. **Decoupled Homelab Infrastructure**: Production server daemons, Docker stacks, Traefik edge routing, and DDNS automation are maintained independently in the [Core](file:///home/kiskaadee/Projects/active/homelab/Core) repository.
|
4. **Decoupled Homelab Infrastructure**: Production server daemons, Docker stacks, Traefik edge routing, and DDNS automation are maintained independently in the [Core](file:///home/kiskaadee/Projects/active/homelab/Core) repository.
|
||||||
|
5. **Workstation Remote Access ≠ Server Infrastructure**: Local system daemons (such as the OpenSSH server) are legitimate workstation facilities for LAN access, remote editor attachments, and file transfers. They do not constitute "server infrastructure," which refers to independently operated application workloads and edge proxies.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -17,20 +18,20 @@ This repository manages a purely declarative NixOS and Home Manager configuratio
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
Config/
|
Config/
|
||||||
├── flake.nix # Flake inputs and nixosConfigurations.laptop entrypoint
|
├── flake.nix # Flake inputs and composition root for nixosConfigurations.laptop
|
||||||
├── flake.lock # Pinned dependency revisions
|
├── flake.lock # Pinned dependency revisions
|
||||||
│
|
│
|
||||||
├── system/ # NixOS system-level configuration (root / privileged)
|
├── system/ # NixOS system-level configuration (root / privileged)
|
||||||
│ ├── default.nix # System composition entrypoint
|
│ ├── default.nix # System composition entrypoint
|
||||||
│ ├── hardware-configuration.nix # Generated hardware scan (disks, CPU, kernel modules)
|
│ ├── hardware-configuration.nix # Generated hardware scan (disks, CPU, kernel modules)
|
||||||
│ ├── core.nix # Base OS: networking, users, locale, openssh, nix-ld
|
│ ├── core.nix # Base OS: networking, users, locale, openssh, nix-ld
|
||||||
│ ├── hardware.nix # Laptop hardware: power daemon, upower, PipeWire, bluetooth, printing, docker
|
│ ├── hardware.nix # Machine services & peripherals: power, PipeWire, bluetooth, printing, docker
|
||||||
│ └── desktop.nix # Desktop stack: Niri compositor, DMS, greetd, fonts
|
│ └── desktop.nix # Desktop stack: Niri compositor, DMS daemon, greetd, fonts
|
||||||
│
|
│
|
||||||
├── home/ # Home Manager user-level configuration (kiskaadee)
|
├── home/ # Home Manager user-level configuration (kiskaadee)
|
||||||
│ ├── default.nix # User session entrypoint (paths, state version)
|
│ ├── default.nix # User session entrypoint (paths, state version)
|
||||||
│ ├── desktop.nix # Graphical apps (Zen, Zed, media), Wayland tools, DankSearch, Niri/Zed dotfiles
|
│ ├── desktop.nix # Graphical apps (Zen, Zed, media), Wayland tools, DankSearch, Niri/Zed dotfiles
|
||||||
│ ├── dev.nix # Developer toolchains (Rust, Python, Node, LSPs), Antigravity, Neovim
|
│ ├── dev.nix # Developer toolchains (Rust, Python, Node, LSPs), Antigravity, Neovim, SOPS/age CLI
|
||||||
│ ├── shell.nix # Interactive shell (Bash, aliases, modular scripts), Git, Delta, Tmux, Starship
|
│ ├── shell.nix # Interactive shell (Bash, aliases, modular scripts), Git, Delta, Tmux, Starship
|
||||||
│ ├── config/ # Managed application dotfiles (alacritty, niri, nvim, zed, fastfetch, tmux)
|
│ ├── config/ # Managed application dotfiles (alacritty, niri, nvim, zed, fastfetch, tmux)
|
||||||
│ ├── scripts/ # Standalone helper scripts (bundle-project, record)
|
│ ├── scripts/ # Standalone helper scripts (bundle-project, record)
|
||||||
@@ -41,46 +42,48 @@ Config/
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Layer Responsibilities
|
## Layer Responsibilities & Composition Roots
|
||||||
|
|
||||||
|
The repository utilizes a dual-composition model anchored by `flake.nix`:
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
graph TD
|
graph TD
|
||||||
FLAKE["flake.nix"] --> CFG["nixosConfigurations.laptop"]
|
FLAKE["flake.nix<br/><i>(Composition Root)</i>"] --> CFG["nixosConfigurations.laptop"]
|
||||||
|
|
||||||
subgraph System Layer ["system/ (Privileged Root / NixOS)"]
|
subgraph System Layer ["system/ (Privileged Root / NixOS)"]
|
||||||
CFG --> S_DEF["system/default.nix"]
|
CFG --> S_DEF["system/default.nix"]
|
||||||
S_DEF --> S_HW["hardware-configuration.nix"]
|
S_DEF --> S_HW["hardware-configuration.nix"]
|
||||||
S_DEF --> S_CORE["core.nix<br/><i>(Host, Users, Boot, Nix-LD)</i>"]
|
S_DEF --> S_CORE["core.nix<br/><i>(Host, Users, Boot, OpenSSH, Nix-LD)</i>"]
|
||||||
S_DEF --> S_DEV["hardware.nix<br/><i>(Power, PipeWire, Bluetooth, Printing)</i>"]
|
S_DEF --> S_DEV["hardware.nix<br/><i>(Power, PipeWire, Bluetooth, Printing, Docker)</i>"]
|
||||||
S_DEF --> S_DESK["desktop.nix<br/><i>(Niri, DMS Daemon, Greeter, Fonts)</i>"]
|
S_DEF --> S_DESK["desktop.nix<br/><i>(Niri, DMS Daemon, Greeter, Fonts)</i>"]
|
||||||
end
|
end
|
||||||
|
|
||||||
subgraph User Layer ["home/ (Unprivileged User / Home Manager)"]
|
subgraph User Layer ["home/ (Unprivileged User / Home Manager)"]
|
||||||
CFG --> H_DEF["home/default.nix"]
|
CFG --> H_DEF["home/default.nix"]
|
||||||
H_DEF --> H_DESK["desktop.nix<br/><i>(GUI Apps, Wayland Tools, Alacritty, Zed, Niri Config)</i>"]
|
H_DEF --> H_DESK["desktop.nix<br/><i>(GUI Apps, Wayland Tools, Alacritty, Zed, Niri Config)</i>"]
|
||||||
H_DEF --> H_DEV["dev.nix<br/><i>(Neovim, Compilers, LSPs, Antigravity, Cloud Tools)</i>"]
|
H_DEF --> H_DEV["dev.nix<br/><i>(Neovim, Compilers, LSPs, Antigravity, SOPS/age CLI)</i>"]
|
||||||
H_DEF --> H_SH["shell.nix<br/><i>(Bash, Git, Delta, Tmux, Starship, Fastfetch)</i>"]
|
H_DEF --> H_SH["shell.nix<br/><i>(Bash, Git, Delta, Tmux, Starship, Fastfetch)</i>"]
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
### 1. `flake.nix`
|
### 1. `flake.nix`
|
||||||
- **Role**: Public entry point declaring external flake inputs (`nixpkgs`, `home-manager`, `dms`, `zen-browser`, `antigravity`, etc.) and composing the single `laptop` target.
|
- **Role**: Sole public composition root declaring external flake inputs (`nixpkgs`, `home-manager`, `dms`, `zen-browser`, `antigravity`, etc.) and wiring `system/` and `home/` into the `laptop` target.
|
||||||
- **Rule**: Contains only inputs and host output definitions. No package lists or host-specific options.
|
- **Rule**: Contains only inputs and host output definitions. No inline packages, scripts, or machine-specific options.
|
||||||
|
|
||||||
### 2. `system/`
|
### 2. `system/` (Machine Privileged Layer)
|
||||||
- **Role**: Contains all system-level declarations requiring root privileges.
|
- **Role**: Contains all machine-level declarations requiring root privileges.
|
||||||
- **Components**:
|
- **Components**:
|
||||||
- `hardware-configuration.nix`: Generated hardware parameters (managed by `nixos-generate-config`).
|
- `hardware-configuration.nix`: Generated hardware parameters (managed by `nixos-generate-config`).
|
||||||
- `core.nix`: Bootloader (`systemd-boot`), network identity, time zone, locale, main user account (`kiskaadee`), unfree license acceptance, and `nix-ld` dynamic library loader.
|
- `core.nix`: Bootloader (`systemd-boot`), network identity, time zone, locale, main user account (`kiskaadee`), dynamic binary support (`nix-ld`), and workstation remote access (`openssh`).
|
||||||
- `hardware.nix`: Power & battery management (`power-profiles-daemon`, `upower`, `brightnessctl`), PipeWire audio, Bluetooth, printing/scanning drivers, and Docker runtime.
|
- `hardware.nix`: Machine services & peripherals (`power-profiles-daemon`, `upower`, `brightnessctl`), PipeWire audio, Bluetooth, printing/scanning drivers, and Docker runtime.
|
||||||
- `desktop.nix`: Niri window manager enablement, DMS background daemon & greeter, greetd login manager, typography/fonts, and Wayland session environment variables.
|
- `desktop.nix`: Niri window manager enablement, DMS background daemon & greeter, greetd login manager, typography/fonts, and Wayland session environment variables.
|
||||||
|
|
||||||
### 3. `home/`
|
### 3. `home/` (User-Space Interactive Layer)
|
||||||
- **Role**: Contains all user-space declarations and dotfiles managed by Home Manager.
|
- **Role**: Contains all user-space declarations and dotfiles managed by Home Manager.
|
||||||
- **Components**:
|
- **Components**:
|
||||||
- `default.nix`: Root user environment declaration (username, home directory, state version, session paths).
|
- `default.nix`: Root user environment declaration (username, home directory, state version, session search paths).
|
||||||
- `desktop.nix`: Graphical productivity tools, Wayland screen capture/clipboard utilities, Alacritty terminal emulator, Firefox profile, DankSearch indexer, and declarative symlinks for Niri (`config.kdl`, `custom.kdl`) and Zed (`settings.json`, themes).
|
- `desktop.nix`: Graphical productivity tools, Wayland screen capture/clipboard utilities, Alacritty terminal emulator, Firefox profile, DankSearch indexer, and declarative symlinks for Niri (`config.kdl`, `custom.kdl`) and Zed (`settings.json`, themes).
|
||||||
- `dev.nix`: Neovim editor configuration (Lua init, Tree-sitter, LSP plugins, DAP), toolchains (Rust, Python, Node), language servers, API testing tools (`httpie`, `bruno`), and Antigravity CLI.
|
- `dev.nix`: Neovim editor configuration (Lua init, Tree-sitter, LSP plugins, DAP), toolchains (Rust, Python, Node), language servers, API testing tools, Antigravity CLI, and operator secrets tooling (`sops`, `age`, `rbw`).
|
||||||
- `shell.nix`: Bash shell aliases, prompt (`starship`), multiplexer (`tmux`), Git/Delta configuration, SSH client profiles, and modular shell helpers.
|
- `shell.nix`: Bash shell aliases, prompt (`starship`), multiplexer (`tmux`), Git/Delta configuration, SSH client profiles, and modular shell helpers.
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -91,24 +94,26 @@ graph TD
|
|||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| **External Dependencies** | `flake.nix` | Flake inputs only; lock `inputs.nixpkgs.follows` where applicable. |
|
| **External Dependencies** | `flake.nix` | Flake inputs only; lock `inputs.nixpkgs.follows` where applicable. |
|
||||||
| **Kernel / Disks / Firmware** | `system/hardware-configuration.nix` | Generated hardware scan. Do not manually restructure. |
|
| **Kernel / Disks / Firmware** | `system/hardware-configuration.nix` | Generated hardware scan. Do not manually restructure. |
|
||||||
| **Root OS / User Groups / Boot** | `system/core.nix` | Bootloader, users, host name, locale, nix-ld. |
|
| **Root OS / User Groups / Boot** | `system/core.nix` | Bootloader, users, host name, locale, nix-ld, workstation SSH daemon. |
|
||||||
| **Machine Hardware Services** | `system/hardware.nix` | Audio, power profiles, battery, bluetooth, printing, docker. |
|
| **Machine Services & Peripherals**| `system/hardware.nix` | Audio, power profiles, battery, bluetooth, printing, docker. |
|
||||||
| **System Compositor & Greeter** | `system/desktop.nix` | Niri enablement, greetd, DMS shell daemon, system fonts. |
|
| **System Compositor & Greeter** | `system/desktop.nix` | Niri enablement, greetd, DMS shell daemon, system fonts. |
|
||||||
| **GUI Apps & Wayland Utilities** | `home/desktop.nix` | Browser, Zed, Alacritty, clipboard, screen capture tools. |
|
| **GUI Apps & Wayland Utilities** | `home/desktop.nix` | Browser, Zed, Alacritty, clipboard, screen capture tools. |
|
||||||
| **Compilers, LSPs & Editors** | `home/dev.nix` | Neovim, toolchains, language servers, developer utilities. |
|
| **Compilers, LSPs & Editors** | `home/dev.nix` | Neovim, toolchains, language servers, developer utilities. |
|
||||||
| **Shell, Aliases & Multiplexer** | `home/shell.nix` | Bash, Tmux, Starship, Fastfetch, Git, Direnv, SSH config. |
|
| **Shell, Aliases & Multiplexer** | `home/shell.nix` | Bash, Tmux, Starship, Fastfetch, Git, Direnv, SSH client config. |
|
||||||
| **Static Application Dotfiles** | `home/config/` | Application configs linked into `$HOME/.config/`. |
|
| **Static Application Dotfiles** | `home/config/` | Application configs linked into `$HOME/.config/`. |
|
||||||
| **Standalone Scripts** | `home/scripts/` | Executable user utility scripts. |
|
| **Standalone Scripts** | `home/scripts/` | Executable user utility scripts. |
|
||||||
| **Modular Shell Helpers** | `home/shell/` | Discrete `.sh` files sourced by `.bashrc`. |
|
| **Modular Shell Helpers** | `home/shell/` | Discrete `.sh` files sourced by `.bashrc`. |
|
||||||
| **Encrypted Secrets** | SOPS / age | Decrypted dynamically into memory at runtime via SOPS. |
|
| **Operator Secrets Tooling** | `home/dev.nix` | `sops`, `age`, and `rbw` CLI tools for authoring Core homelab secrets. |
|
||||||
| **Homelab Services** | `~/Projects/active/homelab/Core` | Managed independently in the Core repository. |
|
| **Homelab Services & Secrets** | `~/Projects/active/homelab/Core` | Managed independently in the Core repository. |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Architectural Invariants
|
## Architectural Invariants
|
||||||
|
|
||||||
1. **Single Entrypoint Invariant**: `flake.nix` is the sole entrypoint for building the workstation system (`laptop`).
|
1. **Single Entrypoint Invariant**: `flake.nix` is the sole entrypoint for building the workstation system (`laptop`). Neither `system/` nor `home/` are deployed independently.
|
||||||
2. **Domain Separation Invariant**: User packages belong in `home/` categorized by functional domain (`desktop.nix` for GUI/Wayland, `dev.nix` for developer tools, `shell.nix` for terminal productivity). System-level packages in `system/` are strictly reserved for root administration and core OS daemons.
|
2. **Context-Driven Package Ownership**:
|
||||||
3. **Decoupled Homelab Invariant**: Server infrastructure, Traefik edge proxying, and Docker container stacks belong in the `Core` repository and must never be merged back into this workstation configuration.
|
- Packages in `system/` are reserved for tools required by NixOS modules, system services, hardware integration, login/session infrastructure, or privileged administration.
|
||||||
|
- Packages in `home/` are dedicated to the user's interactive environment, developer toolchains, and desktop applications.
|
||||||
|
3. **Decoupled Homelab Invariant**: Server infrastructure, Traefik edge proxying, and Docker container stacks belong exclusively in the `Core` repository and must never be merged back into this workstation configuration.
|
||||||
4. **Hardware Configuration Invariant**: `system/hardware-configuration.nix` is generated by `nixos-generate-config`. Do not manually alter hardware disk UUIDs or module lists without explicit verification.
|
4. **Hardware Configuration Invariant**: `system/hardware-configuration.nix` is generated by `nixos-generate-config`. Do not manually alter hardware disk UUIDs or module lists without explicit verification.
|
||||||
5. **State Compatibility Invariant**: `system.stateVersion` and `home.stateVersion` (`26.05`) are compatibility declarations for stateful data and must not be bumped casually.
|
5. **State Compatibility Invariant**: `system.stateVersion` and `home.stateVersion` (`26.05`) are compatibility declarations for stateful data and must not be bumped casually.
|
||||||
@@ -6,7 +6,7 @@ This guide shows how to run isolated project environments using `nix-shell` or `
|
|||||||
|
|
||||||
## ⚡ DevShells and nix-shell
|
## ⚡ DevShells and nix-shell
|
||||||
|
|
||||||
Instead of installing packages globally in [apps.nix](file:///home/kiskaadee/Config/modules/user/apps.nix) for one-off projects, define them per-project.
|
Instead of installing packages globally in [home/dev.nix](file:///home/kiskaadee/Config/home/dev.nix) for one-off projects, define them per-project.
|
||||||
|
|
||||||
### 1. Classic `shell.nix` (Nix Channels)
|
### 1. Classic `shell.nix` (Nix Channels)
|
||||||
For standard Nix projects, place a `shell.nix` in your project root:
|
For standard Nix projects, place a `shell.nix` in your project root:
|
||||||
|
|||||||
@@ -48,37 +48,15 @@ sudo nixos-rebuild switch --flake .#laptop
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔒 Adding a New Secret (SOPS Workflow)
|
## 🔒 Secrets Management (Operator Workflow)
|
||||||
|
|
||||||
Sensitive credentials (like passwords, API keys, and environment variables) are managed using `sops-nix` and `age`.
|
The laptop acts as the administrative management station for homelab credentials using `sops` and `age`. Secrets are stored encrypted in Git under the [Core](file:///home/kiskaadee/Projects/active/homelab/Core) repository.
|
||||||
|
|
||||||
### Step 1: Edit the Secrets File
|
### Editing Homelab Secrets
|
||||||
Launch `sops` inside `nix-shell` to decrypt and edit your secrets file:
|
To edit or rotate homelab secrets from your laptop:
|
||||||
```bash
|
```bash
|
||||||
nix-shell -p sops --run "sops secrets.yaml"
|
sops ~/Projects/active/homelab/Core/nixos/secrets.yaml
|
||||||
```
|
```
|
||||||
Add your key-value pair under the YAML structure:
|
SOPS uses your personal age key at `~/.config/sops/age/keys.txt` to decrypt the file locally, and re-encrypts it for both the server and your workstation upon save.
|
||||||
```yaml
|
|
||||||
my_new_api_key: "secure_token_goes_here"
|
|
||||||
```
|
|
||||||
*When you save and close your editor, SOPS automatically encrypts the file before saving it back to disk.*
|
|
||||||
|
|
||||||
### Step 2: Declare the Secret in Nix
|
For detailed architecture diagrams and recovery steps, see the [Secrets Management Guide](docs/secrets-management.md).
|
||||||
To make the decrypted secret available to services or applications at runtime, register it in your Nix configuration:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
sops.secrets.my_new_api_key = {
|
|
||||||
# (Optional) Restrict file access to specific users/groups
|
|
||||||
owner = "kiskaadee";
|
|
||||||
mode = "0400";
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### Step 3: Reference the Decrypted Path
|
|
||||||
Once declared, `sops-nix` exposes the decrypted value under `/run/secrets/` at boot time. You can reference the file path dynamically in your Nix configuration using:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# This resolves to "/run/secrets/my_new_api_key"
|
|
||||||
config.sops.secrets.my_new_api_key.path
|
|
||||||
```
|
|
||||||
Avoid hardcoding raw paths; instead, pass this dynamic path directly to service configurations (e.g., via `EnvironmentFile` or command-line flags).
|
|
||||||
+58
-59
@@ -1,72 +1,71 @@
|
|||||||
# 🔒 Secrets Management via SOPS & age
|
# 🔒 Homelab & Workstation Secrets Management
|
||||||
|
|
||||||
This repository utilizes **`sops`** and **`age`** (with optional **`sops-nix`** integration) to manage sensitive information (passwords, tokens, API keys) declaratively and securely.
|
This document describes the GitOps secrets management workflow using **Mozilla SOPS** and **age**.
|
||||||
|
|
||||||
Secrets are stored encrypted directly in the Git repository, and decrypted dynamically into memory (`/run/secrets/`), ensuring no credentials leak into the public-readable Nix store.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🛠️ Bootstrapping Secrets on the Workstation
|
## 🏛️ Architectural Model: Author vs Consumer
|
||||||
|
|
||||||
To set up or re-initialize secrets encryption on the laptop:
|
Secrets management follows a strict separation between **authoring** (human operator on the workstation) and **runtime consumption** (headless server):
|
||||||
|
|
||||||
### Step 1: Generate a User age Key Pair
|
```text
|
||||||
To encrypt and decrypt files on your local machine, generate a native `age` key pair:
|
┌─────────────────────────────────────────────────────────┐
|
||||||
|
│ WORKSTATION (Author / Operator) │
|
||||||
|
│ - Key: ~/.config/sops/age/keys.txt (&laptop) │
|
||||||
|
│ - Tooling: sops, age, rbw (installed in home/dev.nix) │
|
||||||
|
│ - Action: Decrypt, edit, and re-encrypt secrets locally │
|
||||||
|
└───────────────────────────┬─────────────────────────────┘
|
||||||
|
│
|
||||||
|
Git Commit (Ciphertext in repo)
|
||||||
|
│
|
||||||
|
▼
|
||||||
|
┌─────────────────────────────────────────────────────────┐
|
||||||
|
│ SERVER (Consumer / Runtime) │
|
||||||
|
│ - Key: /etc/ssh/ssh_host_ed25519_key (&server) │
|
||||||
|
│ - Tooling: sops-nix systemd activation service (root) │
|
||||||
|
│ - Action: Unattended decryption into RAM (/run/secrets) │
|
||||||
|
└─────────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
* **Why editing secrets directly on the remote server fails**: The server does not have the operator's age key. Its host SSH key is owned by `root:root` with `0600` permissions and is only read by `sops-nix` during systemd activation at boot.
|
||||||
|
* **Why the workstation is the author**: The operator's private age key resides in `~/.config/sops/age/keys.txt` on the laptop. This allows secure local editing without exposing administrative keys on production nodes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛠️ Managing Secrets for Core
|
||||||
|
|
||||||
|
Production homelab secrets are maintained in the [Core](file:///home/kiskaadee/Projects/active/homelab/Core) repository at `Core/nixos/secrets.yaml`.
|
||||||
|
|
||||||
|
### 1. Edit Secrets Locally
|
||||||
|
From your laptop, open the encrypted secrets file:
|
||||||
|
```bash
|
||||||
|
sops ~/Projects/active/homelab/Core/nixos/secrets.yaml
|
||||||
|
```
|
||||||
|
SOPS reads your local `~/.config/sops/age/keys.txt`, decrypts the file in `$EDITOR`, and automatically re-encrypts the ciphertext using the public recipient keys configured in `Core/.sops.yaml`:
|
||||||
|
- `*server` (for server boot decryption)
|
||||||
|
- `*laptop` (for operator editing)
|
||||||
|
|
||||||
|
### 2. Commit and Deploy
|
||||||
|
Commit the newly encrypted ciphertext and push to your git remote:
|
||||||
|
```bash
|
||||||
|
cd ~/Projects/active/homelab/Core
|
||||||
|
git add nixos/secrets.yaml
|
||||||
|
git commit -m "chore(secrets): rotate service credentials"
|
||||||
|
git push
|
||||||
|
```
|
||||||
|
On the server, pulling and rebuilding will activate the updated secrets into `/run/secrets/`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔑 Workstation Key Bootstrapping
|
||||||
|
|
||||||
|
If setting up a new workstation, generate your operator `age` key pair:
|
||||||
```bash
|
```bash
|
||||||
# Create the standard config directory
|
|
||||||
mkdir -p ~/.config/sops/age
|
mkdir -p ~/.config/sops/age
|
||||||
|
age-keygen -o ~/.config/sops/age/keys.txt
|
||||||
# Generate the age key pair
|
|
||||||
nix-shell -p age --run "age-keygen -o ~/.config/sops/age/keys.txt"
|
|
||||||
|
|
||||||
# Lock down key permissions
|
|
||||||
chmod 600 ~/.config/sops/age/keys.txt
|
chmod 600 ~/.config/sops/age/keys.txt
|
||||||
```
|
```
|
||||||
To print your public key for configuration, run:
|
To print the public key for addition to `Core/.sops.yaml`:
|
||||||
```bash
|
```bash
|
||||||
grep "public key" ~/.config/sops/age/keys.txt
|
grep "public key" ~/.config/sops/age/keys.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Convert the Host SSH Public Key to age
|
|
||||||
To allow systemd to decrypt secrets automatically at boot time, obtain the host's SSH public key converted to `age` format:
|
|
||||||
```bash
|
|
||||||
nix run nixpkgs#ssh-to-age -- -i /etc/ssh/ssh_host_ed25519_key.pub
|
|
||||||
```
|
|
||||||
*Note: The private key counterpart `/etc/ssh/ssh_host_ed25519_key` is automatically read by `sops-nix` at boot with root privileges.*
|
|
||||||
|
|
||||||
### Step 3: Configure Public Keys in `.sops.yaml`
|
|
||||||
Add both the user `age` public key and the host `age` public key to the [.sops.yaml](file:///home/kiskaadee/Config/.sops.yaml) configuration file at the root of the repository:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
keys:
|
|
||||||
- &laptop age1...your_laptop_age_key...
|
|
||||||
|
|
||||||
creation_rules:
|
|
||||||
- path_regex: secrets\.yaml$
|
|
||||||
key_groups:
|
|
||||||
- pgp: []
|
|
||||||
age:
|
|
||||||
- *laptop
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ✏️ Editing and Managing Secrets
|
|
||||||
|
|
||||||
Because `sops` automatically reads from your local `~/.config/sops/age/keys.txt` keyfile, you can manage secrets using simple commands:
|
|
||||||
|
|
||||||
### Create/Edit an Encrypted File
|
|
||||||
```bash
|
|
||||||
nix-shell -p sops --run "sops secrets.yaml"
|
|
||||||
```
|
|
||||||
This decrypts the file, opens it in your editor defined by `$EDITOR`, and automatically re-encrypts the values when you save and exit.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔄 Runtime Decryption
|
|
||||||
|
|
||||||
At boot time, `sops-nix` performs the following steps:
|
|
||||||
1. Systemd runs the `sops-install-secrets` activation script.
|
|
||||||
2. The script reads `/etc/ssh/ssh_host_ed25519_key` to decrypt the encrypted secrets file.
|
|
||||||
3. The values are exposed under `/run/secrets/` as individual files (or templates) with strict user/group ownership.
|
|
||||||
4. Services read these paths at startup, keeping secrets secure and decoupled from the world-readable `/nix/store`.
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# 🎛️ Tmux Environment & Cheat Sheet
|
# 🎛️ Tmux Environment & Cheat Sheet
|
||||||
|
|
||||||
This repository configures **Tmux** declaratively via Home Manager in [terminal.nix](file:///home/kiskaadee/Config/modules/user/terminal.nix#L30). The configuration is optimized for speed, Vim keybindings, and seamless split-pane navigation.
|
This repository configures **Tmux** declaratively via Home Manager in [home/shell.nix](file:///home/kiskaadee/Config/home/shell.nix). The configuration is optimized for speed, Vim keybindings, and seamless split-pane navigation.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Generated
-21
@@ -271,30 +271,9 @@
|
|||||||
"dms": "dms",
|
"dms": "dms",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"sops-nix": "sops-nix",
|
|
||||||
"zen-browser": "zen-browser"
|
"zen-browser": "zen-browser"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sops-nix": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1788914643,
|
|
||||||
"narHash": "sha256-4GuMPW90JSxXWDPUB9M+1m7fYbe3H0apOd86/zBQ2Kw=",
|
|
||||||
"owner": "Mic92",
|
|
||||||
"repo": "sops-nix",
|
|
||||||
"rev": "13616fff713a9f94055c66f15687ebdc17a335df",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "Mic92",
|
|
||||||
"repo": "sops-nix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1681028828,
|
||||||
|
|||||||
@@ -48,12 +48,6 @@
|
|||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Cryptographic Secrets management
|
|
||||||
sops-nix = {
|
|
||||||
url = "github:Mic92/sops-nix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Antigravity CLI - coding companion and local AI agent helper
|
# Antigravity CLI - coding companion and local AI agent helper
|
||||||
antigravity = {
|
antigravity = {
|
||||||
url = "github:jacopone/antigravity-nix";
|
url = "github:jacopone/antigravity-nix";
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
home.sessionPath = [
|
home.sessionPath = [
|
||||||
"$HOME/.cargo/bin"
|
"$HOME/.cargo/bin"
|
||||||
"$HOME/.local/bin"
|
"$HOME/.local/bin"
|
||||||
"$HOME/Core/scripts"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# Compatibility state version
|
# Compatibility state version
|
||||||
|
|||||||
+1
-10
@@ -65,16 +65,7 @@ in
|
|||||||
home.file.".config/niri/config.kdl".source = ./config/niri/config.kdl;
|
home.file.".config/niri/config.kdl".source = ./config/niri/config.kdl;
|
||||||
home.file.".config/niri/custom.kdl".source = ./config/niri/custom.kdl;
|
home.file.".config/niri/custom.kdl".source = ./config/niri/custom.kdl;
|
||||||
|
|
||||||
# Systemd user session targets for window managers
|
# Systemd user session target for Niri window manager
|
||||||
systemd.user.targets.hyprland-session = {
|
|
||||||
Unit = {
|
|
||||||
Description = "Hyprland graphical session";
|
|
||||||
Documentation = [ "man:systemd.special(7)" ];
|
|
||||||
BindsTo = [ "graphical-session.target" ];
|
|
||||||
Wants = [ "graphical-session-pre.target" ];
|
|
||||||
After = [ "graphical-session-pre.target" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.user.targets.niri-session = {
|
systemd.user.targets.niri-session = {
|
||||||
Unit = {
|
Unit = {
|
||||||
|
|||||||
+6
-15
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# 📹 Wayland Screen Recording Utility (Niri & Hyprland compatible)
|
# 📹 Wayland Screen Recording Utility (Niri-native)
|
||||||
# Leverages 'wf-recorder' for GPU-accelerated video recording and pipewire audio routing.
|
# Leverages 'wf-recorder' for GPU-accelerated video recording and PipeWire audio routing.
|
||||||
# Supports capturing specific regions, active windows, focused monitors, or full displays.
|
# Supports capturing specific regions, active windows, focused monitors, or full displays.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
@@ -69,14 +69,8 @@ case "$MODE" in
|
|||||||
TYPE_DESC="Area Recording"
|
TYPE_DESC="Area Recording"
|
||||||
;;
|
;;
|
||||||
window)
|
window)
|
||||||
# Try querying Hyprland active window coordinates if on Hyprland
|
# Interactive window selection via slurp
|
||||||
if [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ] && command -v hyprctl >/dev/null 2>&1; then
|
GEOM=$(slurp)
|
||||||
GEOM=$(hyprctl activewindow -j 2>/dev/null | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
|
|
||||||
fi
|
|
||||||
# Fallback to interactive window / region selection via slurp
|
|
||||||
if [ -z "$GEOM" ] || [ "$GEOM" = "null,null nullxnull" ]; then
|
|
||||||
GEOM=$(slurp)
|
|
||||||
fi
|
|
||||||
if [ -z "$GEOM" ]; then
|
if [ -z "$GEOM" ]; then
|
||||||
notify-send -t 2000 "Screen Recorder" "Recording cancelled"
|
notify-send -t 2000 "Screen Recorder" "Recording cancelled"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -84,13 +78,10 @@ case "$MODE" in
|
|||||||
TYPE_DESC="Window Recording"
|
TYPE_DESC="Window Recording"
|
||||||
;;
|
;;
|
||||||
output)
|
output)
|
||||||
# Query focused monitor on Niri or Hyprland
|
# Query focused monitor on Niri
|
||||||
if [ "$XDG_CURRENT_DESKTOP" = "niri" ] || command -v niri >/dev/null 2>&1; then
|
if command -v niri >/dev/null 2>&1; then
|
||||||
OUTPUT_TARGET=$(niri msg -j focused-output 2>/dev/null | jq -r '.name // empty')
|
OUTPUT_TARGET=$(niri msg -j focused-output 2>/dev/null | jq -r '.name // empty')
|
||||||
fi
|
fi
|
||||||
if [ -z "$OUTPUT_TARGET" ] && command -v hyprctl >/dev/null 2>&1; then
|
|
||||||
OUTPUT_TARGET=$(hyprctl monitors -j 2>/dev/null | jq -r '.[] | select(.focused == true) | .name // empty')
|
|
||||||
fi
|
|
||||||
TYPE_DESC="Monitor Recording"
|
TYPE_DESC="Monitor Recording"
|
||||||
;;
|
;;
|
||||||
screen)
|
screen)
|
||||||
|
|||||||
+1
-1
@@ -227,7 +227,7 @@
|
|||||||
# Ensure Home Manager session variables and user PATH are available in non-login / SSH shells
|
# Ensure Home Manager session variables and user PATH are available in non-login / SSH shells
|
||||||
[[ -f /etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh ]] && . /etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh
|
[[ -f /etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh ]] && . /etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh
|
||||||
[[ -f ~/.profile ]] && . ~/.profile
|
[[ -f ~/.profile ]] && . ~/.profile
|
||||||
export PATH="$HOME/Core/scripts:$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
|
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
|
||||||
|
|
||||||
${builtins.readFile ./shell/wayland.sh} # Wayland clipboard helper (wlc)
|
${builtins.readFile ./shell/wayland.sh} # Wayland clipboard helper (wlc)
|
||||||
${builtins.readFile ./shell/git.sh} # Git workflow automations (gacp, gitignore)
|
${builtins.readFile ./shell/git.sh} # Git workflow automations (gacp, gitignore)
|
||||||
|
|||||||
+5
-3
@@ -3,17 +3,19 @@
|
|||||||
|
|
||||||
# 1. pdf_dc: Decrypts a password-protected PDF document.
|
# 1. pdf_dc: Decrypts a password-protected PDF document.
|
||||||
# Uses 'qpdf' under the hood. Automatically searches for a default password
|
# Uses 'qpdf' under the hood. Automatically searches for a default password
|
||||||
# decrypted securely by sops-nix in `/run/secrets/pdf_decrypt_password`
|
# in `$HOME/.config/pdf_decrypt_password` (or `/run/secrets/pdf_decrypt_password`)
|
||||||
# if no password argument is supplied.
|
# if no password argument is supplied.
|
||||||
pdf_dc() {
|
pdf_dc() {
|
||||||
local secret_file="/run/secrets/pdf_decrypt_password"
|
local secret_file="${PDF_PASSWORD_FILE:-$HOME/.config/pdf_decrypt_password}"
|
||||||
local input_file="$1"
|
local input_file="$1"
|
||||||
local password="$2"
|
local password="$2"
|
||||||
|
|
||||||
# Attempt to auto-load password from sops secret if none was provided on the CLI
|
# Attempt to auto-load password from config file if none was provided on the CLI
|
||||||
if [[ -z "$password" ]]; then
|
if [[ -z "$password" ]]; then
|
||||||
if [[ -f "$secret_file" ]]; then
|
if [[ -f "$secret_file" ]]; then
|
||||||
password=$(cat "$secret_file")
|
password=$(cat "$secret_file")
|
||||||
|
elif [[ -f "/run/secrets/pdf_decrypt_password" ]]; then
|
||||||
|
password=$(cat "/run/secrets/pdf_decrypt_password")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,7 @@
|
|||||||
package = inputs.dms.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
package = inputs.dms.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||||
systemd.enable = true;
|
systemd.enable = true;
|
||||||
systemd.restartIfChanged = true;
|
systemd.restartIfChanged = true;
|
||||||
enableSystemMonitoring = true;
|
|
||||||
enableDynamicTheming = true;
|
enableDynamicTheming = true;
|
||||||
enableClipboardPaste = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# DMS Greeter (dank-greeter + greetd)
|
# DMS Greeter (dank-greeter + greetd)
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
# 🔋 Laptop Hardware, Power & Peripheral Management
|
# 🔋 Machine Services, Hardware & Peripherals
|
||||||
# Manages audio (PipeWire), power daemons, Bluetooth, printing, scanning, and virtualization.
|
# Manages audio (PipeWire), power daemons, Bluetooth, printing, scanning, and container virtualization.
|
||||||
|
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user