From 575db4b50ceb48aa40cd2d4169cb7f76af81525f Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Fri, 11 Sep 2026 12:19:49 -0500 Subject: [PATCH] refactor: decommission legacy desktop host derivation and docs - Prune nixosConfigurations.desktop from flake.nix - Delete hosts/desktop directory and legacy Hyprland/homelab configs - Update architecture.md, AGENTS.md, and README.md to 2-host topology (server + laptop) - Update procedural guides in docs/ to reference server and laptop hosts --- AGENTS.md | 26 +-- README.md | 25 +-- architecture.md | 48 +--- docs/antigravity.md | 9 +- docs/dynu-ip-monitor.md | 2 +- docs/package-and-secrets.md | 10 +- docs/secrets-management.md | 14 +- flake.nix | 28 --- hosts/desktop/config/hypr/dms/binds-user.lua | 14 -- hosts/desktop/config/hypr/dms/binds.lua | 172 --------------- hosts/desktop/config/hypr/dms/colors.lua | 27 --- hosts/desktop/config/hypr/dms/cursor.lua | 1 - hosts/desktop/config/hypr/dms/layout.lua | 13 -- hosts/desktop/config/hypr/dms/outputs.lua | 17 -- hosts/desktop/config/hypr/dms/windowrules.lua | 1 - hosts/desktop/config/hypr/hyprland.lua | 89 -------- hosts/desktop/config/hypr/scripts/record.sh | 148 ------------- hosts/desktop/configuration.nix | 97 --------- hosts/desktop/ddclient.conf | 12 - hosts/desktop/dynu.nix | 92 -------- hosts/desktop/hardware-configuration.nix | 41 ---- hosts/desktop/home.nix | 21 -- hosts/desktop/homeserver.nix | 68 ------ hosts/desktop/monitor.py | 205 ------------------ hosts/desktop/secrets.yaml | 42 ---- hosts/desktop/traefik-deployments.nix | 97 --------- 26 files changed, 52 insertions(+), 1267 deletions(-) delete mode 100644 hosts/desktop/config/hypr/dms/binds-user.lua delete mode 100644 hosts/desktop/config/hypr/dms/binds.lua delete mode 100644 hosts/desktop/config/hypr/dms/colors.lua delete mode 100644 hosts/desktop/config/hypr/dms/cursor.lua delete mode 100644 hosts/desktop/config/hypr/dms/layout.lua delete mode 100644 hosts/desktop/config/hypr/dms/outputs.lua delete mode 100644 hosts/desktop/config/hypr/dms/windowrules.lua delete mode 100644 hosts/desktop/config/hypr/hyprland.lua delete mode 100755 hosts/desktop/config/hypr/scripts/record.sh delete mode 100644 hosts/desktop/configuration.nix delete mode 100644 hosts/desktop/ddclient.conf delete mode 100644 hosts/desktop/dynu.nix delete mode 100644 hosts/desktop/hardware-configuration.nix delete mode 100644 hosts/desktop/home.nix delete mode 100644 hosts/desktop/homeserver.nix delete mode 100644 hosts/desktop/monitor.py delete mode 100644 hosts/desktop/secrets.yaml delete mode 100644 hosts/desktop/traefik-deployments.nix diff --git a/AGENTS.md b/AGENTS.md index 4a2ca5e..0fa81f3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ ## Mission & Purpose -This repository manages the declarative NixOS and Home Manager configurations for `desktop` and `laptop` hosts. +This repository manages the declarative NixOS and Home Manager configurations for `server` and `laptop` hosts. 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,8 +37,8 @@ Repository # Validate flake metadata, inputs, and derivations nix flake check -# Build desktop host dryly (evaluates configuration without switching) -nix build .#nixosConfigurations.desktop.config.system.build.toplevel --no-link +# Build server host dryly (evaluates configuration without switching) +nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link # Build laptop host dryly nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link @@ -73,12 +73,12 @@ nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link ### 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., Hyprland screen recording utilities on desktop). +- **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. -### 5. Host Isolation & Desktop Specialisation -- Keep machine-specific homelab infrastructure (`homeserver.nix`, `traefik-deployments.nix`, `dynu.nix`) under `hosts/desktop/`. Never import them into `hosts/laptop/`. -- Protect the desktop `specialisation.server`. Any changes to graphical or audio stacks must preserve the headless server boot profile. +### 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. ### 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. @@ -102,8 +102,8 @@ 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 & Desktop | `modules/system/*`, greetd/display manager, firewall rules, user groups, new flake inputs. | **Autonomous**: Agent plans, edits, and validates via `nix flake check` + builds **both** `desktop` and `laptop`. | -| **HIGH** | Core & Infrastructure | Bootloader, filesystems, SOPS keys/secrets setup, `specialisation.server`, Traefik, Docker networking. | **Stop & Wait**: Agent must present the plan and **wait for user approval before editing**. | +| **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**. | | **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. | --- @@ -156,11 +156,11 @@ REQUEST | Modified Path | Affected Consumers | Required Build Validation | | :--- | :--- | :--- | -| `modules/system/*` | `desktop`, `laptop` | `nix flake check`
`nix build .#nixosConfigurations.desktop.config.system.build.toplevel --no-link`
`nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` | -| `modules/user/*` or `home.nix` | `desktop`, `laptop` | `nix flake check`
`nix build .#nixosConfigurations.desktop.config.system.build.toplevel --no-link`
`nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link` | -| `hosts/desktop/*` | `desktop` only | `nix flake check`
`nix build .#nixosConfigurations.desktop.config.system.build.toplevel --no-link` | +| `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` | `desktop`, `laptop` | `nix flake check` + build both hosts | +| `flake.nix` / `flake.lock` | `server`, `laptop` | `nix flake check` + build both hosts | --- diff --git a/README.md b/README.md index 1b9ad0f..a02c1ca 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# ❄️ Declarative NixOS Workstation Configuration +# ❄️ Declarative NixOS Workstation & Server 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 high-performance Wayland-native workstation environments across desktop and laptop profiles. +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. --- @@ -14,12 +14,10 @@ graph TD subgraph Hosts ["Host Profiles (hosts/)"] S["server
(Headless Homelab)"] - D["desktop
(Hyprland Workstation)"] L["laptop
(Niri Workstation)"] end B -->|"server"| S - B -->|"desktop"| D B -->|"laptop"| L subgraph Shared ["Shared Modules (modules/)"] @@ -28,17 +26,15 @@ graph TD end S --> SYS - D --> SYS L --> SYS S --> USER - D --> USER L --> USER ``` ### Directory Structure -* [flake.nix](flake.nix) — Main entry point defining dependencies (inputs) and system host targets (`server`, `desktop`, `laptop`). +* [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: @@ -49,9 +45,6 @@ graph TD * [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/desktop/](hosts/desktop/) — Legacy dual-mode workstation configuration: - * [configuration.nix](hosts/desktop/configuration.nix) — Main desktop NixOS config with specialisation. - * [home.nix](hosts/desktop/home.nix) — Hyprland desktop environment settings. * [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. @@ -76,7 +69,7 @@ graph TD ## 🛠️ Specialized Shell & Script Automation ### 1. Smart Dynamic DNS Monitor -The [monitor.py](hosts/desktop/monitor.py) daemon prevents redundant DNS updates by running a local-first check before contacting the provider API: +The [monitor.py](hosts/server/monitor.py) daemon prevents redundant DNS updates by running a local-first check before contacting the provider API: ```mermaid flowchart TD @@ -92,8 +85,8 @@ flowchart TD I -->|No| K[Write failed_update status & alert user] ``` -* **Script Location:** [hosts/desktop/monitor.py](hosts/desktop/monitor.py) -* **Systemd Integration:** Managed via [hosts/desktop/dynu.nix](hosts/desktop/dynu.nix) which triggers the monitor service every 30 minutes. +* **Script Location:** [hosts/server/monitor.py](hosts/server/monitor.py) +* **Systemd Integration:** Managed via [hosts/server/dynu.nix](hosts/server/dynu.nix) which triggers the monitor service every 30 minutes. ### 2. GPU-Accelerated Video Recording (`record`) * **Script Location:** [modules/user/scripts/record.sh](modules/user/scripts/record.sh) @@ -145,7 +138,7 @@ graph LR ### Adding and Modifying Secrets 1. Decrypt and open the host secrets file: ```bash - nix-shell -p sops --run "sops hosts/desktop/secrets.yaml" + 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. @@ -165,9 +158,9 @@ cd ~/Config ### 2. Deploy System Configurations Rebuild and switch to the profile matching your active target host machine: -* **Desktop Workstation:** +* **Server Host:** ```bash - sudo nixos-rebuild switch --flake ~/Config#desktop + sudo nixos-rebuild switch --flake ~/Config#server ``` * **Laptop Workstation:** ```bash diff --git a/architecture.md b/architecture.md index 40029da..525ed72 100644 --- a/architecture.md +++ b/architecture.md @@ -2,7 +2,7 @@ ## Core Principles -This repository manages a declarative NixOS configuration for multiple host targets (`server`, `desktop`, `laptop`) and shared user environments via Home Manager. +This repository manages a declarative NixOS configuration for multiple host targets (`server`, `laptop`) and shared user environments via Home Manager. 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. @@ -29,15 +29,6 @@ Config/ │ │ ├── homeserver.nix # Core homelab runtime services (Docker) │ │ └── traefik-deployments.nix # Traefik edge reverse proxy │ │ -│ ├── desktop/ -│ │ ├── configuration.nix # Desktop NixOS configuration & server specialization -│ │ ├── hardware-configuration.nix # Generated hardware configuration -│ │ ├── home.nix # Desktop-specific Home Manager profile (Hyprland dotfiles) -│ │ ├── secrets.yaml # Encrypted desktop secrets (SOPS) -│ │ ├── dynu.nix # Dynu DDNS update service -│ │ ├── homeserver.nix # Core homelab runtime services -│ │ └── traefik-deployments.nix # Traefik edge reverse proxy -│ │ │ └── laptop/ │ ├── configuration.nix # Laptop NixOS configuration (Niri compositor) │ ├── hardware-configuration.nix # Generated hardware configuration @@ -69,7 +60,6 @@ Config/ ```mermaid graph TD A[flake.nix] --> B[nixosConfigurations.server] - A --> C[nixosConfigurations.desktop] A --> D[nixosConfigurations.laptop] subgraph Server Host ["hosts/server/"] @@ -80,15 +70,6 @@ graph TD S_CONF --> S_HS[homeserver.nix] end - subgraph Desktop Host ["hosts/desktop/"] - C --> D_CONF[configuration.nix] - D_CONF --> D_HW[hardware-configuration.nix] - D_CONF --> D_DY[dynu.nix] - D_CONF --> D_TR[traefik-deployments.nix] - D_CONF --> D_HS[homeserver.nix] - D_CONF --> D_SP["specialisation.server"] - end - subgraph Laptop Host ["hosts/laptop/"] D --> L_CONF[configuration.nix] L_CONF --> L_HW[hardware-configuration.nix] @@ -96,20 +77,16 @@ graph TD subgraph Tier1 Shared CLI HM ["home.nix (All Hosts)"] B --> H[home.nix] - C --> H D --> H H --> U1[base.nix] H --> U2[neovim.nix] H --> U3[terminal.nix] end - subgraph Tier23 Workstation HM ["Workstation Extensions (Desktop & Laptop)"] - C --> DH[desktop/home.nix] + subgraph Tier23 Workstation HM ["Workstation Extensions (Laptop)"] D --> LH[laptop/home.nix] - DH --> UA[apps.nix] - DH --> UG[graphical.nix] - LH --> UA - LH --> UG + LH --> UA[apps.nix] + LH --> UG[graphical.nix] end ``` @@ -125,7 +102,7 @@ graph TD - `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`/`desktop`). + - Host infrastructure services (e.g., `homeserver.nix`, `dynu.nix`, `traefik-deployments.nix` on `server`). ### 3. `modules/system/` - **Role**: Reusable system configuration shared by multiple hosts. @@ -133,7 +110,7 @@ graph TD ### 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, desktop). Provides pure terminal tools (`tmux`, `starship`), editor, Git, and essential CLI diagnostics. + - **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. @@ -151,12 +128,12 @@ graph TD | **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., Hyprland `grimblast` on desktop). | +| **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/` or `hosts/desktop/` | Machine-specific homelab infrastructure, reverse proxy, and DDNS monitor. | +| **Homelab Services / DDNS** | `hosts/server/` | Machine-specific homelab infrastructure, reverse proxy, and DDNS monitor. | | **How-To Guides** | `docs/` | Operational procedures and maintenance workflows. | --- @@ -168,8 +145,7 @@ 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. **Desktop Server Specialisation Invariant**: `hosts/desktop/configuration.nix` defines `specialisation.server.configuration`. The server specialization must remain valid, bootable, and strictly headless (disabling display managers, PipeWire, Bluetooth, and desktop sleep targets). -5. **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. -6. **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. -7. **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`, `desktop`, and `laptop`). -8. **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. +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. diff --git a/docs/antigravity.md b/docs/antigravity.md index bbe285c..70c4ea4 100644 --- a/docs/antigravity.md +++ b/docs/antigravity.md @@ -105,7 +105,7 @@ Add `antigravity-nix` to your flake inputs in `flake.nix`. Ensure that you lock }; outputs = { self, nixpkgs, antigravity, ... }@inputs: { - # System outputs (e.g. nixosConfigurations.desktop) + # System outputs (e.g. nixosConfigurations.laptop) }; } ``` @@ -171,12 +171,13 @@ Since Google Antigravity and Chrome are proprietary, NixOS will refuse to build --- -### Step 4: Rebuild and Apply +## 🛠️ 4. Build and Switch + Run the rebuild switch script or alias for your machine target: ```bash # Rebuild the system -sudo nixos-rebuild switch --flake ~/Config#desktop +sudo nixos-rebuild switch --flake ~/Config#laptop ``` --- @@ -216,5 +217,5 @@ To update your local installation to the latest available package version: ``` 3. Reapply your configuration: ```bash - sudo nixos-rebuild switch --flake .#desktop + sudo nixos-rebuild switch --flake .#laptop ``` diff --git a/docs/dynu-ip-monitor.md b/docs/dynu-ip-monitor.md index 4e4d0ed..f40b93d 100644 --- a/docs/dynu-ip-monitor.md +++ b/docs/dynu-ip-monitor.md @@ -79,7 +79,7 @@ We resolve this by using systemd **`LoadCredential`**: ## ⏱️ Systemd Timers & Services Configuration -The updater is divided into two systemd units defined in [dynu.nix](file:///home/kiskaadee/Config/hosts/desktop/dynu.nix): +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. diff --git a/docs/package-and-secrets.md b/docs/package-and-secrets.md index 52f3499..1ed7416 100644 --- a/docs/package-and-secrets.md +++ b/docs/package-and-secrets.md @@ -37,10 +37,10 @@ Open [modules/user/apps.nix](file:///home/kiskaadee/Config/modules/user/apps.nix Verify the package builds correctly before switching system-wide: ```bash # Test build without applying -nix build .#nixosConfigurations.desktop.config.system.build.toplevel --no-link +nix build .#nixosConfigurations.laptop.config.system.build.toplevel --no-link # Apply configuration -sudo nixos-rebuild switch --flake .#desktop +sudo nixos-rebuild switch --flake .#laptop ``` --- @@ -50,9 +50,9 @@ sudo nixos-rebuild switch --flake .#desktop Sensitive credentials (like passwords, API keys, and environment variables) are managed using `sops-nix`. ### 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/desktop/secrets.yaml)): +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)): ```bash -nix-shell -p sops --run "sops hosts/desktop/secrets.yaml" +nix-shell -p sops --run "sops hosts/server/secrets.yaml" ``` Add your key-value pair under the YAML structure: ```yaml @@ -61,7 +61,7 @@ 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/desktop/dynu.nix](file:///home/kiskaadee/Config/hosts/desktop/dynu.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)): ```nix sops.secrets.my_new_api_key = { diff --git a/docs/secrets-management.md b/docs/secrets-management.md index 9afc17a..cbf2e45 100644 --- a/docs/secrets-management.md +++ b/docs/secrets-management.md @@ -39,16 +39,16 @@ Add both the user `age` public key and the host `age` public key to the [.sops.y ```yaml keys: - - &kiskaadee age1...your_user_age_key... - - &desktop age1...your_host_age_key... + - &server age1...your_server_age_key... + - &laptop age1...your_laptop_age_key... creation_rules: - - path_regex: hosts/desktop/secrets\.yaml$ + - path_regex: hosts/(server|laptop)/secrets\.yaml$ key_groups: - pgp: [] age: - - *kiskaadee - - *desktop + - *server + - *laptop ``` --- @@ -59,7 +59,7 @@ 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/desktop/secrets.yaml" +nix-shell -p sops --run "sops hosts/server/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. @@ -77,6 +77,6 @@ dynu_password: your-secret-password-or-hash 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/desktop/secrets.yaml`. +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`). 4. Services read these paths at startup, keeping secrets secure and decoupled from the world-readable `/nix/store`. diff --git a/flake.nix b/flake.nix index c7c6584..fede41f 100644 --- a/flake.nix +++ b/flake.nix @@ -92,34 +92,6 @@ ]; }; - # 🖥️ DESKTOP HOST (Legacy Dual-Mode Workstation) - # Workstation running Hyprland with specialisation fallback. - desktop = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { inherit inputs; }; # Pass flake inputs into submodules (e.g. system/base.nix) - modules = [ - ./hosts/desktop/hardware-configuration.nix # Autogenerated hardware/disk/CPU module - ./hosts/desktop/configuration.nix # Desktop environment / system package settings - inputs.sops-nix.nixosModules.sops # Import Sops module - inputs.dank-greeter.nixosModules.default # Import Dank Greeter module - inputs.dankcalendar.nixosModules.default # Import Dank Calendar module - - 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/desktop/home.nix - inputs.danksearch.homeModules.default - ]; - }; - } - ]; - }; - # 💻 LAPTOP HOST (Mobile Workstation) # Target laptop workstation running Niri window manager. laptop = nixpkgs.lib.nixosSystem { diff --git a/hosts/desktop/config/hypr/dms/binds-user.lua b/hosts/desktop/config/hypr/dms/binds-user.lua deleted file mode 100644 index 7687019..0000000 --- a/hosts/desktop/config/hypr/dms/binds-user.lua +++ /dev/null @@ -1,14 +0,0 @@ --- Optional per-user keybind overrides (managed by DMS). Loaded after default binds. - --- Screen screenshots (Copy to clipboard only, preventing saving files to directory) -hl.bind("SUPER + S", hl.dsp.exec_cmd("grimblast --notify copy area")) -hl.bind("SUPER + SHIFT + S", hl.dsp.exec_cmd("grimblast --notify copy active")) -hl.bind("SUPER + CTRL + S", hl.dsp.exec_cmd("grimblast --notify copy output")) -hl.bind("SUPER + SHIFT + CTRL + S", hl.dsp.exec_cmd("grimblast --notify copy screen")) - --- Screen video recordings (SUPER + W series) -hl.bind("SUPER + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh area")) -hl.bind("SUPER + SHIFT + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh output")) -hl.bind("SUPER + CTRL + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh area audio")) -hl.bind("SUPER + SHIFT + CTRL + W", hl.dsp.exec_cmd("~/.config/hypr/scripts/record.sh output audio")) - diff --git a/hosts/desktop/config/hypr/dms/binds.lua b/hosts/desktop/config/hypr/dms/binds.lua deleted file mode 100644 index 49b2144..0000000 --- a/hosts/desktop/config/hypr/dms/binds.lua +++ /dev/null @@ -1,172 +0,0 @@ --- DMS default keybinds (Hyprland 0.55+ Lua) - --- === Application Launchers === -hl.bind("SUPER + Return", hl.dsp.exec_cmd("alacritty")) -hl.bind("SUPER + B", hl.dsp.exec_cmd("firefox")) -hl.bind("SUPER + space", hl.dsp.exec_cmd("dms ipc call spotlight toggle")) -hl.bind("ALT + space", hl.dsp.exec_cmd("dms ipc call spotlight-bar toggle")) -hl.bind("SUPER + V", hl.dsp.exec_cmd("dms ipc call clipboard toggle")) -hl.bind("SUPER + M", hl.dsp.exec_cmd("dms ipc call processlist focusOrToggle")) -hl.bind("SUPER + comma", hl.dsp.exec_cmd("dms ipc call settings focusOrToggle")) -hl.bind("SUPER + N", hl.dsp.exec_cmd("dms ipc call notifications toggle")) -hl.bind("SUPER + SHIFT + N", hl.dsp.exec_cmd("dms ipc call notepad toggle")) -hl.bind("SUPER + Y", hl.dsp.exec_cmd("dms ipc call dankdash wallpaper")) -hl.bind("SUPER + TAB", hl.dsp.exec_cmd("dms ipc call hypr toggleOverview")) -hl.bind("SUPER + O", hl.dsp.exec_cmd("dms ipc call hypr toggleOverview")) -hl.bind("SUPER + X", hl.dsp.exec_cmd("dms ipc call powermenu toggle")) - --- === Cheat sheet -hl.bind("SUPER + SHIFT + Slash", hl.dsp.exec_cmd("dms ipc call keybinds toggle hyprland")) - --- === Security === -hl.bind("SUPER + ALT + L", hl.dsp.exec_cmd("dms ipc call lock lock")) -hl.bind("SUPER + SHIFT + E", hl.dsp.exit()) -hl.bind("CTRL + ALT + Delete", hl.dsp.exec_cmd("dms ipc call processlist focusOrToggle")) - --- === Audio Controls === -hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("dms ipc call audio increment 3"), { locked = true, repeating = true }) -hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("dms ipc call audio decrement 3"), { locked = true, repeating = true }) -hl.bind("XF86AudioMute", hl.dsp.exec_cmd("dms ipc call audio mute"), { locked = true }) -hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("dms ipc call audio micmute"), { locked = true }) -hl.bind("XF86AudioPause", hl.dsp.exec_cmd("dms ipc call mpris playPause"), { locked = true }) -hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("dms ipc call mpris playPause"), { locked = true }) -hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("dms ipc call mpris previous"), { locked = true }) -hl.bind("XF86AudioNext", hl.dsp.exec_cmd("dms ipc call mpris next"), { locked = true }) -hl.bind("CTRL + XF86AudioRaiseVolume", hl.dsp.exec_cmd("dms ipc call mpris increment 3"), { locked = true, repeating = true }) -hl.bind("CTRL + XF86AudioLowerVolume", hl.dsp.exec_cmd("dms ipc call mpris decrement 3"), { locked = true, repeating = true }) - --- === Brightness Controls === -hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd([[dms ipc call brightness increment 5 ""]]), { locked = true, repeating = true }) -hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd([[dms ipc call brightness decrement 5 ""]]), { locked = true, repeating = true }) - --- === Window Management === -hl.bind("SUPER + Q", hl.dsp.window.close()) -hl.bind("SUPER + F", hl.dsp.window.fullscreen({ mode = "maximized", action = "toggle" })) -hl.bind("SUPER + SHIFT + F", hl.dsp.window.fullscreen({ mode = "fullscreen", action = "toggle" })) -hl.bind("SUPER + SHIFT + T", hl.dsp.window.float({ action = "toggle" })) --- hl.bind("SUPER + W", hl.dsp.group.toggle()) -hl.bind("SUPER + SHIFT + W", hl.dsp.exec_cmd("dms ipc call window-rules toggle")) - --- === Focus Navigation === -hl.bind("SUPER + left", hl.dsp.focus({ direction = "l" })) -hl.bind("SUPER + down", hl.dsp.focus({ direction = "d" })) -hl.bind("SUPER + up", hl.dsp.focus({ direction = "u" })) -hl.bind("SUPER + right", hl.dsp.focus({ direction = "r" })) -hl.bind("SUPER + H", hl.dsp.focus({ direction = "l" })) -hl.bind("SUPER + J", hl.dsp.focus({ direction = "d" })) -hl.bind("SUPER + K", hl.dsp.focus({ direction = "u" })) -hl.bind("SUPER + L", hl.dsp.focus({ direction = "r" })) - --- === Window Movement === -hl.bind("SUPER + SHIFT + left", hl.dsp.window.move({ direction = "l" })) -hl.bind("SUPER + SHIFT + down", hl.dsp.window.move({ direction = "d" })) -hl.bind("SUPER + SHIFT + up", hl.dsp.window.move({ direction = "u" })) -hl.bind("SUPER + SHIFT + right", hl.dsp.window.move({ direction = "r" })) -hl.bind("SUPER + SHIFT + H", hl.dsp.window.move({ direction = "l" })) -hl.bind("SUPER + SHIFT + J", hl.dsp.window.move({ direction = "d" })) -hl.bind("SUPER + SHIFT + K", hl.dsp.window.move({ direction = "u" })) -hl.bind("SUPER + SHIFT + L", hl.dsp.window.move({ direction = "r" })) - --- === Column Navigation === -hl.bind("SUPER + Home", hl.dsp.focus({ window = "first" })) -hl.bind("SUPER + End", hl.dsp.focus({ window = "last" })) - --- === Monitor Navigation === -hl.bind("SUPER + CTRL + left", hl.dsp.focus({ monitor = "l" })) -hl.bind("SUPER + CTRL + right", hl.dsp.focus({ monitor = "r" })) -hl.bind("SUPER + CTRL + H", hl.dsp.focus({ monitor = "l" })) -hl.bind("SUPER + CTRL + J", hl.dsp.focus({ monitor = "d" })) -hl.bind("SUPER + CTRL + K", hl.dsp.focus({ monitor = "u" })) -hl.bind("SUPER + CTRL + L", hl.dsp.focus({ monitor = "r" })) - --- === Move to Monitor === -hl.bind("SUPER + SHIFT + CTRL + left", hl.dsp.window.move({ monitor = "l" })) -hl.bind("SUPER + SHIFT + CTRL + down", hl.dsp.window.move({ monitor = "d" })) -hl.bind("SUPER + SHIFT + CTRL + up", hl.dsp.window.move({ monitor = "u" })) -hl.bind("SUPER + SHIFT + CTRL + right", hl.dsp.window.move({ monitor = "r" })) -hl.bind("SUPER + SHIFT + CTRL + H", hl.dsp.window.move({ monitor = "l" })) -hl.bind("SUPER + SHIFT + CTRL + J", hl.dsp.window.move({ monitor = "d" })) -hl.bind("SUPER + SHIFT + CTRL + K", hl.dsp.window.move({ monitor = "u" })) -hl.bind("SUPER + SHIFT + CTRL + L", hl.dsp.window.move({ monitor = "r" })) - --- === Workspace Navigation === -hl.bind("SUPER + Page_Down", hl.dsp.focus({ workspace = "e+1" })) -hl.bind("SUPER + Page_Up", hl.dsp.focus({ workspace = "e-1" })) -hl.bind("SUPER + U", hl.dsp.focus({ workspace = "e+1" })) -hl.bind("SUPER + I", hl.dsp.focus({ workspace = "e-1" })) -hl.bind("SUPER + CTRL + down", hl.dsp.window.move({ workspace = "e+1" })) -hl.bind("SUPER + CTRL + up", hl.dsp.window.move({ workspace = "e-1" })) -hl.bind("SUPER + CTRL + U", hl.dsp.window.move({ workspace = "e+1" })) -hl.bind("SUPER + CTRL + I", hl.dsp.window.move({ workspace = "e-1" })) - --- === Workspace Management === -hl.bind("CTRL + SHIFT + R", hl.dsp.exec_cmd("dms ipc call workspace-rename open")) - --- === Move Workspaces === -hl.bind("SUPER + SHIFT + Page_Down", hl.dsp.window.move({ workspace = "e+1" })) -hl.bind("SUPER + SHIFT + Page_Up", hl.dsp.window.move({ workspace = "e-1" })) -hl.bind("SUPER + SHIFT + U", hl.dsp.window.move({ workspace = "e+1" })) -hl.bind("SUPER + SHIFT + I", hl.dsp.window.move({ workspace = "e-1" })) - --- === Mouse Wheel Navigation === -hl.bind("SUPER + mouse_down", hl.dsp.focus({ workspace = "e+1" })) -hl.bind("SUPER + mouse_up", hl.dsp.focus({ workspace = "e-1" })) -hl.bind("SUPER + CTRL + mouse_down", hl.dsp.window.move({ workspace = "e+1" })) -hl.bind("SUPER + CTRL + mouse_up", hl.dsp.window.move({ workspace = "e-1" })) - --- === Touchpad Gestures === -hl.gesture({ fingers = 3, direction = "horizontal", action = "workspace" }) - --- === Numbered Workspaces === -hl.bind("SUPER + 1", hl.dsp.focus({ workspace = "1" })) -hl.bind("SUPER + 2", hl.dsp.focus({ workspace = "2" })) -hl.bind("SUPER + 3", hl.dsp.focus({ workspace = "3" })) -hl.bind("SUPER + 4", hl.dsp.focus({ workspace = "4" })) -hl.bind("SUPER + 5", hl.dsp.focus({ workspace = "5" })) -hl.bind("SUPER + 6", hl.dsp.focus({ workspace = "6" })) -hl.bind("SUPER + 7", hl.dsp.focus({ workspace = "7" })) -hl.bind("SUPER + 8", hl.dsp.focus({ workspace = "8" })) -hl.bind("SUPER + 9", hl.dsp.focus({ workspace = "9" })) - --- === Move to Numbered Workspaces === -hl.bind("SUPER + SHIFT + 1", hl.dsp.window.move({ workspace = "1" })) -hl.bind("SUPER + SHIFT + 2", hl.dsp.window.move({ workspace = "2" })) -hl.bind("SUPER + SHIFT + 3", hl.dsp.window.move({ workspace = "3" })) -hl.bind("SUPER + SHIFT + 4", hl.dsp.window.move({ workspace = "4" })) -hl.bind("SUPER + SHIFT + 5", hl.dsp.window.move({ workspace = "5" })) -hl.bind("SUPER + SHIFT + 6", hl.dsp.window.move({ workspace = "6" })) -hl.bind("SUPER + SHIFT + 7", hl.dsp.window.move({ workspace = "7" })) -hl.bind("SUPER + SHIFT + 8", hl.dsp.window.move({ workspace = "8" })) -hl.bind("SUPER + SHIFT + 9", hl.dsp.window.move({ workspace = "9" })) - --- === Column Management === -hl.bind("SUPER + bracketleft", hl.dsp.layout("preselect l")) -hl.bind("SUPER + bracketright", hl.dsp.layout("preselect r")) - --- === Sizing & Layout === -hl.bind("SUPER + R", hl.dsp.layout("togglesplit")) -hl.bind("SUPER + CTRL + F", hl.dsp.window.fullscreen({ mode = "maximized", action = "set" })) - --- === Move/resize windows with mainMod + LMB/RMB and dragging === -hl.bind("SUPER + mouse:272", hl.dsp.window.drag(), { mouse = true, description = "Move window" }) -hl.bind("SUPER + mouse:273", hl.dsp.window.resize(), { mouse = true, description = "Resize window" }) - -hl.bind("SUPER + code:20", hl.dsp.window.resize({ x = -100, y = 0, relative = true }), { description = "Expand window left" }) -hl.bind("SUPER + code:21", hl.dsp.window.resize({ x = 100, y = 0, relative = true }), { description = "Shrink window left" }) - --- === Manual Sizing === -hl.bind("SUPER + minus", hl.dsp.window.resize({ x = -100, y = 0, relative = true }), { repeating = true }) -hl.bind("SUPER + equal", hl.dsp.window.resize({ x = 100, y = 0, relative = true }), { repeating = true }) -hl.bind("SUPER + SHIFT + minus", hl.dsp.window.resize({ x = 0, y = -100, relative = true }), { repeating = true }) -hl.bind("SUPER + SHIFT + equal", hl.dsp.window.resize({ x = 0, y = 100, relative = true }), { repeating = true }) - --- === Screenshots === -hl.bind("Print", hl.dsp.exec_cmd("dms screenshot")) -hl.bind("CTRL + Print", hl.dsp.exec_cmd("dms screenshot full")) -hl.bind("ALT + Print", hl.dsp.exec_cmd("dms screenshot window")) - --- === Display Profiles === -hl.bind("SUPER + P", hl.dsp.exec_cmd("dms ipc outputs cycleProfile")) - --- === System Controls === -hl.bind("SUPER + SHIFT + P", hl.dsp.dpms({ action = "toggle" })) diff --git a/hosts/desktop/config/hypr/dms/colors.lua b/hosts/desktop/config/hypr/dms/colors.lua deleted file mode 100644 index 27f5523..0000000 --- a/hosts/desktop/config/hypr/dms/colors.lua +++ /dev/null @@ -1,27 +0,0 @@ --- Auto-generated by DMS Matugen hook — do not edit manually. --- Remove require("dms.colors") from hyprland.lua to override. - -hl.config({ - general = { - col = { - active_border = "rgb(d0bcff)", - inactive_border = "rgb(948f99)", - }, - }, - group = { - col = { - border_active = "rgb(d0bcff)", - border_inactive = "rgb(948f99)", - border_locked_active = "rgb(f2b8b5)", - border_locked_inactive = "rgb(948f99)", - }, - groupbar = { - col = { - active = "rgb(d0bcff)", - inactive = "rgb(948f99)", - locked_active = "rgb(f2b8b5)", - locked_inactive = "rgb(948f99)", - }, - }, - }, -}) diff --git a/hosts/desktop/config/hypr/dms/cursor.lua b/hosts/desktop/config/hypr/dms/cursor.lua deleted file mode 100644 index 9c0548a..0000000 --- a/hosts/desktop/config/hypr/dms/cursor.lua +++ /dev/null @@ -1 +0,0 @@ --- Cursor theme overrides. Deploy writes ~/.config/hypr/dms/cursor.lua diff --git a/hosts/desktop/config/hypr/dms/layout.lua b/hosts/desktop/config/hypr/dms/layout.lua deleted file mode 100644 index 2bd8110..0000000 --- a/hosts/desktop/config/hypr/dms/layout.lua +++ /dev/null @@ -1,13 +0,0 @@ --- Auto-generated by DMS — do not edit manually - -hl.config({ - general = { - gaps_in = 4, - gaps_out = 4, - border_size = 2, - resize_on_border = false, - }, - decoration = { - rounding = 12, - }, -}) diff --git a/hosts/desktop/config/hypr/dms/outputs.lua b/hosts/desktop/config/hypr/dms/outputs.lua deleted file mode 100644 index 0eee09d..0000000 --- a/hosts/desktop/config/hypr/dms/outputs.lua +++ /dev/null @@ -1,17 +0,0 @@ --- Per-output monitor rules — embedded sibling of the legacy outputs.conf fragment. - -hl.monitor({ - output = "DP-1", - mode = "2560x1440@180.0", - position = "0x0", - scale = 1, - vrr = 0 -}) - -hl.monitor({ - output = "HDMI-A-1", - mode = "1920x1080@60.0", - position = "2560x790", - scale = 1, - vrr = 0 -}) diff --git a/hosts/desktop/config/hypr/dms/windowrules.lua b/hosts/desktop/config/hypr/dms/windowrules.lua deleted file mode 100644 index 278150f..0000000 --- a/hosts/desktop/config/hypr/dms/windowrules.lua +++ /dev/null @@ -1 +0,0 @@ --- Window rules. Deploy writes ~/.config/hypr/dms/windowrules.lua diff --git a/hosts/desktop/config/hypr/hyprland.lua b/hosts/desktop/config/hypr/hyprland.lua deleted file mode 100644 index 9b88cd4..0000000 --- a/hosts/desktop/config/hypr/hyprland.lua +++ /dev/null @@ -1,89 +0,0 @@ --- Hyprland configuration (Lua) — https://wiki.hypr.land/Configuring/Start/ - -hl.config({ autogenerated = false }) - --- DMS_STARTUP_BEGIN -hl.on("hyprland.start", function() - hl.exec_cmd("dbus-update-activation-environment --systemd --all") - hl.exec_cmd("systemctl --user start hyprland-session.target") -end) --- DMS_STARTUP_END - -hl.config({ - input = { - kb_layout = "us", - kb_options = "compose:ralt", - numlock_by_default = true, - touchpad = { - tap_to_click = true, - natural_scroll = true, - }, - }, - general = { - gaps_in = 5, - gaps_out = 5, - border_size = 2, - layout = "dwindle", - }, - decoration = { - rounding = 12, - active_opacity = 1.0, - inactive_opacity = 1.0, - shadow = { - enabled = true, - range = 30, - render_power = 5, - offset = "0 5", - color = "rgba(00000070)", - }, - }, - misc = { - disable_hyprland_logo = true, - disable_splash_rendering = true, - }, - dwindle = { - preserve_split = true, - }, - master = { - mfact = 0.5, - }, -}) - -hl.animation({ leaf = "windowsIn", enabled = true, speed = 3, bezier = "default" }) -hl.animation({ leaf = "windowsOut", enabled = true, speed = 3, bezier = "default" }) -hl.animation({ leaf = "workspaces", enabled = true, speed = 5, bezier = "default" }) -hl.animation({ leaf = "windowsMove", enabled = true, speed = 4, bezier = "default" }) -hl.animation({ leaf = "fade", enabled = true, speed = 3, bezier = "default" }) -hl.animation({ leaf = "border", enabled = true, speed = 3, bezier = "default" }) - -hl.window_rule({ match = { class = "^(org\\.wezfurlong\\.wezterm)$" }, tile = true }) -hl.window_rule({ match = { class = "^(org\\.gnome\\.)" }, rounding = 12 }) -hl.window_rule({ match = { class = "^(gnome-control-center)$" }, tile = true }) -hl.window_rule({ match = { class = "^(pavucontrol)$" }, tile = true }) -hl.window_rule({ match = { class = "^(nm-connection-editor)$" }, tile = true }) -hl.window_rule({ match = { class = "^(org\\.gnome\\.Calculator)$" }, float = true }) -hl.window_rule({ match = { class = "^(gnome-calculator)$" }, float = true }) -hl.window_rule({ match = { class = "^(galculator)$" }, float = true }) -hl.window_rule({ match = { class = "^(blueman-manager)$" }, float = true }) -hl.window_rule({ match = { class = "^(org\\.gnome\\.Nautilus)$" }, float = true }) -hl.window_rule({ match = { class = "^(xdg-desktop-portal)$" }, float = true }) -hl.window_rule({ - match = { class = "^(steam)$", title = "^(notificationtoasts)" }, - no_initial_focus = true, - pin = true, -}) -hl.window_rule({ - match = { class = "^(firefox)$", title = "^(Picture-in-Picture)$" }, - float = true, -}) -hl.window_rule({ match = { class = "^(zoom)$" }, float = true }) -hl.layer_rule({ match = { namespace = "^(quickshell)$" }, no_anim = true }) -hl.layer_rule({ match = { namespace = "^dms:.*" }, no_anim = true }) - -require("dms.colors") -require("dms.outputs") -require("dms.layout") -require("dms.cursor") -require("dms.binds") -require("dms.binds-user") -require("dms.windowrules") diff --git a/hosts/desktop/config/hypr/scripts/record.sh b/hosts/desktop/config/hypr/scripts/record.sh deleted file mode 100755 index 98d2bf3..0000000 --- a/hosts/desktop/config/hypr/scripts/record.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env bash - -# 📹 Wayland Screen Recording Utility (Niri & Hyprland compatible) -# Leverages 'wf-recorder' for GPU-accelerated video recording and pipewire audio routing. -# Supports capturing specific regions, active windows, focused monitors, or full displays. -# -# Usage: -# record.sh [area | window | output | screen] [audio] - -PID_FILE="/tmp/wf-recorder.pid" -TYPE_FILE="/tmp/wf-recorder.type" -OUTPUT_DIR="${XDG_VIDEOS_DIR:-$HOME/Videos}" - -# Ensure output directory exists -mkdir -p "$OUTPUT_DIR" - -# Stop any active recording session gracefully -stop_recording() { - # Check if we have a saved process ID - if [ -f "$PID_FILE" ]; then - PID=$(cat "$PID_FILE") - if kill -0 "$PID" 2>/dev/null; then - # Send INT signal (Ctrl+C equivalent) so wf-recorder can flush the output container - kill -INT "$PID" - # Wait briefly to permit filesystem write finalization - sleep 0.5 - fi - rm -f "$PID_FILE" - fi - - # Sweep for orphan instances of wf-recorder to prevent background process leaks - if pgrep -x "wf-recorder" > /dev/null; then - pkill -INT -x wf-recorder - sleep 0.5 - fi - - # Read the recording type metadata for user notification - TYPE="Recording" - if [ -f "$TYPE_FILE" ]; then - TYPE=$(cat "$TYPE_FILE") - rm -f "$TYPE_FILE" - fi - - notify-send -t 3000 -u normal "Screen Recorder" "$TYPE stopped and saved to $OUTPUT_DIR" - exit 0 -} - -# If the script is invoked while a recording is already running, toggle it OFF -if pgrep -x "wf-recorder" > /dev/null; then - stop_recording -fi - -# Define operation modes -MODE="${1:-area}" -AUDIO_DEVICE="" -TYPE_DESC="Screen Recording" -GEOM="" -OUTPUT_TARGET="" - -# Extract geometric regions or output target based on requested mode -case "$MODE" in - area) - # Interactive region selector using 'slurp'. User clicks and drags to select. - GEOM=$(slurp) - if [ -z "$GEOM" ]; then - notify-send -t 2000 "Screen Recorder" "Recording cancelled" - exit 1 - fi - TYPE_DESC="Area Recording" - ;; - window) - # Try querying Hyprland active window coordinates if on Hyprland - if [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ] && command -v hyprctl >/dev/null 2>&1; then - GEOM=$(hyprctl activewindow -j 2>/dev/null | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"') - fi - # Fallback to interactive window / region selection via slurp - if [ -z "$GEOM" ] || [ "$GEOM" = "null,null nullxnull" ]; then - GEOM=$(slurp) - fi - if [ -z "$GEOM" ]; then - notify-send -t 2000 "Screen Recorder" "Recording cancelled" - exit 1 - fi - TYPE_DESC="Window Recording" - ;; - output) - # Query focused monitor on Niri or Hyprland - if [ "$XDG_CURRENT_DESKTOP" = "niri" ] || command -v niri >/dev/null 2>&1; then - OUTPUT_TARGET=$(niri msg -j focused-output 2>/dev/null | jq -r '.name // empty') - fi - if [ -z "$OUTPUT_TARGET" ] && command -v hyprctl >/dev/null 2>&1; then - OUTPUT_TARGET=$(hyprctl monitors -j 2>/dev/null | jq -r '.[] | select(.focused == true) | .name // empty') - fi - TYPE_DESC="Monitor Recording" - ;; - screen) - # Full desktop layout across monitors - GEOM="" - OUTPUT_TARGET="" - TYPE_DESC="Full Screen Recording" - ;; -esac - -# Resolve dynamic audio monitor node if requested -if [ "$2" = "audio" ] || [ "$1" = "audio" ]; then - # Parse status output of wireplumber to determine the currently active output Sink ID - SINK_ID=$(wpctl status 2>/dev/null | sed -n '/Sinks:/,/Sources:/p' | grep '\*' | awk '{print $3}' | tr -d '.' | head -n 1) - if [ -n "$SINK_ID" ]; then - # Query wireplumber to resolve the dynamic node name of the identified sink - NODE_NAME=$(wpctl inspect "$SINK_ID" 2>/dev/null | grep 'node.name' | awk -F'"' '{print $2}') - if [ -n "$NODE_NAME" ]; then - # Append .monitor to route output system audio loopback to the recording device - AUDIO_DEVICE="${NODE_NAME}.monitor" - fi - fi - # Fallback to default system source if parsing failed - if [ -z "$AUDIO_DEVICE" ]; then - AUDIO_DEVICE="default" - fi - TYPE_DESC="${TYPE_DESC} (with Audio)" -fi - -# Define output filename format -FILENAME="recording_$(date +%Y-%m-%d_%H-%M-%S).mp4" -FILEPATH="$OUTPUT_DIR/$FILENAME" - -# Desktop notification before starting -notify-send -t 2000 -u low "Screen Recorder" "Starting $TYPE_DESC..." - -# Build wf-recorder arguments array -CMD=(wf-recorder) -if [ -n "$AUDIO_DEVICE" ]; then - CMD+=(-a "$AUDIO_DEVICE") -fi -if [ -n "$GEOM" ]; then - CMD+=(-g "$GEOM") -elif [ -n "$OUTPUT_TARGET" ]; then - CMD+=(-o "$OUTPUT_TARGET") -fi -CMD+=(-f "$FILEPATH") - -# Execute wf-recorder in background -"${CMD[@]}" & -PID=$! - -# Track PID and Type metadata in /tmp for toggle invocation -echo "$PID" > "$PID_FILE" -echo "$TYPE_DESC" > "$TYPE_FILE" diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix deleted file mode 100644 index 77204cf..0000000 --- a/hosts/desktop/configuration.nix +++ /dev/null @@ -1,97 +0,0 @@ -# 🖥️ Desktop Machine Configuration -# This file defines host-specific system configurations for the Desktop environment. - -{ config, lib, pkgs, ... }: - -{ - imports = [ - ./hardware-configuration.nix # Desktop-specific disk and CPU configuration - ../../modules/system/graphical.nix # System-wide graphical stack settings (DMS daemon) - ../../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 (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 = "desktop"; - - # 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 graphical compositors (Niri as primary, Hyprland as secondary/fallback) - programs = { - niri.enable = true; - hyprland.enable = true; - nix-ld = { - enable = true; - libraries = with pkgs; [ - stdenv.cc.cc.lib - zlib - glib - ]; - }; - }; - - # Specialisation for headless server mode - specialisation.server.configuration = { - # 1. Disable display manager and window manager - services.greetd.enable = lib.mkForce false; - programs.niri.enable = lib.mkForce false; - programs.hyprland.enable = lib.mkForce false; - programs.dms-shell.enable = lib.mkForce false; - programs.dms-greeter.enable = lib.mkForce false; - programs.dank-calendar.enable = lib.mkForce false; - - # 2. Disable peripheral hardware services to reduce power consumption - services.pipewire.enable = lib.mkForce false; - services.printing.enable = lib.mkForce false; - hardware.bluetooth.enable = lib.mkForce false; - services.blueman.enable = lib.mkForce false; - - # 3. Disable power-saving suspend/sleep/hibernate behaviors to keep server 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; - - # 4. Enable active kernel-level power management tuning - powerManagement.powertop.enable = lib.mkForce true; - }; - - # Rebuild/State version. Do not modify. - system.stateVersion = "26.05"; -} diff --git a/hosts/desktop/ddclient.conf b/hosts/desktop/ddclient.conf deleted file mode 100644 index c61a9b2..0000000 --- a/hosts/desktop/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/desktop/dynu.nix b/hosts/desktop/dynu.nix deleted file mode 100644 index 071d0e2..0000000 --- a/hosts/desktop/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.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/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix deleted file mode 100644 index 0b10a8a..0000000 --- a/hosts/desktop/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/desktop/home.nix b/hosts/desktop/home.nix deleted file mode 100644 index b51e8e5..0000000 --- a/hosts/desktop/home.nix +++ /dev/null @@ -1,21 +0,0 @@ -# 🏠 Desktop Host-Specific Home Manager Configuration -# Graphical workstation environment for legacy desktop host. - -{ config, pkgs, ... }: - -{ - imports = [ - ../../modules/user/apps.nix - ../../modules/user/graphical.nix - ]; - - # Host-specific package installations for desktop (Hyprland environment) - home.packages = with pkgs; [ - grimblast # Screenshot utility for Hyprland - ]; - - # Mount custom Hyprland and DankMaterialShell configuration files declaratively - home.file.".config/hypr/hyprland.lua".source = ./config/hypr/hyprland.lua; - home.file.".config/hypr/dms".source = ./config/hypr/dms; - home.file.".config/hypr/scripts".source = ./config/hypr/scripts; -} diff --git a/hosts/desktop/homeserver.nix b/hosts/desktop/homeserver.nix deleted file mode 100644 index f5d5d6f..0000000 --- a/hosts/desktop/homeserver.nix +++ /dev/null @@ -1,68 +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, ... }: - -{ - # 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" - "acme_email" - "authelia_session_secret" - "authelia_storage_encryption_key" - "authelia_identity_validation_reset_password_jwt_secret" - "authelia_user_kiskaadee_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.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_identity_validation_reset_password_jwt_secret; - }; - }; - - # Generate the declarative Authelia user database file at runtime in /run/secrets/users.yml - sops.templates."users.yml" = { - owner = "kiskaadee"; - content = '' - users: - kiskaadee: - displayname: "Kiskaadee" - password: "${config.sops.placeholder.authelia_user_kiskaadee_password_hash}" - email: "fcortesbio@gmail.com" - groups: - - admins - - dev - ''; - }; - - # 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. Open ports in the firewall for Traefik and Gitea SSH - networking.firewall.allowedTCPPorts = [ 80 443 2223 ]; -} diff --git a/hosts/desktop/monitor.py b/hosts/desktop/monitor.py deleted file mode 100644 index 964ba00..0000000 --- a/hosts/desktop/monitor.py +++ /dev/null @@ -1,205 +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 urllib.request -import re -import json -import os -import subprocess -import sys -from datetime import datetime - -# 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 - if a == 169 and b == 254: - return False - - return True - - -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 Exception as e: - errors.append(f"{provider}: {str(e)}") - - 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 Exception 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.utcnow().isoformat() + "Z", - "ip": ip, - "status": status - } - if details: - entry["details"] = details - try: - with open(HISTORY_FILE, "a") as f: - f.write(json.dumps(entry) + "\n") - except Exception 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 - ) - 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 Exception 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/desktop/secrets.yaml b/hosts/desktop/secrets.yaml deleted file mode 100644 index 8a4a3bd..0000000 --- a/hosts/desktop/secrets.yaml +++ /dev/null @@ -1,42 +0,0 @@ -dynu_user: ENC[AES256_GCM,data:wDnJP2jHasV4,iv:7yk+J9tO9yqwe3POjFUTkP10I0gp1eEEQPvs4SJzBd0=,tag:98+v/rJGrTDTrxAQqhVomA==,type:str] -dynu_domain: ENC[AES256_GCM,data:bZGnwbQEGVWnTRe7aWMSAMuhsZcIcmb2,iv:nWQzYtJeLYbtqlfe2hDMvtksFGuJ76Qjm+lnG7X2zgo=,tag:65UFCJl4JueHvkiRwcwdjQ==,type:str] -dynu_password: ENC[AES256_GCM,data:F+YtoH6rJov2tgDdrIBGQ99b66PfJhUH0rybYhiF9ck=,iv:3o7vaYT8lNwn0fDt3opHtg5OGKkSxF8RkONTbFGe6Hw=,tag:T5EnMSwGHwAtfK1mS6FvMQ==,type:str] -dynu_api_key: ENC[AES256_GCM,data:4v2mHY8gXIYfiEDjTcDYxhVXc5Lb/szA40oLOvwltGE=,iv:cq7pYGmN7lIWQYG5x+kaoH3GbdAb7MEufdHEMwaeFnA=,tag:sUTgBFcMGRMFgDzgDobsKw==,type:str] -pdf_decrypt_password: ENC[AES256_GCM,data:8lh3pW2rMFs9AA==,iv:4+e0urvjYmdZ4/c0KcD7v9Ps8nKvopdYquwaMlYi2xQ=,tag:XHUESw6g1h1tR4EHrD4SaQ==,type:str] -learning_turso_db_url: ENC[AES256_GCM,data:yV3wJI7Y5kymKjaWZ7i2Ywm7N3vSMO2ApJZALJbGVxsyIs77Z336Rljvf90hbuaTKnY=,iv:Bx2m1NpDDRU2lhiwRRlEZrhFzpNqMCDx4bbfHK63Fl8=,tag:xC7OeNC6+4Zk+IZxozWqgQ==,type:str] -learning_turso_auth_token: ENC[AES256_GCM,data:1fl1kIEw7Z/Xv4ilMRZIt8/ei42O7KSg/yjBs5sxTYVaLrC3GNsngXuTClti8x3AjNsVN39uK2fLI8pUjGb60u07448SlByeBRQkodX/PX7WycaRl3IJ+FlaZJ/DijK2L3AEvOlECs/0PGr7hkgnVnjjg9c2YK+mJuT3xqY5DPytMU7f4nMFM/o63qNffB/N+WtxMsrD5izsawe95Bf6YQvpH+ue4qNn+ZIFmu/MRdCEsLjIRT4rbG76G6iIbLCT2Hr3W1hrzrCPcJ1KvLsAeT97iyNvfDdEWIdpv3DWS8jptS/G9Xvd2xJ8FWkbulZYpHLcjs4nNI0vKULi8VRfJYLYWqZ0gjNb+lkrYt6QgD13VWoC5X/H,iv:sc7Ppa5Jbrnhw97OSMSBQUrnYPH9rJfo+QzeNCbwtIM=,tag:v3AAGyqW9ahXL+dnmDr8BA==,type:str] -mongo_root_username: ENC[AES256_GCM,data:9jIpJnClrLAc,iv:ZtOwIUdXZoY4168YWTCE1Vcz+fek1YHRsAAyFbgkU64=,tag:WmtiJ1sdeFSQxHz5k5I2dQ==,type:str] -mongo_root_password: ENC[AES256_GCM,data:fbtY9aMXhd8D4TL6s7Ce,iv:xXckK6Sbg1PB+1Cifq6WkHtIk9FMgZ3Yf2HdjxPO6vU=,tag:bmyC2dv+QAaoOff+ejw2/g==,type:str] -ollama_api_key: ENC[AES256_GCM,data:1vw8FayOxXv3kfy5xcUy,iv:2zgPy1GUfPtPCyFgtED0R6cPPFJmDdhDbVA+jnomG/k=,tag:3HOdQll25oMPx3jg7Mbrdg==,type:str] -postgres_user: ENC[AES256_GCM,data:81MBXlhjMgKd,iv:54hTY9wtxy16iB/P2QqRsIgdJZyLWYdjaWUqVQFOd74=,tag:Z/idYinY3lB1THGqG7UWAA==,type:str] -postgres_password: ENC[AES256_GCM,data:U2ttYoopG/Uc8HrX3kKq,iv:5pUV00FPcVtKsAx2M3HSUXxRhEXFZWWt9O97CRhKrkM=,tag:ZzbB3Ggu45sylveJcfqStw==,type:str] -postgres_db: ENC[AES256_GCM,data:DJCXJz4SSjcETw==,iv:pM2UfxK8yOL8XxbAZY6XQyNKVPRrrGwjxtM8F3XOCU0=,tag:DcCu/9L4pz7WAkF8WkKzCA==,type:str] -acme_email: ENC[AES256_GCM,data:nQwu6pSUVGwkoq3wvY1wKNMMvis=,iv:jDY32yCLQCruelmeZ1DaeFPoxMyM4/+Mpt6g5rsYrO8=,tag:ROcVL+/2zCzF8fId6MSlrg==,type:str] -authelia_session_secret: ENC[AES256_GCM,data:sz99LUaspa4PyTZb0ukBPKZ5uQoomEiDZ/+IxU9OxzLhBysZChTZ7nIMAmxnffbT6dHuWE3cvGntKAAOqx7DKpTOkk/YFZk31Z1FfYZ59csrIW9LChWc7EeM21SzS9Z+1jU9Zo5PBsK93X7E1m9OTKtinCwivb+hLa6AVpmdOm4=,iv:V+oxP22Nm3DyY6/SA61SrQoVwraixlM8RANQ9wejFnI=,tag:8bAuoJ6jkg5hsrzMna23vQ==,type:str] -authelia_storage_encryption_key: ENC[AES256_GCM,data:f/pHK6GORv8iHiQbDvybi/KShoKl9b3NJbfW6m8iBK4X0A9n9UiYj+LBRFY79xs78YvYj/fDROaWN1fQM6nXJf+HsUqZ7/V3cIfk8eQdYto1mVI53VByIAEURQopnb9/+ypAN61YnCwkL2CEm0ID/sOmbLVO/aQmK7ccuN9CP2I=,iv:BcoAkOdR/gGoiiP+KJNa0H/9rXpfZf2h8dT0sw5o9pU=,tag:DsPWeWABjZVvDHC5dE1XDA==,type:str] -authelia_identity_validation_reset_password_jwt_secret: ENC[AES256_GCM,data:HNK2JEBHQBWuNnuqiqyhbk3NOoRhV40C4H+aM7kbFl+Ag1u0Vh4yafpQuyhzBH/e2jb3KDDu12m/7u2jv8bTLFhlp3b91KeKLz4c1sVoMNRzGYzIyynx42KYutaFLH42sBVgOQ/sCw1ug+Plt2bGFMK20PODdNzFELStvk4qH1Q=,iv:6nqNlshXJoemh97LlpUCp2t/AmXmxzufzjRZYEJzGXc=,tag:ATA3lP2hQl+jFFUERIayTw==,type:str] -authelia_user_kiskaadee_password_hash: ENC[AES256_GCM,data:ZJvq9ocETSzIl3RH9Qg0Ls4p+9QCD1/e+g1uzpAKs6HZk0AjKtCrUtqxEUjqbPi3W9ymsXQzkurtfYRw47lqsom5yGoyW6Q1Tq19crCqibgn4DHc0XGp1uoIvtxUkDSijg==,iv:rsP/z/fwhJhJs7hH0Qx3ry7K++tmEiWke2MwNULHKWg=,tag:vA7cRip2+Y7ALPL/Kqo3uQ==,type:str] -sops: - age: - - enc: | - -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBGRUpiNDJVODBxZ3o0TGwv - MHNCU2lENkdXMGJVcW5DeDJjQjJCaExTR0VVCjlTbVF4VW9FR3Q0akwrNlZZR09V - Z2NYT2Q1bGtHdkhhNnJtdGVzVVJIZ2MKLS0tIHhkU1l0TDMxWUVEK280WVcxVk8w - Y0ZUZ0xRdXhTRGxGSk9lOE1Ha1l2MFUKxUhwgiNLkWuYcxq/4vKVJ/Kdot8b8fEh - DcZmV3Q+7hi2cZvkJ3MFEGNmESe7//bGHXDJOt7rEnCcjgbU+jPAug== - -----END AGE ENCRYPTED FILE----- - recipient: age16nr2t9jrw09kakuxy2vtvtgtwa9jvy5dmtge25rzlqelf5cjy4es46alu9 - - enc: | - -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA0U3dFSTBxckZjTFpMYzIv - L2lwVk5HMk91YjdNejNGTkR0Uy9qR0pYVEJNCk5CQ2xLRS9rQnU5UzFzc2RzY1Rr - NUNCWlA0Nmg5VFVkTzBNVG8vaWZkMEEKLS0tIFFwdW0yVFJyQmdhMk9tcStURTFm - MjdVUVJEZHB1SUlGYVlNTDdER0lnb2cKbJ6sWXplLLph2o+0RbAk5DXPBk3Q9LaD - KHX+ZcBi2WoOtZJEs5G+Z6fGeZHjJ1X2JTCv9oINsppu8FUovkYX/A== - -----END AGE ENCRYPTED FILE----- - recipient: age18q3lr2z4yeg2f86my42ym4hx0dvcwgjshmchyhdkgwvf4k37dsyq3mcjse - lastmodified: "2026-08-11T16:01:34Z" - mac: ENC[AES256_GCM,data:PoTV9ffRfrA04oKQj57pAK3TeH4VRZ9IYxlt3qQ9ELM6fgc0+HxXYGF3XHwier1Qk8KieZtL1CeWsCwVSMIbvs6krDqqv7dSWoVs8re2cVlkSpa99eReR1wpbNBOvv2mAHBVUgMfQlht/GaBbwbswk9bnIUY5zB7AsqCSjSsPQE=,iv:49yMPyXAPeyp1Peq/L3ruLingnyWnaok4t05lSqEnTQ=,tag:PXuMC2ZjZ9eq2Xn2V+ubHQ==,type:str] - unencrypted_suffix: _unencrypted - version: 3.13.3 diff --git a/hosts/desktop/traefik-deployments.nix b/hosts/desktop/traefik-deployments.nix deleted file mode 100644 index cc73664..0000000 --- a/hosts/desktop/traefik-deployments.nix +++ /dev/null @@ -1,97 +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" - ] (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"; - - # --- 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"; - }; - }; -}