- Remove headless server configuration, homelab services, and legacy host directories (`hosts/server/`, `hosts/laptop/`). - Consolidate privileged system files into a clean `system/` directory (`core.nix`, `hardware.nix`, `desktop.nix`). - Migrate Home Manager configuration into functional domain modules under `home/` (`desktop.nix`, `dev.nix`, `shell.nix`). - Update `flake.nix` to expose a single `laptop` target. - Overhaul documentation (`architecture.md`, `AGENTS.md`, `README.md`) to reflect the standalone architecture and homelab decoupling. This refactor eliminates the multi-host maintenance tax by decoupling server infrastructure into the Core repository and simplifying workstation management around domain-driven cohesion.
85 lines
2.9 KiB
Markdown
85 lines
2.9 KiB
Markdown
# 📦 Package & Secrets Workflow Guide
|
|
|
|
This guide covers the day-to-day workflow for managing user-space packages and sensitive information (secrets) within this NixOS configuration.
|
|
|
|
---
|
|
|
|
## 🚀 Adding a New Package
|
|
|
|
User-space applications are managed declaratively using Home Manager in domain modules under `home/`:
|
|
- Developer tools, SDKs, LSPs, compilers: [home/dev.nix](file:///home/kiskaadee/Config/home/dev.nix)
|
|
- Desktop applications, GUI tools, Wayland utilities: [home/desktop.nix](file:///home/kiskaadee/Config/home/desktop.nix)
|
|
- Shell utilities, terminal enhancements: [home/shell.nix](file:///home/kiskaadee/Config/home/shell.nix)
|
|
|
|
### Step 1: Find the Package Name
|
|
Before adding a package, look up its exact attribute name:
|
|
* **Search Engine:** Go to the official [NixOS Package Search](https://search.nixos.org/packages).
|
|
* **CLI Search:**
|
|
```bash
|
|
nix-env -qaP '<package-name>'
|
|
# Or using modern flake-native search:
|
|
nix search nixpkgs <query>
|
|
```
|
|
|
|
### Step 2: Update the Target Domain Module
|
|
Open the appropriate module (e.g., [home/dev.nix](file:///home/kiskaadee/Config/home/dev.nix)) and append the package name into `home.packages`:
|
|
|
|
```nix
|
|
home.packages = with pkgs; [
|
|
# ... existing packages
|
|
|
|
# Text Editors / Development
|
|
neovim
|
|
|
|
# New Package Example
|
|
ripgrep # Modern grep alternative for fast directory search
|
|
];
|
|
```
|
|
|
|
### Step 3: Test and Switch
|
|
Verify the package builds correctly before switching system-wide:
|
|
```bash
|
|
# Test build without applying
|
|
nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link
|
|
|
|
# Apply configuration
|
|
sudo nixos-rebuild switch --flake .#laptop
|
|
```
|
|
|
|
---
|
|
|
|
## 🔒 Adding a New Secret (SOPS Workflow)
|
|
|
|
Sensitive credentials (like passwords, API keys, and environment variables) are managed using `sops-nix` and `age`.
|
|
|
|
### Step 1: Edit the Secrets File
|
|
Launch `sops` inside `nix-shell` to decrypt and edit your secrets file:
|
|
```bash
|
|
nix-shell -p sops --run "sops secrets.yaml"
|
|
```
|
|
Add your key-value pair under the YAML structure:
|
|
```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
|
|
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).
|