From 3597e035d3aaf49d430248b36975c82ebf28c1e6 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Sat, 12 Sep 2026 16:22:58 -0500 Subject: [PATCH] refactor: transition repository to a standalone declarative workstation - 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. --- AGENTS.md | 49 ++--- README.md | 146 +++++-------- architecture.md | 177 ++++++--------- docs/antigravity.md | 4 +- docs/dynu-ip-monitor.md | 92 -------- docs/package-and-secrets.md | 20 +- docs/secrets-management.md | 28 +-- docs/system-maintenance.md | 5 +- flake.nix | 57 ++--- home.nix | 30 --- .../config/alacritty/alacritty.toml | 0 .../config/fastfetch/config.jsonc | 0 {modules/user => home}/config/niri/config.kdl | 0 {modules/user => home}/config/niri/custom.kdl | 0 .../user => home}/config/nvim/catppuccin.lua | 0 {modules/user => home}/config/nvim/dap.lua | 0 {modules/user => home}/config/nvim/init.lua | 0 {modules/user => home}/config/nvim/lsp.lua | 0 {modules/user => home}/config/starship.toml | 0 {modules/user => home}/config/tmux.conf | 0 .../user => home}/config/zed/settings.json | 0 .../config/zed/themes/dank-zed-theme.json | 0 home/default.nix | 29 +++ .../user/graphical.nix => home/desktop.nix | 53 ++--- home/dev.nix | 132 ++++++++++++ .../user => home}/scripts/bundle_project.py | 0 {modules/user => home}/scripts/record.sh | 0 modules/user/base.nix => home/shell.nix | 52 ++--- {modules/user => home}/shell/git.sh | 0 {modules/user => home}/shell/interactive.sh | 0 {modules/user => home}/shell/jump.sh | 0 {modules/user => home}/shell/pdf.sh | 0 {modules/user => home}/shell/quicklinks.sh | 0 {modules/user => home}/shell/todo.sh | 0 {modules/user => home}/shell/wayland.sh | 0 hosts/laptop/configuration.nix | 78 ------- hosts/laptop/home.nix | 11 - hosts/server/configuration.nix | 90 -------- hosts/server/ddclient.conf | 12 -- hosts/server/dynu.nix | 92 -------- hosts/server/hardware-configuration.nix | 41 ---- hosts/server/home.nix | 14 -- hosts/server/homeserver.nix | 122 ----------- hosts/server/monitor.py | 204 ------------------ hosts/server/secrets.yaml | 59 ----- hosts/server/traefik-deployments.nix | 98 --------- modules/system/base.nix | 103 --------- modules/system/graphical.nix | 43 ---- modules/user/apps.nix | 68 ------ modules/user/neovim.nix | 59 ----- modules/user/terminal.nix | 17 -- system/core.nix | 67 ++++++ system/default.nix | 13 ++ system/desktop.nix | 74 +++++++ .../hardware-configuration.nix | 0 system/hardware.nix | 53 +++++ 56 files changed, 606 insertions(+), 1586 deletions(-) delete mode 100644 docs/dynu-ip-monitor.md delete mode 100644 home.nix rename {modules/user => home}/config/alacritty/alacritty.toml (100%) rename {modules/user => home}/config/fastfetch/config.jsonc (100%) rename {modules/user => home}/config/niri/config.kdl (100%) rename {modules/user => home}/config/niri/custom.kdl (100%) rename {modules/user => home}/config/nvim/catppuccin.lua (100%) rename {modules/user => home}/config/nvim/dap.lua (100%) rename {modules/user => home}/config/nvim/init.lua (100%) rename {modules/user => home}/config/nvim/lsp.lua (100%) rename {modules/user => home}/config/starship.toml (100%) rename {modules/user => home}/config/tmux.conf (100%) rename {modules/user => home}/config/zed/settings.json (100%) rename {modules/user => home}/config/zed/themes/dank-zed-theme.json (100%) create mode 100644 home/default.nix rename modules/user/graphical.nix => home/desktop.nix (79%) create mode 100644 home/dev.nix rename {modules/user => home}/scripts/bundle_project.py (100%) rename {modules/user => home}/scripts/record.sh (100%) rename modules/user/base.nix => home/shell.nix (80%) rename {modules/user => home}/shell/git.sh (100%) rename {modules/user => home}/shell/interactive.sh (100%) rename {modules/user => home}/shell/jump.sh (100%) rename {modules/user => home}/shell/pdf.sh (100%) rename {modules/user => home}/shell/quicklinks.sh (100%) rename {modules/user => home}/shell/todo.sh (100%) rename {modules/user => home}/shell/wayland.sh (100%) delete mode 100644 hosts/laptop/configuration.nix delete mode 100644 hosts/laptop/home.nix delete mode 100644 hosts/server/configuration.nix delete mode 100644 hosts/server/ddclient.conf delete mode 100644 hosts/server/dynu.nix delete mode 100644 hosts/server/hardware-configuration.nix delete mode 100644 hosts/server/home.nix delete mode 100644 hosts/server/homeserver.nix delete mode 100644 hosts/server/monitor.py delete mode 100644 hosts/server/secrets.yaml delete mode 100644 hosts/server/traefik-deployments.nix delete mode 100644 modules/system/base.nix delete mode 100644 modules/system/graphical.nix delete mode 100644 modules/user/apps.nix delete mode 100644 modules/user/neovim.nix delete mode 100644 modules/user/terminal.nix create mode 100644 system/core.nix create mode 100644 system/default.nix create mode 100644 system/desktop.nix rename {hosts/laptop => system}/hardware-configuration.nix (100%) create mode 100644 system/hardware.nix diff --git a/AGENTS.md b/AGENTS.md index 0fa81f3..0e205fd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ ## Mission & Purpose -This repository manages the declarative NixOS and Home Manager configurations for `server` and `laptop` hosts. +This repository manages the declarative NixOS and Home Manager configuration for the `laptop` mobile workstation host. AI agents working in this repository must maintain architectural integrity, avoid configuration sprawl, respect pre-existing work, and adhere strictly to the invariants defined in `architecture.md`. @@ -37,10 +37,7 @@ Repository # Validate flake metadata, inputs, and derivations nix flake check -# Build server host dryly (evaluates configuration without switching) -nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link - -# Build laptop host dryly +# Build laptop host dryly (evaluates configuration without switching) nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link ``` @@ -72,16 +69,17 @@ nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link - **Capture Out-of-Scope Ideas in Second Brain**: When the user mentions a new idea, feature request, or architectural concept unrelated to the immediate active task, record a note in `/home/kiskaadee/Brain/` (or suggest logging it) so valuable insights are preserved without disrupting current execution scope. ### 4. Package Placement Rules -- **Shared User Applications**: Place in `modules/user/` (with `apps.nix` as the default central application module). -- **Host-Specific User Tools**: Place in `hosts//home.nix` (e.g., Niri utilities on laptop, diagnostic tools on server). -- **System-Wide Packages**: Place in `modules/system/base.nix` *only* if required for root maintenance, core networking, or systemd daemons. +- **Developer Tools, Compilers, LSPs**: Place in `home/dev.nix`. +- **Graphical Applications & Desktop Tools**: Place in `home/desktop.nix`. +- **Terminal Utilities & Shell Integration**: Place in `home/shell.nix`. +- **System-Wide Daemons & Hardware Support**: Place in `system/core.nix` or `system/hardware.nix` *only* if required for root maintenance, core networking, or systemd daemons. -### 5. Host Isolation & Homelab Infrastructure -- Keep machine-specific homelab infrastructure (`homeserver.nix`, `traefik-deployments.nix`, `dynu.nix`) under `hosts/server/`. Never import them into `hosts/laptop/`. -- Protect the headless `server` profile. Any changes to shared base modules must preserve the headless server runtime. +### 5. Homelab Infrastructure Decoupling +- Production homelab services, Traefik edge proxying, Docker container deployments, and DDNS automation live exclusively in the `Core` repository (`~/Projects/active/homelab/Core`). +- Never import or re-introduce server daemon definitions into this workstation repository. ### 6. Hardware Configurations -- `hardware-configuration.nix` files are generated by `nixos-generate-config`. Do not manually restructure, clean up, or refactor them. Hardware additions (e.g., kernel parameters, disk mounts) require explicit justification. +- `system/hardware-configuration.nix` is generated by `nixos-generate-config`. Do not manually restructure, clean up, or refactor it. Hardware additions (e.g., kernel parameters, disk mounts) require explicit justification. ### 7. Secrets & Key Safety (SOPS) - **Never write or commit plaintext secrets** into `.nix`, `.yaml`, or temporary files. @@ -101,9 +99,9 @@ nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link | Tier | Category | Examples | Required Action & Workflow | | :--- | :--- | :--- | :--- | -| **LOW** | User Configuration | User packages in `apps.nix`, shell aliases, Neovim lua config, Tmux settings, docs. | **Autonomous**: Agent plans, edits, and validates via `nix flake check` + affected host build. | -| **MEDIUM** | Shared System & Workstation | `modules/system/*`, greetd/display manager, firewall rules, user groups, new flake inputs. | **Autonomous**: Agent plans, edits, and validates via `nix flake check` + builds **both** `server` and `laptop`. | -| **HIGH** | Core & Infrastructure | Bootloader, filesystems, SOPS keys/secrets setup, server deployments, Traefik, Docker networking. | **Stop & Wait**: Agent must present the plan and **wait for user approval before editing**. | +| **LOW** | User Configuration | User packages in `home/dev.nix`, shell aliases in `home/shell.nix`, Neovim lua config, docs. | **Autonomous**: Agent plans, edits, and validates via `nix flake check` + laptop build. | +| **MEDIUM** | System & Desktop Stack | `system/core.nix`, `system/desktop.nix`, greetd/DMS, firewall rules, user groups, new flake inputs. | **Autonomous**: Agent plans, edits, and validates via `nix flake check` + laptop build. | +| **HIGH** | Core Hardware & Boot | Bootloader, filesystem mounts, SOPS keys setup, kernel module changes. | **Stop & Wait**: Agent must present the plan and **wait for user approval before editing**. | | **PROHIBITED** | Live System Mutators | `nixos-rebuild switch`, destructive disk ops, editing `/etc` outside Nix, rotating age keys, plaintext secrets. | **Blocked**: Cannot execute unless explicitly commanded by the user in the current prompt. | --- @@ -117,7 +115,7 @@ REQUEST │ ▼ 1. UNDERSTAND - ├── Identify affected host(s) and trace consumer import chain + ├── Identify affected components in system/ or home/ ├── Check `git status` to identify pre-existing uncommitted work └── Read architectural boundaries in architecture.md │ @@ -135,7 +133,7 @@ REQUEST ▼ 4. VALIDATE ├── Run `nix flake check` - └── Build all downstream affected hosts (`--no-link`) + └── Build laptop host (`--no-link`): `nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` │ ▼ 5. REVIEW @@ -149,18 +147,13 @@ REQUEST --- -## Host-Aware Validation Matrix +## Validation Matrix -> [!NOTE] -> The matrix below is a default heuristic. When the import graph indicates additional downstream consumers, validate those configurations as well. - -| Modified Path | Affected Consumers | Required Build Validation | +| Modified Path | Affected Consumer | Required Build Validation | | :--- | :--- | :--- | -| `modules/system/*` | `server`, `laptop` | `nix flake check`
`nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link`
`nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` | -| `modules/user/*` or `home.nix` | `server`, `laptop` | `nix flake check`
`nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link`
`nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` | -| `hosts/server/*` | `server` only | `nix flake check`
`nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link` | -| `hosts/laptop/*` | `laptop` only | `nix flake check`
`nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` | -| `flake.nix` / `flake.lock` | `server`, `laptop` | `nix flake check` + build both hosts | +| `system/*` | `laptop` | `nix flake check`
`nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` | +| `home/*` | `laptop` | `nix flake check`
`nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` | +| `flake.nix` / `flake.lock` | `laptop` | `nix flake check`
`nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` | --- @@ -170,7 +163,7 @@ Maintain clear ownership of documentation: - **`README.md`**: High-level repository overview and quick start. - **`architecture.md`**: Structural topology, layer boundaries, and architectural invariants. - **`AGENTS.md`**: Agent constitution, change policies, risk matrix, and validation rules. -- **`docs/*.md`**: Step-by-step procedural guides for humans (maintenance, secrets, Antigravity, Dynu). +- **`docs/*.md`**: Step-by-step procedural guides for humans (maintenance, secrets, Antigravity). *Rule: Do not duplicate architectural descriptions into procedural docs or README.* diff --git a/README.md b/README.md index 5937b4b..04c846a 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,60 @@ -# ❄️ Declarative NixOS Workstation & Server Configuration +# ❄️ Declarative NixOS Laptop Workstation Configuration -This repository houses a purely declarative, reproducible NixOS configuration using Nix Flakes and Home Manager. It serves as the single source of truth for provisioning and managing a headless homelab server and high-performance Wayland-native workstation environment on laptop. +This repository houses a purely declarative, reproducible NixOS configuration using Nix Flakes and Home Manager. It serves as the single source of truth for provisioning and managing a high-performance, Wayland-native mobile workstation environment on laptop powered by the Niri scrollable window manager and DankMaterialShell. + +Homelab infrastructure and server services are maintained independently in the [Core](file:///home/kiskaadee/Projects/active/homelab/Core) repository. --- ## 🏗️ Repository Architecture -This configuration maintains a strict separation between global system defaults, shared user configuration modules, and host-specific profiles to avoid redundancy. +The repository enforces a clear separation between privileged system declarations (`system/`) and unprivileged user-space dotfiles and toolchains (`home/`), organized by functional domains. ```mermaid graph TD - A["flake.nix"] --> B{"Host Targets"} + A["flake.nix"] --> B["nixosConfigurations.laptop"] - subgraph Hosts ["Host Profiles (hosts/)"] - S["server
(Headless Homelab)"] - L["laptop
(Niri Workstation)"] + subgraph System ["Privileged System Layer (system/)"] + S_CORE["core.nix
(Base OS, Users, Boot, Nix-LD)"] + S_HW["hardware.nix
(Power, PipeWire, Bluetooth, Printing)"] + S_DESK["desktop.nix
(Niri, DMS Daemon, Greeter, Fonts)"] end - B -->|"server"| S - B -->|"laptop"| L - - subgraph Shared ["Shared Modules (modules/)"] - SYS["modules/system/
(Base OS & System Daemons)"] - USER["home.nix + modules/user/
(User Environment & Apps)"] + subgraph User ["Unprivileged User Layer (home/)"] + U_DESK["desktop.nix
(GUI Apps, Wayland Tools, Alacritty, Zed)"] + U_DEV["dev.nix
(Neovim, Compilers, LSPs, Antigravity)"] + U_SH["shell.nix
(Bash, Git, Delta, Tmux, Starship)"] end - S --> SYS - L --> SYS - - S --> USER - L --> USER + B --> System + B --> User ``` ### Directory Structure -* [flake.nix](flake.nix) — Main entry point defining dependencies (inputs) and system host targets (`server`, `laptop`). -* [home.nix](home.nix) — Global Home Manager declaration defining the user context (`kiskaadee`). -* [hosts/](hosts/) — Specific hardware configuration files and profiles. - * [hosts/server/](hosts/server/) — Dedicated headless homelab server configuration: - * [configuration.nix](hosts/server/configuration.nix) — Headless server NixOS config (power-tuned, no GUI, no greeter). - * [home.nix](hosts/server/home.nix) — Pure CLI user environment with server diagnostic tools (`htop`, `iotop`, `ncdu`). - * [dynu.nix](hosts/server/dynu.nix) — Service settings triggering Dynu DDNS. - * [homeserver.nix](hosts/server/homeserver.nix) — Core services declarative systemd service. - * [traefik-deployments.nix](hosts/server/traefik-deployments.nix) — Edge proxy secrets and microservice templates. - * [monitor.py](hosts/server/monitor.py) — Python script checking for public WAN IP rotations. - * [secrets.yaml](hosts/server/secrets.yaml) — Encrypted server credentials. - * [hosts/laptop/](hosts/laptop/) — Configuration for the mobile workstation: - * [configuration.nix](hosts/laptop/configuration.nix) — Main laptop NixOS config. - * [home.nix](hosts/laptop/home.nix) — Niri-based workspace environment settings. -* [modules/](modules/) — Reusable, modular system and user configuration files: - * [modules/system/](modules/system/) — Global hardware settings, Docker, greetd, and audio: - * [base.nix](modules/system/base.nix) — System-wide terminal base. - * [graphical.nix](modules/system/graphical.nix) — System display and desktop styling modules. - * [modules/user/](modules/user/) — User environment settings: - * [base.nix](modules/user/base.nix) — Core CLI utilities, alias definitions, and fastfetch. - * [apps.nix](modules/user/apps.nix) — Packages including Zen Browser, Neovim, and Cloud SDKs. - * [terminal.nix](modules/user/terminal.nix) — Alacritty terminal emulator, Tmux configurations, and Starship. - * [shell/](modules/user/shell/) — Modular, domain-specific shell scripts natively compiled into the shell configuration: - * [git.sh](modules/user/shell/git.sh) — Automation helpers for Git staging, committing, and repositories. - * [jump.sh](modules/user/shell/jump.sh) — Interactive navigation helper scripts powered by `fzf` and `yazi`. - * [pdf.sh](modules/user/shell/pdf.sh) — Quick decryption of password-protected PDF files. - * [quicklinks.sh](modules/user/shell/quicklinks.sh) — Quick menu launcher for saved bookmarks and workflows. - * [todo.sh](modules/user/shell/todo.sh) — Productivity shortcuts and syntax highlighter for `todo.txt` and `tuxedo`. - * [wayland.sh](modules/user/shell/wayland.sh) — Utility to automatically pipe program stdout/stderr to the Wayland clipboard. +* [flake.nix](flake.nix) — Main entry point defining dependencies (inputs) and system host target (`laptop`). +* [system/](system/) — Privileged NixOS system-level configuration modules: + * [default.nix](system/default.nix) — System composition entrypoint. + * [hardware-configuration.nix](system/hardware-configuration.nix) — Generated hardware scan (disks, CPU microcode, kernel modules). + * [core.nix](system/core.nix) — Base operating system, bootloader, networking, user account, and `nix-ld`. + * [hardware.nix](system/hardware.nix) — Power management (`power-profiles-daemon`, `upower`), audio (`pipewire`), printing/scanning, and Docker. + * [desktop.nix](system/desktop.nix) — Niri compositor enablement, DankMaterialShell daemon, greetd login, and fonts. +* [home/](home/) — Home Manager user-space configuration modules (`kiskaadee`): + * [default.nix](home/default.nix) — User environment entrypoint, state version, and session search paths. + * [desktop.nix](home/desktop.nix) — Graphical applications (Zen Browser, Zed, media), Wayland capture tools, Alacritty, and Niri/Zed dotfiles. + * [dev.nix](home/dev.nix) — Neovim editor setup, developer toolchains (Rust, Python, Node, LSPs), Antigravity CLI, and dev utilities. + * [shell.nix](home/shell.nix) — Interactive Bash shell, Git/Delta configuration, SSH client profiles, Tmux, Starship, and Fastfetch. + * [config/](home/config/) — Static dotfile source trees (Alacritty, Fastfetch, Niri, Neovim, Zed, Starship, Tmux). + * [scripts/](home/scripts/) — Compiled standalone user scripts (`bundle_project.py`, `record.sh`). + * [shell/](home/shell/) — Modular Bash helper scripts sourced into `.bashrc`. +* [docs/](docs/) — Maintenance runbooks and operational workflows. --- ## 🛠️ Specialized Shell & Script Automation -### 1. Smart Dynamic DNS Monitor -* **Feature:** Smart IP monitor preventing redundant Dynu API calls by verifying WAN IP rotations locally before invoking `ddclient`. -* **Documentation:** Detailed flow and operational architecture are documented in the [Smart DDNS Updater Guide](docs/dynu-ip-monitor.md). - -### 2. GPU-Accelerated Video Recording (`record`) -* **Script Location:** [modules/user/scripts/record.sh](modules/user/scripts/record.sh) +### 1. GPU-Accelerated Video Recording (`record`) +* **Script Location:** [home/scripts/record.sh](home/scripts/record.sh) * **Functionality:** Uses `wf-recorder` to record Wayland outputs in Niri sessions. * **Modes:** * `area` — Manually drag and draw a target bounding box using `slurp`. @@ -82,15 +63,15 @@ graph TD * `screen` — Full layout capture. * `audio` flag — Parses `wpctl` to dynamically resolve output system loopback paths from PipeWire/WirePlumber to include sound. -### 3. Git Automation Shorthand (`git.sh`) -* **Script Location:** [modules/user/shell/git.sh](modules/user/shell/git.sh) +### 2. Git Automation Shorthand (`git.sh`) +* **Script Location:** [home/shell/git.sh](home/shell/git.sh) * **Features:** * `gitignore ` — Appends pattern to project-root `.gitignore`, commits the change, and pushes to remote. * `gacp ` — Shorthand to stage all edits, commit with a message, and push directly to the current branch. * `new-repo ` — Scaffolds local files, runs git init, and pushes the project to GitHub using the `gh` CLI. -### 4. Todo.txt & Tuxedo Productivity Helper (`todo.sh`) -* **Script Location:** [modules/user/shell/todo.sh](modules/user/shell/todo.sh) +### 3. Todo.txt & Tuxedo Productivity Helper (`todo.sh`) +* **Script Location:** [home/shell/todo.sh](home/shell/todo.sh) * **Features:** * `todo` — Launches the interactive `tuxedo` TUI for the local `./todo.txt`. * `todo n` / `todo next` — Displays only the highest-priority focus task. @@ -98,8 +79,8 @@ graph TD * `todo dn` / `todo do-next` — Auto-completes the top priority task. * `_todo_color` — Built-in awk parser adding ANSI color formatting for priorities, `@contexts`, `+projects`, dates, and `key:value` tags without broken-pipe errors. -### 5. Repository Bundler Utility (`bundle-project`) -* **Script Location:** [modules/user/scripts/bundle_project.py](modules/user/scripts/bundle_project.py) +### 4. Repository Bundler Utility (`bundle-project`) +* **Script Location:** [home/scripts/bundle_project.py](home/scripts/bundle_project.py) * **Features:** * `bundle-project [target_dir] [-o output_file]` — Compresses the structure and contents of a target directory (defaults to `.`) into a single output file (defaults to `output.txt`). * Natively skips binary files and `.git` repositories to prevent pollution. @@ -109,49 +90,34 @@ graph TD ## 🔒 Secrets Management (SOPS + age) -No plain text passwords, tokens, or private keys are committed to the public history. Secrets are stored inside encrypted `.yaml` assets decrypted dynamically on-demand at boot time using **`sops-nix`** and SSH host keys. +Sensitive credentials (tokens, private keys) are managed using `sops` and `age`. Plaintext secrets are never committed to version control. -```mermaid -graph LR - A[Encrypted secrets.yaml in Git] --> B(sops-nix on system boot) - C[Host SSH Private Key /etc/ssh/...] --> B - B --> D[Decrypted RAM filesystem /run/secrets/] - D --> E[Services read secrets securely] -``` - -### Adding and Modifying Secrets -1. Decrypt and open the host secrets file: - ```bash - nix-shell -p sops --run "sops hosts/server/secrets.yaml" - ``` -2. Save changes and exit. `sops` will automatically re-encrypt the file with the public keys defined in the root [.sops.yaml](.sops.yaml) configuration file. - -For detailed steps on bootstrapping, key generation, and service decryption, see the [Secrets Management Guide](docs/secrets-management.md). +For bootstrapping, key generation, and decryption workflows, consult the [Secrets Management Guide](docs/secrets-management.md). --- ## 🚀 Quick Start / Deployment ### 1. Installation -Clone the configuration workspace directly into your home folder: +Clone the configuration repository into your home folder: ```bash git clone https://github.com/kiskaadee/nixos-config.git ~/Config cd ~/Config ``` -### 2. Deploy System Configurations -Rebuild and switch to the profile matching your active target host machine: +### 2. Validate & Test Build +Verify flake evaluation and dry-build the derivation without switching: +```bash +nix flake check +nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link +``` -* **Server Host:** - ```bash - sudo nixos-rebuild switch --flake ~/Config#server - ``` -* **Laptop Workstation:** - ```bash - sudo nixos-rebuild switch --flake ~/Config#laptop - ``` - -*Note: The user environment configures `nix-switch` as an alias to automatically build and switch using the current hostname.* +### 3. Apply Configuration +Switch to the new generation on the laptop: +```bash +sudo nixos-rebuild switch --flake ~/Config#laptop +``` +*Tip: The shell environment includes the `nix-switch` alias to automatically rebuild using the local hostname.* --- @@ -161,7 +127,5 @@ Rebuild and switch to the profile matching your active target host machine: * [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. * [Secrets Management Details](docs/secrets-management.md) — Secure storage bootstrapping using `sops-nix` and `age`. -* [Smart DDNS Updater](docs/dynu-ip-monitor.md) — Under-the-hood details of the smart IP change detector and updater. * [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. - diff --git a/architecture.md b/architecture.md index 525ed72..090000d 100644 --- a/architecture.md +++ b/architecture.md @@ -1,12 +1,15 @@ -# System Architecture +# System Architecture: Standalone Workstation ## Core Principles -This repository manages a declarative NixOS configuration for multiple host targets (`server`, `laptop`) and shared user environments via Home Manager. +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 configuration must be declaratively defined within this repository. -2. **Runtime State Separation**: Runtime state (Docker volumes, dynamic IP caches, `/run/secrets/`, mutable state) must not become configuration state. -3. **Layered Isolation**: System modules provide reusable machine infrastructure; user modules configure user environments; host directories bind hardware, secrets, and machine-specific services together. +1. **Git is the Source of Truth**: Every persistent system setting, user dotfile, and toolchain declaration must be declaratively defined within this repository. +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. +3. **Privilege Boundary Separation**: + - **`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`. +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. --- @@ -14,43 +17,26 @@ This repository manages a declarative NixOS configuration for multiple host targ ```text Config/ -├── flake.nix # Flake inputs and nixosConfigurations public entrypoint -├── flake.lock # Pinned dependencies -├── home.nix # Root Home Manager shared entrypoint (Pure CLI: base, neovim, terminal) -├── .sops.yaml # SOPS encryption keys and path rules +├── flake.nix # Flake inputs and nixosConfigurations.laptop entrypoint +├── flake.lock # Pinned dependency revisions │ -├── hosts/ # Machine-specific configurations -│ ├── server/ -│ │ ├── configuration.nix # Server NixOS configuration (headless homelab node) -│ │ ├── hardware-configuration.nix # Generated hardware configuration -│ │ ├── home.nix # Server-specific Home Manager profile (diagnostics CLI) -│ │ ├── secrets.yaml # Encrypted server secrets (SOPS) -│ │ ├── dynu.nix # Dynu DDNS update service -│ │ ├── homeserver.nix # Core homelab runtime services (Docker) -│ │ └── traefik-deployments.nix # Traefik edge reverse proxy -│ │ -│ └── laptop/ -│ ├── configuration.nix # Laptop NixOS configuration (Niri compositor) -│ ├── hardware-configuration.nix # Generated hardware configuration -│ ├── home.nix # Laptop-specific Home Manager profile (Niri dotfiles) -│ └── secrets.yaml # Encrypted laptop secrets (SOPS) +├── system/ # NixOS system-level configuration (root / privileged) +│ ├── default.nix # System composition entrypoint +│ ├── hardware-configuration.nix # Generated hardware scan (disks, CPU, kernel modules) +│ ├── core.nix # Base OS: networking, users, locale, openssh, nix-ld +│ ├── hardware.nix # Laptop hardware: power daemon, upower, PipeWire, bluetooth, printing, docker +│ └── desktop.nix # Desktop stack: Niri compositor, DMS, greetd, fonts │ -├── modules/ -│ ├── system/ # Reusable system-level NixOS modules (shared across hosts) -│ │ ├── base.nix # Core OS settings, networking, audio, docker, bluetooth -│ │ └── graphical.nix # Shared display manager (greetd / DMS) & graphical daemons -│ │ -│ └── user/ # Reusable Home Manager modules (tiered split) -│ ├── base.nix # Tier 1: Pure CLI shell, utilities, Git, common environment -│ ├── terminal.nix # Tier 1: Pure CLI multiplexer (tmux) & prompt (starship) -│ ├── neovim.nix # Tier 1: Modular Neovim editor configuration -│ ├── apps.nix # Tier 2: Developer & user applications (Tea, Antigravity, SDKs) -│ ├── graphical.nix # Tier 3: Graphical user tools, Alacritty, Wayland stack, LSPs -│ ├── shell/ # Modular shell scripts, aliases, and functions -│ ├── scripts/ # Standalone helper scripts -│ └── config/ # Managed application dotfiles +├── home/ # Home Manager user-level configuration (kiskaadee) +│ ├── default.nix # User session entrypoint (paths, state version) +│ ├── desktop.nix # Graphical apps (Zen, Zed, media), Wayland tools, DankSearch, Niri/Zed dotfiles +│ ├── dev.nix # Developer toolchains (Rust, Python, Node, LSPs), Antigravity, Neovim +│ ├── shell.nix # Interactive shell (Bash, aliases, modular scripts), Git, Delta, Tmux, Starship +│ ├── config/ # Managed application dotfiles (alacritty, niri, nvim, zed, fastfetch, tmux) +│ ├── scripts/ # Standalone helper scripts (bundle-project, record) +│ └── shell/ # Modular bash source scripts (git, jump, pdf, quicklinks, todo, wayland) │ -└── docs/ # Procedural and operational documentation +└── docs/ # Operational workflows and maintenance runbooks ``` --- @@ -59,61 +45,43 @@ Config/ ```mermaid graph TD - A[flake.nix] --> B[nixosConfigurations.server] - A --> D[nixosConfigurations.laptop] + FLAKE["flake.nix"] --> CFG["nixosConfigurations.laptop"] - subgraph Server Host ["hosts/server/"] - B --> S_CONF[configuration.nix] - S_CONF --> S_HW[hardware-configuration.nix] - S_CONF --> S_DY[dynu.nix] - S_CONF --> S_TR[traefik-deployments.nix] - S_CONF --> S_HS[homeserver.nix] + subgraph System Layer ["system/ (Privileged Root / NixOS)"] + CFG --> S_DEF["system/default.nix"] + S_DEF --> S_HW["hardware-configuration.nix"] + S_DEF --> S_CORE["core.nix
(Host, Users, Boot, Nix-LD)"] + S_DEF --> S_DEV["hardware.nix
(Power, PipeWire, Bluetooth, Printing)"] + S_DEF --> S_DESK["desktop.nix
(Niri, DMS Daemon, Greeter, Fonts)"] end - subgraph Laptop Host ["hosts/laptop/"] - D --> L_CONF[configuration.nix] - L_CONF --> L_HW[hardware-configuration.nix] - end - - subgraph Tier1 Shared CLI HM ["home.nix (All Hosts)"] - B --> H[home.nix] - D --> H - H --> U1[base.nix] - H --> U2[neovim.nix] - H --> U3[terminal.nix] - end - - subgraph Tier23 Workstation HM ["Workstation Extensions (Laptop)"] - D --> LH[laptop/home.nix] - LH --> UA[apps.nix] - LH --> UG[graphical.nix] + subgraph User Layer ["home/ (Unprivileged User / Home Manager)"] + CFG --> H_DEF["home/default.nix"] + H_DEF --> H_DESK["desktop.nix
(GUI Apps, Wayland Tools, Alacritty, Zed, Niri Config)"] + H_DEF --> H_DEV["dev.nix
(Neovim, Compilers, LSPs, Antigravity, Cloud Tools)"] + H_DEF --> H_SH["shell.nix
(Bash, Git, Delta, Tmux, Starship, Fastfetch)"] end ``` ### 1. `flake.nix` -- **Role**: Public entry point for package set pinning, external flake inputs, and host output wiring (`nixosConfigurations`). -- **Contains**: `inputs` definitions (`nixpkgs`, `home-manager`, `dms`, `sops-nix`, `antigravity`, etc.) and system module composition via `specialArgs`. -- **Must Not Contain**: Package lists, user configurations, shell scripts, or host-specific options. +- **Role**: Public entry point declaring external flake inputs (`nixpkgs`, `home-manager`, `dms`, `zen-browser`, `antigravity`, etc.) and composing the single `laptop` target. +- **Rule**: Contains only inputs and host output definitions. No package lists or host-specific options. -### 2. `hosts//` -- **Role**: Contains everything specific to an individual physical machine. -- **Includes**: - - `hardware-configuration.nix`: Generated hardware and kernel parameters (managed by `nixos-generate-config`). - - `configuration.nix`: Hostname, bootloader, host-specific users, GPU/display drivers, and specialisations. - - `home.nix`: User packages and dotfiles tied to the host's desktop environment or headless role. - - `secrets.yaml`: SOPS-encrypted secrets for that machine. - - Host infrastructure services (e.g., `homeserver.nix`, `dynu.nix`, `traefik-deployments.nix` on `server`). +### 2. `system/` +- **Role**: Contains all system-level declarations requiring root privileges. +- **Components**: + - `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. + - `hardware.nix`: Power & battery management (`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. -### 3. `modules/system/` -- **Role**: Reusable system configuration shared by multiple hosts. -- **Rule**: A module must only be placed here when its assumptions are valid for every host importing it. If a configuration is meaningful only for one host, keep it under `hosts//`. - -### 4. `modules/user/` -- **Role**: Reusable Home Manager modules organized into clean, predictable layers: - - **Tier 1: Pure CLI Base** (`base.nix`, `terminal.nix`, `neovim.nix` via `home.nix`): Imported on all hosts (headless server, laptop). Provides pure terminal tools (`tmux`, `starship`), editor, Git, and essential CLI diagnostics. - - **Tier 2: Developer & User Apps** (`apps.nix`): Imported by workstation profiles. Provides developer toolchains, cloud SDKs, Git forge clients (`tea`, `gh`), and media tools. - - **Tier 3: Graphical Desktop Environment** (`graphical.nix`): Imported by workstation profiles. Provides Alacritty, Firefox, Zen Browser, Zed, DankSearch, Wayland capture/clipboard utilities (`wl-clipboard`, `grim`, `slurp`, `swappy`, `wf-recorder`, `obs-studio`), and Language Servers. - - `shell/`, `scripts/`, `config/`: Shell utility files and structured dotfiles. +### 3. `home/` +- **Role**: Contains all user-space declarations and dotfiles managed by Home Manager. +- **Components**: + - `default.nix`: Root user environment declaration (username, home directory, state version, session 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). + - `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. + - `shell.nix`: Bash shell aliases, prompt (`starship`), multiplexer (`tmux`), Git/Delta configuration, SSH client profiles, and modular shell helpers. --- @@ -122,30 +90,25 @@ graph TD | Concern | Target Location | Placement Rule | | :--- | :--- | :--- | | **External Dependencies** | `flake.nix` | Flake inputs only; lock `inputs.nixpkgs.follows` where applicable. | -| **Shared System Services** | `modules/system/` | Systemd services, system packages, or OS features valid for all importing hosts. | -| **Host System Settings** | `hosts//configuration.nix` | Hostname, bootloader, user groups, machine-specific daemons. | -| **Hardware / Disks** | `hosts//hardware-configuration.nix` | Generated configuration. Do not manually restructure or refactor. | -| **Shared CLI Foundations** | `modules/user/base.nix`, `terminal.nix` | Tier 1 pure CLI tools (Git, tmux, starship, core utilities) shared across all hosts. | -| **Workstation Dev Tools** | `modules/user/apps.nix` | Tier 2 developer CLI & cloud tools (`tea`, `antigravity`, compilers, SDKs). | -| **Workstation Graphical Stack** | `modules/user/graphical.nix` | Tier 3 GUI applications, terminal emulator (`alacritty`), Wayland tools, LSPs. | -| **Host-Specific User Apps** | `hosts//home.nix` | Tools relevant only to that host (e.g., Niri utilities on laptop). | -| **Shared Shell Tools** | `modules/user/shell/` | Modular bash/zsh helpers, aliases, and functions. | -| **Standalone Scripts** | `modules/user/scripts/` | Executable user shell scripts. | -| **Application Dotfiles** | `modules/user/config/` | Managed static configuration files linked into `$HOME/.config/`. | -| **Encrypted Secrets** | `hosts//secrets.yaml` | Encrypted with SOPS/age; referenced via `config.sops.secrets.*.path`. | -| **Homelab Services / DDNS** | `hosts/server/` | Machine-specific homelab infrastructure, reverse proxy, and DDNS monitor. | -| **How-To Guides** | `docs/` | Operational procedures and maintenance workflows. | +| **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. | +| **Machine Hardware Services** | `system/hardware.nix` | Audio, power profiles, battery, bluetooth, printing, docker. | +| **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. | +| **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. | +| **Static Application Dotfiles** | `home/config/` | Application configs linked into `$HOME/.config/`. | +| **Standalone Scripts** | `home/scripts/` | Executable user utility scripts. | +| **Modular Shell Helpers** | `home/shell/` | Discrete `.sh` files sourced by `.bashrc`. | +| **Encrypted Secrets** | SOPS / age | Decrypted dynamically into memory at runtime via SOPS. | +| **Homelab Services** | `~/Projects/active/homelab/Core` | Managed independently in the Core repository. | --- ## Architectural Invariants -These rules define the repository boundaries and must not be violated: - -1. **Flake Public Entrypoint Invariant**: `flake.nix` is the sole public entrypoint for building the repository's NixOS host configurations. -2. **Package Ownership Invariant**: Shared user applications belong under `modules/user/` categorized by tier (`base.nix` / `terminal.nix` for pure CLI, `apps.nix` for developer tools, `graphical.nix` for GUI/Wayland). Do not introduce arbitrary package lists in `modules/system/` unless strictly required for system-wide root maintenance or core OS services. -3. **Host Isolation Invariant**: Machine-specific homelab infrastructure (`homeserver.nix`, `traefik-deployments.nix`, `dynu.nix`) must remain isolated under their respective host directories and must never be imported into `hosts/laptop/`. -4. **Secrets Security Invariant**: Secrets must stay encrypted in Git via SOPS. Plaintext secrets must never be committed. Configurations must refer to secrets at runtime via `/run/secrets/` or `config.sops.secrets..path`. Never decrypt secrets into tracked or persistent working-tree files. Never add, modify, or rotate SOPS/age keys unless explicitly requested. -5. **Hardware Configuration Invariant**: `hardware-configuration.nix` is generated configuration. Do not manually restructure, clean up, or refactor it. Hardware-specific changes should normally be produced by `nixos-generate-config`; deliberate manual additions require explicit justification. -6. **Consumer Validation Invariant**: Changes to shared modules (`modules/system/` or `modules/user/`) or composed host configurations must be evaluated against all downstream consumers in the import graph (`server` and `laptop`). -7. **State Compatibility Invariant**: `system.stateVersion` and `home.stateVersion` (`26.05`) are compatibility declarations for stateful data and must not be bumped casually as part of routine maintenance or package updates. +1. **Single Entrypoint Invariant**: `flake.nix` is the sole entrypoint for building the workstation system (`laptop`). +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. +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. +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. diff --git a/docs/antigravity.md b/docs/antigravity.md index 70c4ea4..6f9c107 100644 --- a/docs/antigravity.md +++ b/docs/antigravity.md @@ -117,13 +117,13 @@ Add `antigravity-nix` to your flake inputs in `flake.nix`. Ensure that you lock You can inject the packages using standard package inputs in your configurations: #### Option A: Home Manager Integration (Recommended) -This matches your system's user setup. Add the required package to your user packages module (e.g., `modules/user/apps.nix`). +This matches your system's user setup. Add the required package to your developer tools module (e.g., `home/dev.nix`). > [!NOTE] > In this repository's default configuration, only the CLI helper (`google-antigravity-cli`) is installed. The GUI apps (`google-antigravity` and `google-antigravity-no-fhs`) are optional and omitted by default. ```nix -# modules/user/apps.nix +# home/dev.nix { inputs, pkgs, ... }: { diff --git a/docs/dynu-ip-monitor.md b/docs/dynu-ip-monitor.md deleted file mode 100644 index f40b93d..0000000 --- a/docs/dynu-ip-monitor.md +++ /dev/null @@ -1,92 +0,0 @@ -# 🌐 Dynu IP Monitor Service (dynu-ip-monitor) - -This service manages the Dynamic DNS (DDNS) lifecycle for your host. Instead of continuously polling public APIs (which can lead to blocks or rate-limits), it implements a smart, local-first change detector that updates Dynu via `ddclient` **only when an actual WAN IP rotation is detected**. - ---- - -## ⚙️ Architecture and Logic Flow - -The synchronization process runs in the background as a system service completely decoupled from the graphical user session. - -```mermaid -graph TD - A[Timer triggers dynu-monitor.service] --> B[Fetch public IP via HTTP] - B --> C{Verify public IPv4?} - C -- No/Timeout --> D[Log warning to journald & Fallback to next provider] - C -- Yes --> E[Read history database log] - E --> F{Did IP change?} - F -- No --> G[Exit cleanly] - F -- Yes --> H[Log rotation in history log] - H --> I[Trigger systemctl start ddclient.service] - I --> J{ddclient success?} - J -- Yes --> K[Record success in ip_history.jsonl] - J -- No --> L[Record failed_update in ip_history.jsonl & exit 1] -``` - ---- - -## 🔍 Public IP Discovery & Validation - -### 1. HTTP Resolvers with Fallback -The script queries multiple independent IP reflection endpoints sequentially to handle offline states or service outages: -1. `https://api.ipify.org` -2. `https://ifconfig.me/ip` -3. `https://icanhazip.com` -4. `https://wtfismyip.com/text` - -If a provider fails or times out, the script logs the warning to `stderr` and falls back to the next provider. If all providers fail, it exits with a non-zero code to flag a connectivity issue. - -### 2. IP Address Validation -Every returned IP must pass a verification check to ensure it is a valid public IPv4 address. The check rejects: -* Loopback ranges (`127.0.0.0/8`) -* Private networks / RFC 1918 (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`) -* Link-local addresses (`169.254.0.0/16`) -* Carrier-Grade NAT / CGNAT (`100.64.0.0/10`) - ---- - -## 📊 Persistent History Registry - -The monitor maintains a historical log of all your public IP assignments in a JSONLines format at `/var/lib/dynu/ip_history.jsonl`. - -Each entry records the timestamp, IP address, and status: -```json -{"timestamp": "2026-06-24T02:00:00Z", "ip": "186.116.231.181", "status": "success"} -{"timestamp": "2026-06-24T02:30:00Z", "ip": "186.116.231.181", "status": "success"} -{"timestamp": "2026-06-24T03:00:00Z", "ip": "186.116.232.40", "status": "success"} -``` - -At each check, the monitor compares the current public IP with the **last recorded successful IP** in the history file. If they match, the monitor exits cleanly without invoking the DNS provider APIs. - ---- - -## 🔑 secrets-management & sops-nix Integration - -### Dynamic User Credentials Access -The `ddclient` service in NixOS runs with systemd `DynamicUser=true` for security. Because the dynamic user doesn't exist statically, standard file ownership can prevent access. - -We resolve this by using systemd **`LoadCredential`**: -1. `sops-nix` decrypts the credentials file owned by `root:root` into `/run/secrets/`. -2. The systemd service for `ddclient` is injected with: - ```nix - LoadCredential = [ "ddclient.conf:${config.sops.templates."ddclient.conf".path}" ]; - ``` -3. Systemd copies the file securely, adjusts permissions, and exposes it inside the service boundaries at: - `/run/credentials/ddclient.service/ddclient.conf` -4. `ddclient` reads the configuration from the credentials directory. - ---- - -## ⏱️ Systemd Timers & Services Configuration - -The updater is divided into two systemd units defined in [dynu.nix](file:///home/kiskaadee/Config/hosts/server/dynu.nix): - -### 1. `dynu-monitor.timer` -Runs every 30 minutes. It triggers the `dynu-monitor.service` which executes the Python script. - -### 2. `ddclient.service` (On-Demand) -The automatic `ddclient.timer` is disabled. The service is only triggered by the Python script using: -```bash -systemctl start ddclient.service -``` -This ensures your host only makes outbound API calls to Dynu when a rotation actually occurs, maintaining zero overhead. diff --git a/docs/package-and-secrets.md b/docs/package-and-secrets.md index 1ed7416..6b973b3 100644 --- a/docs/package-and-secrets.md +++ b/docs/package-and-secrets.md @@ -6,7 +6,10 @@ This guide covers the day-to-day workflow for managing user-space packages and s ## 🚀 Adding a New Package -User-space applications are managed declaratively using Home Manager in [modules/user/apps.nix](file:///home/kiskaadee/Config/modules/user/apps.nix). +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: @@ -18,8 +21,8 @@ Before adding a package, look up its exact attribute name: nix search nixpkgs ``` -### Step 2: Update `apps.nix` -Open [modules/user/apps.nix](file:///home/kiskaadee/Config/modules/user/apps.nix) and append the package name directly into the list inside `home.packages`: +### 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; [ @@ -47,12 +50,12 @@ 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`. +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 the target secrets file (e.g., [secrets.yaml](file:///home/kiskaadee/Config/hosts/server/secrets.yaml)): +Launch `sops` inside `nix-shell` to decrypt and edit your secrets file: ```bash -nix-shell -p sops --run "sops hosts/server/secrets.yaml" +nix-shell -p sops --run "sops secrets.yaml" ``` Add your key-value pair under the YAML structure: ```yaml @@ -61,13 +64,12 @@ 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 (e.g., in [hosts/server/dynu.nix](file:///home/kiskaadee/Config/hosts/server/dynu.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 = "root"; - group = "root"; + owner = "kiskaadee"; mode = "0400"; }; ``` diff --git a/docs/secrets-management.md b/docs/secrets-management.md index cbf2e45..000f4df 100644 --- a/docs/secrets-management.md +++ b/docs/secrets-management.md @@ -1,14 +1,14 @@ -# 🔒 Secrets Management via sops-nix +# 🔒 Secrets Management via SOPS & age -This repository utilizes **`sops-nix`** (integrated with Mozilla SOPS and `age`) to manage all sensitive information (passwords, tokens, API keys) declaratively and securely. +This repository utilizes **`sops`** and **`age`** (with optional **`sops-nix`** integration) to manage sensitive information (passwords, tokens, API keys) declaratively and securely. -Secrets are stored encrypted directly in the Git repository, and decrypted dynamically at boot into memory (`/run/secrets/`), ensuring no credentials leak into the public-readable Nix store. +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 a Recreated Server +## 🛠️ Bootstrapping Secrets on the Workstation -If you are setting up a new host or rebuilding the system from scratch, follow these steps to configure your secrets key structure. +To set up or re-initialize secrets encryption on the laptop: ### Step 1: Generate a User age Key Pair To encrypt and decrypt files on your local machine, generate a native `age` key pair: @@ -39,15 +39,13 @@ Add both the user `age` public key and the host `age` public key to the [.sops.y ```yaml keys: - - &server age1...your_server_age_key... - &laptop age1...your_laptop_age_key... creation_rules: - - path_regex: hosts/(server|laptop)/secrets\.yaml$ + - path_regex: secrets\.yaml$ key_groups: - pgp: [] age: - - *server - *laptop ``` @@ -59,24 +57,16 @@ Because `sops` automatically reads from your local `~/.config/sops/age/keys.txt` ### Create/Edit an Encrypted File ```bash -nix-shell -p sops --run "sops hosts/server/secrets.yaml" +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. -### Structure of `secrets.yaml` -Provide your keys and values as standard YAML: -```yaml -dynu_user: your-username -dynu_domain: your-domain.dynu.net -dynu_password: your-secret-password-or-hash -``` - --- ## 🔄 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 `hosts/server/secrets.yaml`. -3. The values are exposed under `/run/secrets/` as individual files (or templates) with strict user/group ownership (typically restricted to `root`). +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`. diff --git a/docs/system-maintenance.md b/docs/system-maintenance.md index 710e0e6..8f1b0c1 100644 --- a/docs/system-maintenance.md +++ b/docs/system-maintenance.md @@ -42,9 +42,10 @@ Verify system health immediately after a major system switch: ```bash ls -la /run/secrets/ ``` -4. **Network Resolution:** Check DNS resolution and active IP rotation daemons: +4. **Network & Connectivity:** Verify internet connectivity and NetworkManager status: ```bash - systemctl status dynu-monitor.service + systemctl status NetworkManager.service + ping -c 3 google.com ``` --- diff --git a/flake.nix b/flake.nix index fede41f..2151940 100644 --- a/flake.nix +++ b/flake.nix @@ -1,16 +1,15 @@ { - description = "Kiskaadee's Modular NixOS Configuration"; + description = "Kiskaadee's Declarative NixOS Laptop Workstation"; # --- External Repositories & Flake Inputs --- - # These inputs specify where Nix downloads package sets, tools, and configurations. inputs = { - # NixOS Unstable channel - used for bleeding-edge package releases (official project-hosted zstd tarball) + # NixOS Unstable channel - official project-hosted zstd tarball nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst"; # Home Manager - manages user-space configurations, dotfiles, and shell environments home-manager = { url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; # Forces home-manager to use the same nixpkgs channel + inputs.nixpkgs.follows = "nixpkgs"; }; # DankMaterialShell (DMS) - core custom desktop shell environment and panel @@ -49,11 +48,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - ## Cryptographic Secrets management + # Cryptographic Secrets management sops-nix = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; - }; + }; # Antigravity CLI - coding companion and local AI agent helper antigravity = { @@ -62,20 +61,17 @@ }; }; - # --- System Outputs (Configuration Definitions) --- - # Maps host machines to target environments, architecture types, and user settings. - outputs = { self, nixpkgs, home-manager, dms, dgop, dank-greeter, dankcalendar, danksearch, zen-browser, antigravity, ...}@inputs: { + # --- System Outputs --- + outputs = { self, nixpkgs, home-manager, dms, dgop, dank-greeter, dankcalendar, danksearch, zen-browser, antigravity, ... }@inputs: { nixosConfigurations = { - - # 🌐 SERVER HOST (Dedicated Headless Homelab Node) - # Production server host running Docker, Traefik, SOPS secrets, and DDNS. - server = nixpkgs.lib.nixosSystem { + # 💻 LAPTOP HOST (Mobile Workstation) + laptop = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ - ./hosts/server/hardware-configuration.nix - ./hosts/server/configuration.nix - inputs.sops-nix.nixosModules.sops + ./system + inputs.dank-greeter.nixosModules.default + inputs.dankcalendar.nixosModules.default home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; @@ -84,34 +80,7 @@ home-manager.extraSpecialArgs = { inherit inputs; }; home-manager.users.kiskaadee = { imports = [ - ./home.nix - ./hosts/server/home.nix - ]; - }; - } - ]; - }; - - # 💻 LAPTOP HOST (Mobile Workstation) - # Target laptop workstation running Niri window manager. - laptop = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { inherit inputs; }; - modules = [ - ./hosts/laptop/hardware-configuration.nix - ./hosts/laptop/configuration.nix - inputs.dank-greeter.nixosModules.default - inputs.dankcalendar.nixosModules.default - - home-manager.nixosModules.home-manager { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.backupFileExtension = "backup"; # Auto-back up conflicting files - home-manager.extraSpecialArgs = { inherit inputs; }; - home-manager.users.kiskaadee = { - imports = [ - ./home.nix - ./hosts/laptop/home.nix + ./home inputs.danksearch.homeModules.default ]; }; diff --git a/home.nix b/home.nix deleted file mode 100644 index 7b16348..0000000 --- a/home.nix +++ /dev/null @@ -1,30 +0,0 @@ -# 🏠 Home Manager Base Configuration Entrypoint -# Shared user environment foundations (Git, Shell, Neovim, Terminal) across all systems. - -{ config, pkgs, ... }: - -{ - # Import core user-specific modules - imports = [ - ./modules/user/base.nix # Core shell configurations, utilities, git aliases, SOPS & age - ./modules/user/neovim.nix # Neovim configuration, plugins, tree-sitter, LSP, DAP - ./modules/user/terminal.nix # Terminal emulators and multiplexers (Alacritty, Tmux, Starship) - ]; - - # Home directory settings - home.username = "kiskaadee"; - home.homeDirectory = "/home/kiskaadee"; - - # Ensure cargo/bin (and other user binaries) are in the system PATH - home.sessionPath = [ - "$HOME/.cargo/bin" - "$HOME/.local/bin" - "$HOME/Core/scripts" - ]; - - # The state version of Home Manager that this configuration is compatible with. - home.stateVersion = "26.05"; - - # Enable Home Manager to manage itself - programs.home-manager.enable = true; -} diff --git a/modules/user/config/alacritty/alacritty.toml b/home/config/alacritty/alacritty.toml similarity index 100% rename from modules/user/config/alacritty/alacritty.toml rename to home/config/alacritty/alacritty.toml diff --git a/modules/user/config/fastfetch/config.jsonc b/home/config/fastfetch/config.jsonc similarity index 100% rename from modules/user/config/fastfetch/config.jsonc rename to home/config/fastfetch/config.jsonc diff --git a/modules/user/config/niri/config.kdl b/home/config/niri/config.kdl similarity index 100% rename from modules/user/config/niri/config.kdl rename to home/config/niri/config.kdl diff --git a/modules/user/config/niri/custom.kdl b/home/config/niri/custom.kdl similarity index 100% rename from modules/user/config/niri/custom.kdl rename to home/config/niri/custom.kdl diff --git a/modules/user/config/nvim/catppuccin.lua b/home/config/nvim/catppuccin.lua similarity index 100% rename from modules/user/config/nvim/catppuccin.lua rename to home/config/nvim/catppuccin.lua diff --git a/modules/user/config/nvim/dap.lua b/home/config/nvim/dap.lua similarity index 100% rename from modules/user/config/nvim/dap.lua rename to home/config/nvim/dap.lua diff --git a/modules/user/config/nvim/init.lua b/home/config/nvim/init.lua similarity index 100% rename from modules/user/config/nvim/init.lua rename to home/config/nvim/init.lua diff --git a/modules/user/config/nvim/lsp.lua b/home/config/nvim/lsp.lua similarity index 100% rename from modules/user/config/nvim/lsp.lua rename to home/config/nvim/lsp.lua diff --git a/modules/user/config/starship.toml b/home/config/starship.toml similarity index 100% rename from modules/user/config/starship.toml rename to home/config/starship.toml diff --git a/modules/user/config/tmux.conf b/home/config/tmux.conf similarity index 100% rename from modules/user/config/tmux.conf rename to home/config/tmux.conf diff --git a/modules/user/config/zed/settings.json b/home/config/zed/settings.json similarity index 100% rename from modules/user/config/zed/settings.json rename to home/config/zed/settings.json diff --git a/modules/user/config/zed/themes/dank-zed-theme.json b/home/config/zed/themes/dank-zed-theme.json similarity index 100% rename from modules/user/config/zed/themes/dank-zed-theme.json rename to home/config/zed/themes/dank-zed-theme.json diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..11d249c --- /dev/null +++ b/home/default.nix @@ -0,0 +1,29 @@ +# 🏠 Home Manager Workstation Profile Entrypoint +# User-level environment for kiskaadee on the laptop workstation. + +{ ... }: + +{ + imports = [ + ./desktop.nix + ./dev.nix + ./shell.nix + ]; + + # User identity & home path + home.username = "kiskaadee"; + home.homeDirectory = "/home/kiskaadee"; + + # User binary search paths + home.sessionPath = [ + "$HOME/.cargo/bin" + "$HOME/.local/bin" + "$HOME/Core/scripts" + ]; + + # Compatibility state version + home.stateVersion = "26.05"; + + # Enable Home Manager self-management + programs.home-manager.enable = true; +} diff --git a/modules/user/graphical.nix b/home/desktop.nix similarity index 79% rename from modules/user/graphical.nix rename to home/desktop.nix index 572461e..e5f39ab 100644 --- a/modules/user/graphical.nix +++ b/home/desktop.nix @@ -1,13 +1,32 @@ -# 🎨 User Graphical Module -# Configures graphical workspace tools, GUI applications, and window manager session unit targets. -# Only imported by desktop and laptop profiles. +# 🎨 User Desktop & Graphical Applications +# GUI applications, Wayland capture tools, Alacritty, Firefox, DankSearch, and Niri/Zed dotfiles. { inputs, pkgs, ... }: + +let + # Declaratively compile local scripts as user utility packages + bundleProject = pkgs.writeScriptBin "bundle-project" (builtins.readFile ./scripts/bundle_project.py); + recordScript = pkgs.writeScriptBin "record" (builtins.readFile ./scripts/record.sh); +in { - # Graphical packages managed via Home Manager home.packages = with pkgs; [ - inputs.zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.default # Modern browser build - zed-editor # GPU-accelerated desktop text editor + # Custom scripts + bundleProject + recordScript + + # Modern Web Browser + inputs.zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.default + + # Graphical Applications & Editors + zed-editor + obsidian + libreoffice + nautilus + yazi + mpv + gimp + imagemagick + eyed3 # Wayland Clipboard, Screenshot & Screen Capture Utilities wl-clipboard @@ -17,19 +36,6 @@ libnotify wf-recorder obs-studio - - # Language Servers for Zed (and general dev use) - rust-analyzer - pyright - ruff - nil - nixd - jdt-language-server - typescript-language-server - lua-language-server - taplo - marksman - prettier ]; # GPU-Accelerated Terminal Emulator (Alacritty) @@ -38,16 +44,13 @@ settings = builtins.fromTOML (builtins.readFile ./config/alacritty/alacritty.toml); }; - # Firefox configuration + # Firefox configuration with hardware acceleration programs.firefox = { enable = true; profiles.default = { settings = { - # Force hardware acceleration "layers.acceleration.force-enabled" = true; "gfx.webrender.all" = true; - - # Disable pocket-telemetry "extensions.pocket.enabled" = false; "datareporting.healthreport.uploadEnabled" = false; }; @@ -62,7 +65,7 @@ home.file.".config/niri/config.kdl".source = ./config/niri/config.kdl; home.file.".config/niri/custom.kdl".source = ./config/niri/custom.kdl; - # ⚙️ Systemd user session targets for window managers + # Systemd user session targets for window managers systemd.user.targets.hyprland-session = { Unit = { Description = "Hyprland graphical session"; @@ -83,7 +86,7 @@ }; }; - # 🔍 DankSearch - Fast Indexed Filesystem Search Service + # DankSearch - Fast Indexed Filesystem Search Service programs.dsearch = { enable = true; config = { diff --git a/home/dev.nix b/home/dev.nix new file mode 100644 index 0000000..b67057a --- /dev/null +++ b/home/dev.nix @@ -0,0 +1,132 @@ +# 🛠️ Developer Environment, Toolchains & Neovim +# Compilers, SDKs, language servers, API testing tools, and modular Neovim configuration. + +{ inputs, pkgs, ... }: + +{ + # Neovim CLI & IDE Editor Configuration + programs.neovim = { + enable = true; + defaultEditor = true; # Make neovim the default $EDITOR + viAlias = true; # Symlink vi -> nvim + vimAlias = true; # Symlink vim -> nvim + + # Core Editor Settings (Lua-based) + initLua = builtins.readFile ./config/nvim/init.lua; + + # Declarative Plugin Management + plugins = with pkgs.vimPlugins; [ + { + plugin = catppuccin-nvim; + type = "lua"; + config = builtins.readFile ./config/nvim/catppuccin.lua; + } + (nvim-treesitter.withPlugins (p: with p; [ + python + rust + nix + lua + java + javascript + typescript + markdown + kdl + toml + bash + ])) + { + plugin = nvim-lspconfig; + type = "lua"; + } + { + plugin = nvim-dap; + } + { + plugin = nvim-dap-ui; + } + ]; + }; + + # Declarative configuration files for Neovim (lsp.lua & dap.lua loaded dynamically via init.lua) + home.file.".config/nvim/lsp.lua".source = ./config/nvim/lsp.lua; + home.file.".config/nvim/dap.lua".source = ./config/nvim/dap.lua; + + # Developer packages & Toolchains + home.packages = with pkgs; [ + # AI Assistant Companion + inputs.antigravity.packages.${pkgs.stdenv.hostPlatform.system}.google-antigravity-cli + + # Rust Toolchain & Language Server + cargo + rustc + rustfmt + clippy + rust-analyzer + gcc + + # Python Toolchain & Language Server + python3 + uv + ruff + mypy + pyright + + # Node.js, Web & Formatter Tooling + nodejs + prettier + + # Language Servers (Zed, Neovim, General) + nil + nixd + jdt-language-server + typescript-language-server + lua-language-server + taplo + marksman + + # Cloud CLI, Git Forge & Database Management + tea # Gitea official CLI client + google-cloud-sdk # GCP administration utilities + turso-cli # Turso libSQL management CLI + postgresql # PostgreSQL client utilities (psql, pg_dump) + pgcli # Postgres client with auto-completion + + # API Testing & Networking + httpie # User-friendly HTTP/REST client + bruno # Fast, git-friendly GUI API client + websocat # WebSocket client + grpcurl # gRPC command-line tool + bind.dnsutils # DNS lookup tools (dig, nslookup) + openssh # SSH client tools + sshfs # FUSE-based SSH filesystem mount + nmap # Network scanner + arp-scan # ARP packet scanner + + # File & Archive Utilities + wget + zip + unzip + unrar + rsync + aria2 + + # CLI Productivity & Text Processing + ripgrep + fd + glow + jq + tree + sqlite + bc + qpdf + tty-clock + curl + parallel + tuxedo + + # Secrets Management + rbw # Bitwarden CLI client + sops # Mozilla SOPS CLI + age # File encryption tool + ]; +} diff --git a/modules/user/scripts/bundle_project.py b/home/scripts/bundle_project.py similarity index 100% rename from modules/user/scripts/bundle_project.py rename to home/scripts/bundle_project.py diff --git a/modules/user/scripts/record.sh b/home/scripts/record.sh similarity index 100% rename from modules/user/scripts/record.sh rename to home/scripts/record.sh diff --git a/modules/user/base.nix b/home/shell.nix similarity index 80% rename from modules/user/base.nix rename to home/shell.nix index 32ddfed..9b54c66 100644 --- a/modules/user/base.nix +++ b/home/shell.nix @@ -1,13 +1,11 @@ -# 🛠️ User Base Shell & Git Environment -# This module defines the foundation of the interactive user shell, command line utilities, -# custom shell scripts, aliases, and Git workflows. +# 🐚 User Shell, Terminal Multiplexing & Git Environment +# Bash aliases, modular shell scripts, Git, Delta, Gh, Direnv, SSH client, Tmux, Starship, and Fastfetch. -{ pkgs, ...}: +{ pkgs, ... }: { programs = { # 🌟 Git Version Control Configuration - # Declares default user identity, global conflict styles, and highly optimized git aliases git = { enable = true; settings = { @@ -54,6 +52,7 @@ }; }; + # Syntax-highlighting pager for git delta = { enable = true; enableGitIntegration = true; @@ -65,14 +64,14 @@ }; }; - # ⚡ Direnv - Automatic environment loading - # Automatically activates nix development shells when entering project directories containing .envrc + # ⚡ Direnv - Automatic environment loading for Nix dev shells direnv = { enable = true; enableBashIntegration = true; nix-direnv.enable = true; }; + # GitHub CLI gh = { enable = true; settings = { @@ -89,7 +88,6 @@ }; # 🔑 SSH Client Configuration - # Declaratively configures SSH client connections and host options ssh = { enable = true; enableDefaultConfig = false; @@ -120,7 +118,6 @@ }; # 🗺️ Navigation & Directory Listing - # Modern replacements for traditional cd, ls, and grep tools. zoxide = { enable = true; enableBashIntegration = true; @@ -137,7 +134,7 @@ eza = { enable = true; enableBashIntegration = true; - extraOptions = ["--group-directories-first" "--header" "--icons"]; + extraOptions = [ "--group-directories-first" "--header" "--icons" ]; }; tealdeer = { @@ -150,13 +147,27 @@ enable = true; }; + # 🖥️ Terminal Multiplexer (Tmux) + tmux = { + enable = true; + extraConfig = builtins.readFile ./config/tmux.conf; + }; + + # 🚀 Cross-Shell Prompt (Starship) + starship = { + enable = true; + enableBashIntegration = true; + settings = builtins.fromTOML (builtins.readFile ./config/starship.toml); + }; + + # 📊 System Information Dashboard (Fastfetch) + fastfetch.enable = true; + # 🐚 Bash Shell Configuration - # Bridges the Arch 'bash-custom' environment to NixOS, defining aliases and sourcing modular scripts. bash = { enable = true; - enableCompletion = true; # Enable programmable auto-completion for system commands + enableCompletion = true; - # Shell Aliases for speed, productivity, and command overrides shellAliases = { zed = "zeditor"; reload = "exec bash"; @@ -170,8 +181,6 @@ # System Administration nix-switch = "sudo nixos-rebuild switch --flake ~/Config#$(hostname)"; - server-on = "sudo /run/current-system/specialisation/server/bin/switch-to-configuration switch"; - server-off = "sudo /run/current-system/bin/switch-to-configuration switch"; sys = "dgop"; wifi = "nmtui"; lock = "hyprlock"; @@ -213,8 +222,7 @@ gadc = "git add -A && git diff --staged | wl-copy"; }; - # Inject modular shell helper scripts directly into .bashrc. - # This allows us to keep discrete logic files without cluttering home.nix or base.nix. + # Inject modular shell helper scripts directly into .bashrc bashrcExtra = '' # 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 @@ -232,14 +240,6 @@ }; }; - # 📊 Custom Catnap-style Fastfetch - # A stylized, minimalist system information dashboard displayed on shell startup - programs.fastfetch.enable = true; + # Link fastfetch config home.file.".config/fastfetch/config.jsonc".source = ./config/fastfetch/config.jsonc; - - # Standalone CLI utilities & system dependencies - home.packages = with pkgs; [ - ripgrep fd glow jq tree sqlite python3 nodejs - bc qpdf tty-clock uv curl parallel tuxedo sops age - ]; } diff --git a/modules/user/shell/git.sh b/home/shell/git.sh similarity index 100% rename from modules/user/shell/git.sh rename to home/shell/git.sh diff --git a/modules/user/shell/interactive.sh b/home/shell/interactive.sh similarity index 100% rename from modules/user/shell/interactive.sh rename to home/shell/interactive.sh diff --git a/modules/user/shell/jump.sh b/home/shell/jump.sh similarity index 100% rename from modules/user/shell/jump.sh rename to home/shell/jump.sh diff --git a/modules/user/shell/pdf.sh b/home/shell/pdf.sh similarity index 100% rename from modules/user/shell/pdf.sh rename to home/shell/pdf.sh diff --git a/modules/user/shell/quicklinks.sh b/home/shell/quicklinks.sh similarity index 100% rename from modules/user/shell/quicklinks.sh rename to home/shell/quicklinks.sh diff --git a/modules/user/shell/todo.sh b/home/shell/todo.sh similarity index 100% rename from modules/user/shell/todo.sh rename to home/shell/todo.sh diff --git a/modules/user/shell/wayland.sh b/home/shell/wayland.sh similarity index 100% rename from modules/user/shell/wayland.sh rename to home/shell/wayland.sh diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix deleted file mode 100644 index 923ef7f..0000000 --- a/hosts/laptop/configuration.nix +++ /dev/null @@ -1,78 +0,0 @@ -# 💻 Laptop Machine Configuration -# This file defines host-specific system configurations for the Laptop environment. -# Sharing 100% of base shell, neovim, apps, and terminal settings with desktop, -# but swapping the graphical compositor stack to Niri. - -{ config, lib, pkgs, ... }: - -{ - imports = [ - ./hardware-configuration.nix - ../../modules/system/graphical.nix # System-wide graphical stack settings (DMS daemon + greeter) - ../../modules/system/base.nix # General hardware-agnostic OS settings - ]; - - # Enable experimental Nix features (required for Flakes and newer command line tools) - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - # System-wide fonts installed for general window manager / applications - fonts.packages = with pkgs; [ - inter - nerd-fonts.fira-code - nerd-fonts.jetbrains-mono - nerd-fonts.roboto-mono - ]; - - # Configure default fonts for system-wide alias fallbacks - fonts.fontconfig = { - enable = true; - defaultFonts = { - monospace = [ "Fira Code" ]; - sansSerif = [ "Inter" ]; - }; - }; - - # EFI bootloader configuration - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - # Network identification - networking.hostName = "laptop"; - - # Define the main user profile - users.users.kiskaadee = { - isNormalUser = true; - extraGroups = [ - "wheel" # Enable sudo access for administrative tasks - "docker" # Allows running docker commands without sudo - "networkmanager" # Allows modifying network configurations - "lp" # Allows managing printers and print jobs - "scanner" # Allows access to scanners - ]; - }; - - # Host-specific graphical compositor (Niri window manager for laptop) - programs.niri.enable = true; - - # Dynamic binary execution support (for unpatched binaries, VS Code server, language servers) - programs.nix-ld = { - enable = true; - libraries = with pkgs; [ - stdenv.cc.cc.lib - zlib - glib - ]; - }; - - # 🔋 Laptop Power & Battery Management - services.power-profiles-daemon.enable = true; - services.upower.enable = true; - - # Backlight brightness control utility - environment.systemPackages = with pkgs; [ - brightnessctl - ]; - - # Rebuild/State version. Do not modify. - system.stateVersion = "26.05"; -} diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix deleted file mode 100644 index 7ec7908..0000000 --- a/hosts/laptop/home.nix +++ /dev/null @@ -1,11 +0,0 @@ -# 🏠 Laptop Host-Specific Home Manager Configuration -# Graphical workstation environment for Niri-powered mobile laptop. - -{ config, pkgs, ... }: - -{ - imports = [ - ../../modules/user/apps.nix - ../../modules/user/graphical.nix - ]; -} diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix deleted file mode 100644 index 978c1e3..0000000 --- a/hosts/server/configuration.nix +++ /dev/null @@ -1,90 +0,0 @@ -# 🌐 Server Machine Configuration (Headless Homelab Node) -# This file defines host-specific system configurations for the dedicated Server environment. - -{ config, lib, pkgs, ... }: - -{ - imports = [ - ./hardware-configuration.nix # Server-specific disk and CPU configuration - ../../modules/system/base.nix # General hardware-agnostic OS settings - ./dynu.nix # Dynu DDNS update service - ./traefik-deployments.nix # Traefik deployments secrets module - ./homeserver.nix # Homeserver core services module - ]; - - # Enable experimental Nix features - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - # System-wide fonts - fonts.packages = with pkgs; [ - nerd-fonts.fira-code - nerd-fonts.jetbrains-mono - nerd-fonts.fira-mono - inter - ]; - - # Configure default fonts - fonts.fontconfig = { - enable = true; - defaultFonts = { - monospace = [ "FiraCode Nerd Font" "JetBrainsMono Nerd Font" "Fira Code" ]; - sansSerif = [ "Inter" ]; - }; - }; - - # Console font for local TTY screen - console = { - font = "Lat2-Terminus16"; - keyMap = "us"; - }; - - # EFI bootloader configuration - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - # Network identification - networking.hostName = "server"; - - # Define the main user profile - users.users.kiskaadee = { - isNormalUser = true; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICAVPPMk+WApUd/fo78+lsRGnLKSlY4GDZiNGKwBAifD" - ]; - extraGroups = [ - "wheel" # Enable sudo access - "docker" # Allows running docker commands without sudo - "networkmanager" # Allows modifying network configurations - ]; - }; - - # Dynamic binary execution support - programs.nix-ld = { - enable = true; - libraries = with pkgs; [ - stdenv.cc.cc.lib - zlib - glib - ]; - }; - - # Headless Server Optimizations: - # Disable peripheral hardware & desktop services - services.pipewire.enable = lib.mkForce false; - services.printing.enable = lib.mkForce false; - hardware.bluetooth.enable = lib.mkForce false; - services.blueman.enable = lib.mkForce false; - services.greetd.enable = lib.mkForce false; - - # Disable power-saving suspend/sleep/hibernate behaviors to keep homelab always active - systemd.targets.sleep.enable = lib.mkForce false; - systemd.targets.suspend.enable = lib.mkForce false; - systemd.targets.hibernate.enable = lib.mkForce false; - systemd.targets.hybrid-sleep.enable = lib.mkForce false; - - # Kernel-level power management tuning - powerManagement.powertop.enable = true; - - # Rebuild/State version. Do not modify. - system.stateVersion = "26.05"; -} diff --git a/hosts/server/ddclient.conf b/hosts/server/ddclient.conf deleted file mode 100644 index c61a9b2..0000000 --- a/hosts/server/ddclient.conf +++ /dev/null @@ -1,12 +0,0 @@ -# General configuration -syslog=no -pid=/run/ddclient/ddclient.pid -cache=/var/lib/ddclient/ddclient.cache -usev4=webv4 - -# Provider definition using credentials decrypted at runtime -protocol=dyndns2 -server=api.dynu.com -login=@dynu_user@ -password=@dynu_password@ -@dynu_domain@ diff --git a/hosts/server/dynu.nix b/hosts/server/dynu.nix deleted file mode 100644 index 2078053..0000000 --- a/hosts/server/dynu.nix +++ /dev/null @@ -1,92 +0,0 @@ -# 🌐 Dynu DDNS IP Monitor & Updater Service -# This NixOS module configures a smart, local-first IP change detector. -# It queries public IP providers, maintains a history log of WAN IP rotations, -# and triggers ddclient only when an actual change is detected to prevent API rate limits. - -{ config, lib, pkgs, ... }: - -let - # Declaratively read the external Python script into the Nix store at evaluation time - ipMonitorScript = pkgs.writers.writePython3Bin "dynu-ip-monitor" { } (builtins.readFile ./monitor.py); -in -{ - # 1. Load the encrypted secrets file - sops.defaultSopsFile = ./secrets.yaml; - sops.defaultSopsFormat = "yaml"; - - # Define the keys to decrypt - sops.secrets."dynu/user" = { }; - sops.secrets."dynu/domain" = { }; - sops.secrets."dynu/password" = { }; - sops.secrets."system/pdf_decrypt_password" = { - owner = "kiskaadee"; - }; - - # Assemble the ddclient config file securely at boot time in /run/secrets/ - # Defaults to owner root:root (which avoids dynamic user evaluation issues) - 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); - }; - - # 2. Enable ddclient and feed it the decrypted configuration template via systemd credentials - services.ddclient = { - enable = true; - configFile = "/run/credentials/ddclient.service/ddclient.conf"; - }; - - systemd.services.ddclient = { - serviceConfig = { - # Securely load the root-owned secret file into the dynamic ddclient service - LoadCredential = [ "ddclient.conf:${config.sops.templates."ddclient.conf".path}" ]; - }; - }; - - # 3. Disable ddclient's automatic timer. - # This stops ddclient from polling every 10 minutes on its own. - systemd.timers.ddclient.enable = false; - - # 4. Define the smart IP change detector service - systemd.services.dynu-monitor = { - description = "Dynu DDNS Smart IP Change Monitor"; - after = [ "network-online.target" ]; - wants = [ "network-online.target" ]; - path = with pkgs; [ - systemd # Required for systemctl - ]; - serviceConfig = { - Type = "oneshot"; - User = "root"; - Group = "root"; - StateDirectory = "dynu"; - Environment = "HISTORY_FILE=/var/lib/dynu/ip_history.jsonl"; - ExecStart = "${ipMonitorScript}/bin/dynu-ip-monitor"; - TimeoutSec = 30; - - # Hardening - NoNewPrivileges = true; - PrivateTmp = true; - ProtectSystem = "strict"; - ProtectHome = true; - ReadWritePaths = "/var/lib/dynu"; - }; - }; - - # 5. Run the smart IP change monitor periodically (every 30 minutes) - systemd.timers.dynu-monitor = { - description = "Run Dynu IP monitor periodically"; - timerConfig = { - OnBootSec = "5min"; - OnUnitActiveSec = "30min"; - AccuracySec = "1min"; - Persistent = true; - }; - wantedBy = [ "timers.target" ]; - }; -} diff --git a/hosts/server/hardware-configuration.nix b/hosts/server/hardware-configuration.nix deleted file mode 100644 index 0b10a8a..0000000 --- a/hosts/server/hardware-configuration.nix +++ /dev/null @@ -1,41 +0,0 @@ -# Do not modify this file! It was generated by ‘nixos-generate-config’ -# and may be overwritten by future invocations. Please make changes -# to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - -{ - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; - - boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usbhid" ]; - boot.initrd.kernelModules = [ "dm-snapshot" ]; - boot.kernelModules = [ "kvm-amd" ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = - { device = "/dev/mapper/nixos_vg-root"; - fsType = "ext4"; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/66E6-7442"; - fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; - }; - - fileSystems."/media" = - { device = "/dev/mapper/nixos_vg-media"; - fsType = "ext4"; - }; - - fileSystems."/home" = - { device = "/dev/mapper/nixos_vg-home"; - fsType = "ext4"; - }; - - swapDevices = [ ]; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/hosts/server/home.nix b/hosts/server/home.nix deleted file mode 100644 index e0ba747..0000000 --- a/hosts/server/home.nix +++ /dev/null @@ -1,14 +0,0 @@ -# 🏠 Server Host-Specific Home Manager Configuration -# Pure CLI environment for headless server operation. - -{ config, pkgs, ... }: - -{ - # Server CLI packages - home.packages = with pkgs; [ - htop - iotop - iftop - ncdu - ]; -} diff --git a/hosts/server/homeserver.nix b/hosts/server/homeserver.nix deleted file mode 100644 index 30c1af5..0000000 --- a/hosts/server/homeserver.nix +++ /dev/null @@ -1,122 +0,0 @@ -# 🌐 Homeserver Core Environment Secrets & Systemd service configuration -# This NixOS module manages secrets and the systemd lifecycle for the core homeserver stack. - -{ 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"; - }; - }; - - renderUser = username: user: " " + username + ":\n" - + " displayname: \"" + user.displayName + "\"\n" - + " password: '" + user.passwordPlaceholder + "'\n" - + " email: \"" + user.email + "\"\n" - + " groups:\n" - + (lib.concatMapStringsSep "\n" (g: " - " + g) user.groups); - - renderedUsersYaml = "users:\n" + (lib.concatStringsSep "\n\n" (lib.mapAttrsToList renderUser autheliaUsers)) + "\n"; -in -{ - # 1. Load the encrypted secrets file - sops.defaultSopsFile = ./secrets.yaml; - sops.defaultSopsFormat = "yaml"; - - # Define the keys to decrypt from secrets.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"; }); - - # 2. Generate the unified environment file at runtime in /run/secrets/homeserver.env - 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"; - }; - }; - - # Generate the declarative Authelia user database file at runtime in /run/secrets/users.yml - sops.templates."users.yml" = { - owner = "kiskaadee"; - content = renderedUsersYaml; - }; - - # 3. Define the declarative systemd service to manage the homeserver container stack - systemd.services.homeserver-core = { - description = "Homeserver Core Stack (Traefik, Authelia, Homepage, etc.)"; - after = [ "network-online.target" "docker.service" ]; - wants = [ "network-online.target" ]; - wantedBy = [ "multi-user.target" ]; - - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - WorkingDirectory = "/home/kiskaadee/Core"; - ExecStart = "${pkgs.docker-compose}/bin/docker-compose --env-file ${config.sops.templates."homeserver.env".path} up -d --remove-orphans"; - ExecStop = "${pkgs.docker-compose}/bin/docker-compose down"; - }; - }; - - # 4. Declarative Dynamic GitOps Webhook Service (Internal Port 9000) - systemd.services.homelab-gitops = { - description = "Dynamic Homelab GitOps Webhook Dispatcher"; - after = [ "network-online.target" "docker.service" ]; - wants = [ "network-online.target" ]; - wantedBy = [ "multi-user.target" ]; - - path = with pkgs; [ git docker docker-compose python3 coreutils bash openssh ]; - - serviceConfig = { - Type = "simple"; - User = "kiskaadee"; - WorkingDirectory = "/home/kiskaadee/Core"; - ExecStart = "${pkgs.webhook}/bin/webhook -hooks ${pkgs.writeText "hooks.json" (builtins.toJSON [ - { - id = "deploy"; - execute-command = "/home/kiskaadee/Core/scripts/gitops_dispatcher.py"; - pass-arguments-to-command = [ - { source = "entire-payload"; } - ]; - command-working-directory = "/home/kiskaadee/Core"; - response-message = "Deployment payload dispatched successfully."; - } - ])} -port 9000 -verbose"; - Restart = "on-failure"; - RestartSec = "5s"; - }; - }; - - # 5. Open ports in the firewall for Traefik, Gitea SSH, and GitOps Webhook Receiver - networking.firewall.allowedTCPPorts = [ 80 443 2223 9000 ]; -} diff --git a/hosts/server/monitor.py b/hosts/server/monitor.py deleted file mode 100644 index e396ef2..0000000 --- a/hosts/server/monitor.py +++ /dev/null @@ -1,204 +0,0 @@ -""" -Dynu DDNS Smart IP Change Monitor and Updater. - -This script determines the current public IPv4 address by querying multiple -external resolvers sequentially. It compares the discovered IP against the last -recorded successful IP in a local history log. If a change is detected, it -triggers the `ddclient.service` on-demand to perform the DNS record update. - -This local-first state verification prevents making redundant API requests to -the DNS provider, avoiding rate-limiting, IP bans, or API abuse flags. -""" - -import json -import os -import re -import subprocess -import sys -import urllib.error -import urllib.request -from datetime import datetime, timezone - -# History file location storing the transition log of public IP states. -# Defaults to a state directory managed securely by the systemd service unit. -HISTORY_FILE = os.environ.get("HISTORY_FILE", "/var/lib/dynu/ip_history.jsonl") - -# Fallback sequence of external services to discover the public WAN IP. -PROVIDERS = [ - "https://api.ipify.org", - "https://ifconfig.me/ip", - "https://icanhazip.com", - "https://wtfismyip.com/text" -] - - -def is_valid_public_ipv4(ip): - """ - Validates that a string is a properly formatted public IPv4 address. - - This function excludes standard private, loopback, link-local, and CGNAT - blocks to avoid recording temporary, local, or invalid network states. - """ - match = re.match(r"^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$", ip) - if not match: - return False - octets = [int(x) for x in match.groups()] - if any(x > 255 for x in octets): - return False - a, b, _c, _d = octets - - # RFC 1918 Private ranges: 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12 - if a == 10: - return False - if a == 192 and b == 168: - return False - if a == 172 and 16 <= b <= 31: - return False - - # Carrier-Grade NAT (CGNAT) RFC 6598: 100.64.0.0/10 - if a == 100 and 64 <= b <= 127: - return False - - # Loopback address range: 127.0.0.0/8 - if a == 127: - return False - - # Link-local addresses: 169.254.0.0/16 - return not (a == 169 and b == 254) - - -def get_public_ip(): - """ - Queries public IP providers until a valid public IPv4 is returned. - - Returns: - str: The validated public IP string, or None if all providers fail. - """ - errors = [] - for provider in PROVIDERS: - try: - req = urllib.request.Request( - provider, - headers={ - 'User-Agent': 'Mozilla/5.0 (NixOS WAN Monitor)' - } - ) - # Fetch with 5s timeout to avoid hanging the systemd service - with urllib.request.urlopen(req, timeout=5) as response: - ip = response.read().decode('utf-8').strip() - if is_valid_public_ipv4(ip): - return ip - else: - errors.append(f"{provider}: invalid public IPv4 '{ip}'") - except (urllib.error.URLError, OSError, ValueError) as e: - errors.append(f"{provider}: {e!s}") - - print( - f"Error: All IP discovery providers failed. Details: {errors}", - file=sys.stderr - ) - return None - - -def get_last_recorded_ip(): - """ - Reads the history log to locate the last successful IP address. - - Returns: - str: The last successfully updated IP, or None if no log exists yet. - """ - if not os.path.exists(HISTORY_FILE): - return None - try: - with open(HISTORY_FILE, "r") as f: - lines = f.readlines() - if not lines: - return None - # Search backwards to find the most recent successful transition - for line in reversed(lines): - try: - entry = json.loads(line) - if entry.get("status") == "success": - return entry.get("ip") - except json.JSONDecodeError: - continue - except OSError as e: - print(f"Warning: Failed to read history file: {e}", file=sys.stderr) - return None - - -def record_ip(ip, status, details=None): - """ - Appends a new event entry into the JSONLines history registry. - """ - os.makedirs(os.path.dirname(HISTORY_FILE), exist_ok=True) - entry = { - "timestamp": datetime.now(tz=timezone.utc).isoformat(), - "ip": ip, - "status": status - } - if details: - entry["details"] = details - try: - with open(HISTORY_FILE, "a") as f: - f.write(json.dumps(entry) + "\n") - except OSError as e: - print(f"Error: Failed to write to history file: {e}", file=sys.stderr) - - -def trigger_ddclient(): - """ - Invokes the systemd service unit for `ddclient` on-demand. - - Returns: - tuple: (bool, str) representing (success_boolean, error_details_string) - """ - try: - # Run ddclient as a one-shot activation via systemd to perform API call - res = subprocess.run( - ["systemctl", "start", "ddclient.service"], - capture_output=True, - text=True, - check=False, - ) - if res.returncode == 0: - return True, None - else: - err_msg = ( - f"systemctl exited with {res.returncode}: " - f"{res.stderr.strip()}" - ) - return False, err_msg - except (OSError, subprocess.SubprocessError) as e: - return False, str(e) - - -def main(): - """ - Orchestrator logic for DDNS state management. - """ - current_ip = get_public_ip() - if not current_ip: - sys.exit(1) - - last_ip = get_last_recorded_ip() - if current_ip == last_ip: - # IP matches last recorded working IP; do nothing to conserve quota - sys.exit(0) - - print(f"IP rotation detected! Old: {last_ip}, New: {current_ip}") - - # Trigger ddclient to perform the DNS record update - success, error_msg = trigger_ddclient() - if success: - print("Dynu DDNS update via ddclient triggered successfully.") - record_ip(current_ip, "success") - else: - err_msg = f"Error: Failed to trigger ddclient update: {error_msg}" - print(err_msg, file=sys.stderr) - record_ip(current_ip, "failed_update", details=error_msg) - sys.exit(1) - - -if __name__ == "__main__": - main() diff --git a/hosts/server/secrets.yaml b/hosts/server/secrets.yaml deleted file mode 100644 index 0dff655..0000000 --- a/hosts/server/secrets.yaml +++ /dev/null @@ -1,59 +0,0 @@ -authelia: - session_secret: ENC[AES256_GCM,data:TmujJ9I51cQrzRMcvFkhFnG1CICebOM332NUTwXSj33niFdrV3xfHWR3h83/WcNk+M/i0AjcFtZ7fRYNW5VV2766p2BAfsaihSN8yQPrsQRNPyQKvSgij2xWL/B5I1a7NQGRh7xX6yiQYqaPzrwKnlcv8kmKp8aFPlkdmWYOCPc=,iv:Pcj6yu1MvZBJ0VPfuEO4RiTiE5SOULI/jGAz8dy/X4g=,tag:firz8cjG9HP8HEgKM4c53Q==,type:str] - storage_encryption_key: ENC[AES256_GCM,data:ycsfhh9cAsIbSEVaPvCH8ky0t+zayLtI6NVLcb+v2HIJMYSqD8eXu7JCvp5E0u1PkGTyaAoatXtcdChb2ABEiUNeqlOPXciF4ED+4yFAXftfMKy/M4AAYgp9jBA1v8JsE5mfBEOfmnBWV5SwGSaHBcQgUoJubKqcODPfHOmkKwg=,iv:1bgvgcClI+2VG6wXa5el5jfOrkCx+bj33VYiFdA1gas=,tag:0n7nJaZomtllFzSH2+Z8yw==,type:str] - jwt_secret: ENC[AES256_GCM,data:C1FnoRi49PSaIZNp+SAS6Q5+odYwai75OR4UfvGx1Jk8wb4nVDUASpaOgm7ZFJysTX4WjuQi99PYyG5GshlHoJ5dVbLSFpEq7MSSiY8tZA2PqnHmIODNYARfFw6lB7udPjz8ANyU2UcrnwRKXnDD+T2Pa1uL9joW5rg7vWZlRks=,iv:IDZ2/wbmCPoR14b1imZrTJR5LuQp6V91tcZ/Z5Znl0w=,tag:d0UQ49QcEqgD+PCIBoOJ7Q==,type:str] - users: - kiskaadee: - password_hash: ENC[AES256_GCM,data:/Sz5Z5YH2+ksjLw60/PkL/P3PJgYR4FEHV3CFlLShP1RASpJ+b3c8ywXlkUEKqNacfIkgaZsYsIpeNwApEYFt+4QLpDOPrX1wyF1sFnD5bDaeKJkV7wVgDO18D6LWJPX4A==,iv:TivrHulGSMtqDtWYyFHL36MHzLCymmceH0ptzF+dvBk=,tag:WQce4BeqHg4jS30gHSqZMw==,type:str] - misa: - password_hash: ENC[AES256_GCM,data:pYNPWzT1m+uYjrz8ZMWROz+q7qcp6+TaYsVmXT5899ItWVX5S2wF0cz08uTu3fveF3iHp27IWOwd3TBpmc0xmkYyeY31LCCMXrtRhuqVzfshVy29jHI/QNgeH4T3kU6UVg==,iv:7kS2+OiUWlApeReOunbJ1i4nYFpl9dcFryjTIOLUEe0=,tag:JYiV8/NJSzetvyzAzWMnWg==,type:str] - valenvg: - password_hash: ENC[AES256_GCM,data:GYf6/rvz2WK5w2T0usPbAP8LQY8EqOKPcFQJrHVEjjN/dVaQqg9IMm5cA0+dyYuJpW/+bdALdIDLjSYIFF3L7KgLij0jiIJhJxxV+7e1HIto+WhoavKBNfv5OREmW9cM7Q==,iv:zZeAL5v0YOHGca8ZebQirucUA7UtR5gnucKVfNJSzTc=,tag:cgm1qBzQKmpD5ttZKWHHjw==,type:str] -traefik: - acme_email: ENC[AES256_GCM,data:U2IPYioGlfgSpfZy5E+2+VM0iXQ=,iv:zQ5Txq9H7mF7GcaZfyPPjSQFKa0736/DI7Y4XARMFqM=,tag:7Q4YN9OPA1rRVpXuapewQQ==,type:str] -dynu: - api_key: ENC[AES256_GCM,data:f4dAZjCplklE08kll1yGuYYYDKKTVEwvSL0d6fM9K+g=,iv:xjR/5lNfRXxTPWJ+WM+/qzZGWTMf7iNua/FoGwTYXTg=,tag:PuZZWUJ+WoZVcWDVKwxM9g==,type:str] - user: ENC[AES256_GCM,data:RdKa9JmnllYQ,iv:2xW8vvzWvKp1rEV8G9fp+Jae38Wr3+lHAQ15htP3Sjs=,tag:tts/zHJqoBoK6vVnt7ho3A==,type:str] - domain: ENC[AES256_GCM,data:Towv0BFeoXhIaP/pzA==,iv:yzMv6t/Z3NEiE7t5u9lVA5siy5APsWHpdPvqYI8EmQU=,tag:8YTWCtA/sshOOLaHOMH+nw==,type:str] - password: ENC[AES256_GCM,data:oF8O3S5n2fuSFpgu8RVa0SwS4U4yYl/I7EMRTt640SQ=,iv:x0npliyj1cZocDce3hofvJYuQbXGOu+EU04GwR48cD4=,tag:ddNmxWp1uL2POW5mXdqfVQ==,type:str] -postgres: - user: ENC[AES256_GCM,data:ifJ3KSf6E6EQ,iv:Ryu/fce3mMRItSoRmwC6/HFWBebT3UXAwccfKMM+B1s=,tag:53ct7ZiF6UmklvPw0oeajw==,type:str] - password: ENC[AES256_GCM,data:wbLdF/1RZwL6fY/IXJdT,iv:5Xk0B0qtDh0hoAKDtwpzwKdhQHhsLvlsnHiwMJP9VeE=,tag:BGlHuEHp0YucoJopg1rzBQ==,type:str] - db: ENC[AES256_GCM,data:zBgGgioMBlVhUw==,iv:4X86eXVILuf98st1po5ipvEUDE2UG9jEPOso7CGR48k=,tag:ZXng+qF6/PUjP6D+Y/AC6w==,type:str] -mongo: - root_username: ENC[AES256_GCM,data:ImHe4j6Botsc,iv:dEXIA746kuh9//SLQO+RfDxIpObMMPZ2wfjgiwouS9Q=,tag:sD2uZKtwgbOgnKffv7DD4g==,type:str] - root_password: ENC[AES256_GCM,data:hETEsUQ+EMnV2rN+ZoOd,iv:8Zt1RLAOm6CCt8W/ie1IC+3PXs2qGzcLCTGTjNxWkI0=,tag:Q9iowfgg5JjaMekRCdUizA==,type:str] -ollama: - api_key: ENC[AES256_GCM,data:D2KSzK6WP9Xstx2l5A3I,iv:DbEnYwhrcVMWPipwfGQ1cvUOhZuB4Q64vCDcutb24Nw=,tag:V4KIOKM7in1i8rTNDLIzZA==,type:str] -gitea: - runner_token: ENC[AES256_GCM,data:aFk3l8rah+lj5iNVDT2RXF2Ie5aqwcBUi9UPjsWv0aRM+i97kYtybA==,iv:pkJpmgt5goEHotx3sCbw6jBy8detOwhaE77yO+NTQ5g=,tag:nLVNSwH1bfAq+gduwgRJuQ==,type:str] -learning: - turso_db_url: ENC[AES256_GCM,data:DveoFqwgimUHJv48Sozh2XqT7Ha9DeX3VAslT7SrqSVHab5RPlEujF+eIHyvAUiE81A=,iv:PgWZMty5hBUsmRJW85xilcvIMO/j54WY249Jsw6LfiM=,tag:osYPQc/Q9734L0FUo9hOCQ==,type:str] - turso_auth_token: ENC[AES256_GCM,data:lRdFDrsKWv90QSvNvYjqp07jU7DcWfrNlpg0bVljbOizixgstnFF70jjafN/QK4kId0nSJTx1DFlsTy7vG8+M00+UYl8SWDW7uTq/Ll1UGkaYinkhKFLNKUHXg5SUTfH3UA+nPBlZSNoZe6kdBgrt35TuV78lI/eUkxpVOI3D/70B6BP2DR4zmb70GztcxUY3e7xkGtVkCbyJd+BY8YOep/MgYvYg512LjESFwL/rJtJBYnh8XtQMcIDVDxRO5hGiy66xpXE4IC3wTPr4+/ZWS00H6VQccUcL0QVEVBkq+c9iytUlcTzTa7FkcYyiBnnlp1XGsk7OaE0E/VESaSaiUpQ6YQY7AllPTmhHs0uo+3KMbttjFLr,iv:OoPEVzYsmbdS2Po8C/lxo53UWxzA3gbPkrP3HZLB6Jo=,tag:1YKmvjWf5o3XZo40BZ6IWw==,type:str] -system: - gh_repo_token: ENC[AES256_GCM,data:QAsmG5iQQJ4TUhtrIbkq3wlw4JWbj2tFX6u2BbdB4werXfWyak8sdw==,iv:orGtlDW71QHDRSTED1xNfdOggF61hHsbGztWOUSdY+Y=,tag:4xe1I+hNjxWLc16BW4yTLA==,type:str] - pdf_decrypt_password: ENC[AES256_GCM,data:n3XTANd+PbejUw==,iv:y2VIabyv/DfTgztbjS6M/xIfRNKOL+U+r3eXsal32OQ=,tag:oFpXg2E9dDM5dwkjSZkLgw==,type:str] -sops: - age: - - enc: | - -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBkeEdCUncxWS9CUDJmbFow - THJpbE9tSmtZcURMcXoyYnd5eHlrcVhNdURrCjJBSFNBTnVpRE9SdkkyWXAwRFFo - Um5UUDFTVVl2ZDBBT1hNMHdQZ0RLYjAKLS0tIDUrS3g2a0QralpuN2hiMHRkRVN6 - MUdvK0FTemxZeGpPTUJiRkcrdWFCL2cKm7EEdZpYdoqQHgTNN1NkR+8xBzYj3ayx - 2zp9GAJgiEz+XaRkVi52JeDkEr2NuZR8WvcF0hvDMuFBslV6N9JZ+g== - -----END AGE ENCRYPTED FILE----- - recipient: age18q3lr2z4yeg2f86my42ym4hx0dvcwgjshmchyhdkgwvf4k37dsyq3mcjse - - enc: | - -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAwWjFNOERYbTg4RWQxS3ox - cDFycmFkaFRvaHg2aXQzTlk4QTVCYVc1ejNzCjR0bUJEc3ZiaHo2V21xYTlsMGgv - ajNPelFUT3JucFRFaDBkeGtVS0trdFEKLS0tIEVtdFZsUHZKNkFlL0NHUnF2UG5s - eEpDb1VLZ2dCVERQUXl5enhZYlZaR1UK8xnixMh5Xk5SkeHj30wPb5wbsKeWxh80 - yvBksdjSVYITIR6E6sZJx4ujk8Gmu64UsHwxtASMZRQ60sUjLCo8+A== - -----END AGE ENCRYPTED FILE----- - recipient: age1pln9sxy5j93lklqklfwp3qepx7x4cs4y2w63n9y3ykt68qgra5ysqleesg - lastmodified: "2026-09-11T19:59:23Z" - mac: ENC[AES256_GCM,data:BcBncbSLf5CdYQxLn5THA6aMyxqipHpTwTgPOSZXf4B8PwO7yH4J7mL/sKEZ08448nAUaOABOrgFHoLlvVzGrUVJegRC/G9OgFQT8A4v1Dkq0yx0VSplMtf2q4ylyTjLHQb5bd4r4OzfBNFjmruyrZHS3ydxn8gfbgOft50w2vM=,iv:dTzR9j4crCaaG/wjMRxiGjVZMyBNOCN+qKlSN34m0m8=,tag:D8go58ulc1nu5biQWq1TpA==,type:str] - unencrypted_suffix: _unencrypted - version: 3.13.3 diff --git a/hosts/server/traefik-deployments.nix b/hosts/server/traefik-deployments.nix deleted file mode 100644 index 986a3fc..0000000 --- a/hosts/server/traefik-deployments.nix +++ /dev/null @@ -1,98 +0,0 @@ -# 🌐 Traefik Deployments Environment Secrets configuration -# This NixOS module manages secrets and environment variables for the unified apps in /traefik-deployments - -{ config, lib, pkgs, ... }: - -{ - # Load the encrypted secrets file - sops.defaultSopsFile = ./secrets.yaml; - sops.defaultSopsFormat = "yaml"; - - # Define the keys to decrypt from secrets.yaml (avoiding repeating the owner boilerplate) - 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"; }); - - # Generate the unified environment file at runtime in /run/secrets/traefik-deployments.env - sops.templates."traefik-deployments.env" = { - owner = "kiskaadee"; - content = lib.generators.toKeyValue {} { - # --- Core / Infrastructure Settings --- - PROXY_NETWORK = "proxy-net"; - CERT_RESOLVER = "myresolver"; - DOMAIN_SUFFIX = "roadtotech.me"; - - # --- Dashboard & Landing --- - DASHBOARD_DOMAIN = "dashboard.roadtotech.me"; - LANDING_DOMAIN = "roadtotech.me"; - - # --- Docs --- - DOCS_DOMAIN = "docs.roadtotech.me"; - DOCS_PROJECT_PATH = "/home/kiskaadee/Brain"; - - # --- Excalidraw --- - EXCALIDRAW_DOMAIN = "excalidraw.roadtotech.me"; - - # --- Gitea --- - GITEA_DOMAIN = "gitea.roadtotech.me"; - GITEA_SSH_DOMAIN = "gitea.roadtotech.me"; - GITEA_SSH_PORT = "2223"; - GITEA_AUTH_MIDDLEWARE = "https-redirect@docker"; - GITEA_RUNNER_TOKEN = config.sops.placeholder."gitea/runner_token"; - # --- Jellyfin --- - JELLYFIN_SERVICE_NAME = "jellyfin"; - JELLYFIN_CONTAINER_NAME = "jellyfin"; - JELLYFIN_IMAGE_TAG = "latest"; - JELLYFIN_DOMAIN = "jellyfin.roadtotech.me"; - JELLYFIN_TZ = "UTC"; - JELLYFIN_PUID = "1000"; - JELLYFIN_PGID = "1000"; - JELLYFIN_MEDIA_PATH = "/media"; - JELLYFIN_HTTP_ENTRYPOINT = "web"; - JELLYFIN_HTTPS_ENTRYPOINT = "websecure"; - JELLYFIN_RATE_LIMIT_AVG = "100"; - JELLYFIN_RATE_LIMIT_BURST = "50"; - - # --- Learning Dashboard --- - LEARNING_SERVICE_NAME = "learning-hub"; - LEARNING_DOMAIN = "learning.roadtotech.me"; - LEARNING_APP_PORT = "8000"; - LEARNING_SOCKET_PROXY_NETWORK = "socket-net"; - LEARNING_DOCKER_HOST = "tcp://socket-proxy:2375"; - TURSO_DATABASE_URL = config.sops.placeholder."learning/turso_db_url"; - TURSO_AUTH_TOKEN = config.sops.placeholder."learning/turso_auth_token"; - - # --- Mermaid --- - MERMAID_DOMAIN = "mermaid.roadtotech.me"; - MERMAID_SERVICE_NAME = "mermaid"; - - # --- Minecraft --- - MINECRAFT_DOMAIN = "minecraft.roadtotech.me"; - - # --- MongoDB --- - MONGO_ROOT_USERNAME = config.sops.placeholder."mongo/root_username"; - MONGO_ROOT_PASSWORD = config.sops.placeholder."mongo/root_password"; - MONGO_DOMAIN = "mongodb.roadtotech.me"; - - # --- PostgreSQL --- - POSTGRES_USER = config.sops.placeholder."postgres/user"; - POSTGRES_PASSWORD = config.sops.placeholder."postgres/password"; - POSTGRES_DB = config.sops.placeholder."postgres/db"; - POSTGRES_DOMAIN = "pgsql.roadtotech.me"; - - # --- Ollama --- - OLLAMA_DOMAIN = "ollama.roadtotech.me"; - OLLAMA_API_KEY = config.sops.placeholder."ollama/api_key"; - OLLAMA_REPLICAS = "1"; - OLLAMA_DATA_VOLUME = "ollama_data"; - }; - }; -} diff --git a/modules/system/base.nix b/modules/system/base.nix deleted file mode 100644 index 4bd4d5e..0000000 --- a/modules/system/base.nix +++ /dev/null @@ -1,103 +0,0 @@ -# ⚙️ Hardware-Agnostic Base System Configuration -# This file contains common system configurations shared by all machines (desktop, laptop). - -{ pkgs, inputs, ... }: - -{ - # Pin system nixpkgs flake registry to the flake input to prevent ad-hoc CLI queries to GitHub - nix.registry.nixpkgs.flake = inputs.nixpkgs; - - # Regional and Language settings - time.timeZone = "America/Bogota"; - i18n.defaultLocale = "en_US.UTF-8"; - - # Allow installation of unfree packages (e.g., Obsidian) - nixpkgs.config.allowUnfree = true; - - # Enable network management daemon - networking.networkmanager.enable = true; - - # Enable virtualisation / Docker container daemon - virtualisation.docker.enable = true; - - # Sound daemon configuration using modern Pipewire backend - services.pipewire = { - enable = true; - pulse.enable = true; # Enable legacy PulseAudio emulation wrapper - }; - - # 🖨️ Printing & Scanning configuration (with Epson drivers & Avahi network discovery) - services.printing = { - enable = true; - drivers = with pkgs; [ - epson-escpr - epson-escpr2 - gutenprint - gutenprintBin - ]; - }; - - # Enable mDNS / Zeroconf discovery for Wi-Fi printers - services.avahi = { - enable = true; - nssmdns4 = true; - openFirewall = true; - }; - - # SANE scanner support (includes Epson scanner backend) - hardware.sane = { - enable = true; - extraBackends = [ pkgs.epsonscan2 ]; - }; - - # System-wide packages - environment.systemPackages = with pkgs; [ - cups-pk-helper - system-config-printer - simple-scan - rclone - sops - age - ]; - - # SSH daemon settings for secure remote command execution - services.openssh = { - enable = true; - ports = [ 22 ]; - settings.PermitRootLogin = "no"; # Security: disable root ssh login - }; - - # 📶 Bluetooth Configuration - hardware.bluetooth = { - enable = true; - powerOnBoot = true; # Automatically power on the Bluetooth adapter at boot - }; - services.blueman.enable = true; # Enable Blueman DBus/Applet service integrations - - # 🚪 Greetd base configuration - services.greetd = { - enable = true; - settings = { - default_session = { - user = "kiskaadee"; - }; - }; - }; - - # Clean boot configuration for the greeter - # Suppresses systemd diagnostic messages on tty1 so the greeter loads cleanly. - systemd.services.greetd.serviceConfig = { - Type = "idle"; - StandardInput = "tty"; - StandardOutput = "tty"; - StandardError = "journal"; - TTYReset = true; - TTYVHangup = true; - TTYVTDisallocate = true; - }; - - # Global environment variables - # NIXOS_OZONE_WL forces Electron / Chromium applications (like Discord or VSCode) - # to natively execute under Wayland instead of fallback XWayland. - environment.sessionVariables.NIXOS_OZONE_WL = "1"; -} diff --git a/modules/system/graphical.nix b/modules/system/graphical.nix deleted file mode 100644 index 54e7cff..0000000 --- a/modules/system/graphical.nix +++ /dev/null @@ -1,43 +0,0 @@ -# 🎨 Graphical Environment System Module -# Configures system-wide services and integrations for DankMaterialShell (DMS). - -{inputs, pkgs, ...}: - -{ - # Configure the DMS graphical helper/shell service daemon. - # DMS handles background management, panels, and notifications. - programs.dms-shell = { - enable = true; - - # Override standard nixpkgs package binary with the bleeding-edge flake output. - package = inputs.dms.packages.${pkgs.stdenv.hostPlatform.system}.default; - - # Run the DMS daemon as a Systemd user service. - # Automatically restarts the daemon whenever the NixOS configuration changes. - systemd.enable = true; - systemd.restartIfChanged = true; - - # DMS System Options - # Refer to documentation: https://danklinux.com/docs/dgop/ - enableSystemMonitoring = true; # Enables daemon hooks for gathering memory, CPU, and disk metrics - enableDynamicTheming = true; # Automatically applies system-wide material palettes to shells and apps - enableClipboardPaste = true; # Bridges terminal and Wayland clipboard buffers seamlessly - }; - - # 🚪 Dank Material Shell Greeter (dank-greeter + greetd) - # Uses niri as the compositor for rendering the login screen - programs.dms-greeter = { - enable = true; - compositor.name = "niri"; - configHome = "/home/kiskaadee"; - }; - - # 📅 DankCalendar Daemon & UI - # Provides calendar integration (Local, CalDAV, Google, Microsoft) for DMS - programs.dank-calendar = { - enable = true; - systemd.enable = true; - systemd.target = "graphical-session.target"; - }; -} - diff --git a/modules/user/apps.nix b/modules/user/apps.nix deleted file mode 100644 index 13bd650..0000000 --- a/modules/user/apps.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ inputs, pkgs, ... }: - -let - # Declaratively compile scripts as user utility packages using writeScriptBin - bundleProject = pkgs.writeScriptBin "bundle-project" (builtins.readFile ./scripts/bundle_project.py); - recordScript = pkgs.writeScriptBin "record" (builtins.readFile ./scripts/record.sh); -in -{ - home.packages = with pkgs; [ - # Custom Flake injections: Google Antigravity CLI helper - inputs.antigravity.packages.${pkgs.stdenv.hostPlatform.system}.google-antigravity-cli - - # Local CLI & Workflow utilities - bundleProject - recordScript - - # Media, Note-taking & Graphical Tools - mpv # Fast, scriptable, keyboard-driven CLI media player - gimp # GNU Image Manipulation Program for graphical assets - imagemagick # Software suite to create, edit, compose, or convert bitmap images - eyed3 # CLI tool and Python library for working with ID3 tags - nautilus # Clean, modern GTK4 graphical file manager for GNOME - yazi # Blazing fast console file manager written in Rust - obsidian # Markdown-based personal knowledge wiki and note-taking app - libreoffice # Comprehensive open-source office suite (Writer, Calc, Impress, Draw) - - # Cloud CLI, Git Forge & Database Management - tea # Gitea official command line client - google-cloud-sdk # GCP administration utilities - turso-cli # Management interface for Turso libSQL cloud databases - postgresql # PostgreSQL client utilities (psql, pg_dump) - pgcli # Command-line client for Postgres with auto-completion - wget # Standard network file downloader - zip # File archiving utility - unzip # Extraction utility for .zip files - unrar # Extraction utility for .rar files - rsync # Efficient incremental file transfer tool - aria2 # High-speed multi-protocol download utility - - # API Testing & Development - httpie # CLI alternative to curl for REST APIs - bruno # Open-source git-friendly GUI REST client - websocat # Command-line client for WebSockets (like netcat for ws://) - grpcurl # Command-line tool for interacting with gRPC servers - - # Network Diagnostics & Scanning - bind.dnsutils # DNS lookup utilities (dig, nslookup, nsupdate, delv) - openssh # OpenSSH client and connectivity tools - sshfs # FUSE-based filesystem client for mounting remote directories over SSH - nmap # Network exploration tool and security / port scanner - arp-scan # Address Resolution Protocol packet scanner - - # Python Tooling - ruff # Extremely fast Python linter and formatter - mypy # Static type checker for Python - - # Rust Tooling - cargo # Rust package manager - rustc # Rust compiler - rustfmt # Official Rust code formatter - clippy # Official Rust linter - rust-analyzer # Language server for IDE code intelligence - gcc # GNU Compiler Collection (provides cc linker) - - # Secrets Management - rbw # Unofficial command line client for Bitwarden - ]; -} diff --git a/modules/user/neovim.nix b/modules/user/neovim.nix deleted file mode 100644 index 8d72d56..0000000 --- a/modules/user/neovim.nix +++ /dev/null @@ -1,59 +0,0 @@ -# 🖋️ Neovim CLI & IDE Editor Configuration -# Shared across all host profiles (server, desktop, laptop). - -{ pkgs, ... }: - -{ - programs.neovim = { - enable = true; - defaultEditor = true; # Make neovim the default `$EDITOR` - viAlias = true; # Symlink `vi` to `nvim` - vimAlias = true; # Symlink `vim` to `nvim` - - ## Core Editor Settings (Lua-based) - initLua = builtins.readFile ./config/nvim/init.lua; - - ## Declarative Plugin Management - plugins = with pkgs.vimPlugins; [ - # Color scheme loaded dynamically - { - plugin = catppuccin-nvim; - type = "lua"; - config = builtins.readFile ./config/nvim/catppuccin.lua; - } - - # Advanced Syntax Highlighting for developer workflows (Python, Rust, Java, Nix, KDL) - (nvim-treesitter.withPlugins (p: with p; [ - python - rust - nix - lua - java - javascript - typescript - markdown - kdl - toml - bash - ])) - - # LSP Configuration & Language Servers - { - plugin = nvim-lspconfig; - type = "lua"; - } - - # DAP (Debug Adapter Protocol) - { - plugin = nvim-dap; - } - { - plugin = nvim-dap-ui; - } - ]; - }; - - # Declarative configuration files for Neovim (lsp.lua & dap.lua loaded dynamically via init.lua) - home.file.".config/nvim/lsp.lua".source = ./config/nvim/lsp.lua; - home.file.".config/nvim/dap.lua".source = ./config/nvim/dap.lua; -} diff --git a/modules/user/terminal.nix b/modules/user/terminal.nix deleted file mode 100644 index 95d771c..0000000 --- a/modules/user/terminal.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, ... }: - -{ - # Terminal Multiplexer (Tmux) - # Allows maintaining persistent shell sessions, window splitting, and tabs. - programs.tmux = { - enable = true; - extraConfig = builtins.readFile ./config/tmux.conf; - }; - - # Cross-Shell Prompt (Starship) - programs.starship = { - enable = true; - enableBashIntegration = true; # Mount prompt configuration inside Bash shells - settings = builtins.fromTOML (builtins.readFile ./config/starship.toml); - }; -} diff --git a/system/core.nix b/system/core.nix new file mode 100644 index 0000000..c45a8f8 --- /dev/null +++ b/system/core.nix @@ -0,0 +1,67 @@ +# ⚙️ Core System Configuration +# Foundational OS settings, bootloader, networking, users, and base system tools. + +{ pkgs, inputs, ... }: + +{ + # Nix settings & Flakes + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.registry.nixpkgs.flake = inputs.nixpkgs; + + # Allow installation of unfree packages + nixpkgs.config.allowUnfree = true; + + # EFI bootloader configuration + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Host identity & networking + networking.hostName = "laptop"; + networking.networkmanager.enable = true; + + # Regional and language settings + time.timeZone = "America/Bogota"; + i18n.defaultLocale = "en_US.UTF-8"; + + # Primary user account definition + users.users.kiskaadee = { + isNormalUser = true; + extraGroups = [ + "wheel" # Administrative access (sudo) + "docker" # Container management without sudo + "networkmanager" # Network configuration + "lp" # Printer management + "scanner" # Scanner access + ]; + }; + + # SSH daemon settings + services.openssh = { + enable = true; + ports = [ 22 ]; + settings.PermitRootLogin = "no"; + }; + + # Dynamic binary execution support (for unpatched binaries, language servers, VS Code server) + programs.nix-ld = { + enable = true; + libraries = with pkgs; [ + stdenv.cc.cc.lib + zlib + glib + ]; + }; + + # System-wide administrative tools + environment.systemPackages = with pkgs; [ + cups-pk-helper + system-config-printer + simple-scan + rclone + sops + age + ]; + + # Compatibility state version + system.stateVersion = "26.05"; +} diff --git a/system/default.nix b/system/default.nix new file mode 100644 index 0000000..f9055a5 --- /dev/null +++ b/system/default.nix @@ -0,0 +1,13 @@ +# 💻 Laptop System Configuration Entrypoint +# Composes the system modules for the mobile workstation. + +{ ... }: + +{ + imports = [ + ./hardware-configuration.nix + ./core.nix + ./hardware.nix + ./desktop.nix + ]; +} diff --git a/system/desktop.nix b/system/desktop.nix new file mode 100644 index 0000000..48db4c2 --- /dev/null +++ b/system/desktop.nix @@ -0,0 +1,74 @@ +# 🎨 System Desktop Environment & Graphical Stack +# Niri window manager, DankMaterialShell (DMS), greetd login, fonts, and Wayland session flags. + +{ pkgs, inputs, ... }: + +{ + # Graphical Compositor (Niri window manager) + programs.niri.enable = true; + + # DankMaterialShell (DMS) graphical helper/shell daemon + programs.dms-shell = { + enable = true; + package = inputs.dms.packages.${pkgs.stdenv.hostPlatform.system}.default; + systemd.enable = true; + systemd.restartIfChanged = true; + enableSystemMonitoring = true; + enableDynamicTheming = true; + enableClipboardPaste = true; + }; + + # DMS Greeter (dank-greeter + greetd) + programs.dms-greeter = { + enable = true; + compositor.name = "niri"; + configHome = "/home/kiskaadee"; + }; + + # DankCalendar Daemon & UI + programs.dank-calendar = { + enable = true; + systemd.enable = true; + systemd.target = "graphical-session.target"; + }; + + # Greetd base service configuration + services.greetd = { + enable = true; + settings = { + default_session = { + user = "kiskaadee"; + }; + }; + }; + + # Clean boot configuration for the greeter (suppresses tty1 diagnostic messages) + systemd.services.greetd.serviceConfig = { + Type = "idle"; + StandardInput = "tty"; + StandardOutput = "tty"; + StandardError = "journal"; + TTYReset = true; + TTYVHangup = true; + TTYVTDisallocate = true; + }; + + # System-wide typography & fonts + fonts.packages = with pkgs; [ + inter + nerd-fonts.fira-code + nerd-fonts.jetbrains-mono + nerd-fonts.roboto-mono + ]; + + fonts.fontconfig = { + enable = true; + defaultFonts = { + monospace = [ "Fira Code" ]; + sansSerif = [ "Inter" ]; + }; + }; + + # Wayland execution flags for Electron / Chromium applications + environment.sessionVariables.NIXOS_OZONE_WL = "1"; +} diff --git a/hosts/laptop/hardware-configuration.nix b/system/hardware-configuration.nix similarity index 100% rename from hosts/laptop/hardware-configuration.nix rename to system/hardware-configuration.nix diff --git a/system/hardware.nix b/system/hardware.nix new file mode 100644 index 0000000..e9667dc --- /dev/null +++ b/system/hardware.nix @@ -0,0 +1,53 @@ +# 🔋 Laptop Hardware, Power & Peripheral Management +# Manages audio (PipeWire), power daemons, Bluetooth, printing, scanning, and virtualization. + +{ pkgs, ... }: + +{ + # Sound daemon configuration (PipeWire backend with PulseAudio emulation) + services.pipewire = { + enable = true; + pulse.enable = true; + }; + + # 🔋 Laptop Power & Battery Management + services.power-profiles-daemon.enable = true; + services.upower.enable = true; + + # Backlight brightness control utility + environment.systemPackages = with pkgs; [ + brightnessctl + ]; + + # 📶 Bluetooth Configuration + hardware.bluetooth = { + enable = true; + powerOnBoot = true; + }; + services.blueman.enable = true; + + # 🖨️ Printing & Scanning (Epson drivers & Avahi network discovery) + services.printing = { + enable = true; + drivers = with pkgs; [ + epson-escpr + epson-escpr2 + gutenprint + gutenprintBin + ]; + }; + + services.avahi = { + enable = true; + nssmdns4 = true; + openFirewall = true; + }; + + hardware.sane = { + enable = true; + extraBackends = [ pkgs.epsonscan2 ]; + }; + + # 🐳 Virtualisation / Docker container daemon + virtualisation.docker.enable = true; +}