From 6332c96d3e504d04791303c3ef70267b6724e7a2 Mon Sep 17 00:00:00 2001 From: Jelle Spreeuwenberg Date: Tue, 21 Apr 2026 12:12:43 +0200 Subject: [PATCH] refactor: centralize host and user metadata --- AGENTS.md | 83 --------- modules/features/bitwarden.nix | 12 +- modules/features/desktop-base.nix | 47 +++-- modules/features/dev-tools.nix | 2 +- modules/features/email.nix | 55 +++--- modules/features/ergon-workstation.nix | 9 + modules/features/git.nix | 14 +- modules/features/home-manager-base.nix | 26 +++ modules/features/kiri-workstation.nix | 23 +++ modules/features/local-apps.nix | 2 +- modules/features/meta.nix | 147 ++++++++++++++++ modules/features/neovim/default.nix | 6 +- modules/features/networking.nix | 8 + modules/features/niri/default.nix | 28 ++- modules/features/qbittorrent-client.nix | 4 +- modules/features/region-nl.nix | 2 +- modules/features/services/actual.nix | 32 ++-- modules/features/services/deluge.nix | 4 +- modules/features/services/gitea.nix | 48 +++-- modules/features/services/openssh.nix | 15 +- modules/features/services/radicale.nix | 58 ++++--- modules/features/services/vaultwarden.nix | 36 ++-- modules/features/shell.nix | 6 +- modules/features/ssh.nix | 2 +- modules/features/standard-boot.nix | 19 +- modules/features/system-base.nix | 10 -- modules/features/user-base.nix | 22 +-- modules/hosts/orion/default.nix | 73 +++----- modules/hosts/polaris/default.nix | 108 ++++-------- modules/hosts/zenith/default.nix | 81 ++++----- modules/lib.nix | 89 ++++++++++ modules/secrets/sops.nix | 10 +- modules/users.nix | 203 +++++++++++++++------- 33 files changed, 805 insertions(+), 479 deletions(-) delete mode 100644 AGENTS.md create mode 100644 modules/features/ergon-workstation.nix create mode 100644 modules/features/home-manager-base.nix create mode 100644 modules/features/kiri-workstation.nix create mode 100644 modules/features/meta.nix delete mode 100644 modules/features/system-base.nix create mode 100644 modules/lib.nix diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index fac6a34..0000000 --- a/AGENTS.md +++ /dev/null @@ -1,83 +0,0 @@ -# Repository Guidelines - -## Project Structure & Module Organization -This repository is a simplified `flake-parts` NixOS flake. `flake.nix` imports `./modules` through `import-tree`, so normal `.nix` files under `modules/` are loaded automatically unless their file or directory name starts with `_`. - -- `modules/flake-parts.nix` defines the `flake-parts` setup, formatter, and the exported `nixosConfigurations`. -- `modules/hosts//default.nix` defines one top-level `flake.modules.nixos.` module and assembles that machine by importing reusable features, user modules, and host-local helpers. -- `modules/hosts//_*.nix` are private host-local helper modules such as hardware and disk layout files. -- `modules/users/.nix` defines one reusable NixOS user module and the baseline Home Manager imports for that account. -- `modules/features/*.nix` contains reusable NixOS and Home Manager feature modules. -- `modules/features//default.nix` is used when a feature needs private helper files, for example `niri/_bindings.nix`. -- `modules/features/services/*.nix` contains reusable service-oriented NixOS modules. -- `modules/secrets/sops.nix` wires `sops-nix` for both NixOS and Home Manager. -- `modules/secrets/secrets.yaml` stores encrypted secrets, with `.sops.yaml` defining SOPS creation rules. -- `modules/_treefmt.nix` configures repository formatting. - -Keep host files thin. Shared behavior belongs in `modules/features/` or `modules/users/`. Host files should mainly compose imports and hold host-only settings such as monitor layouts, hardware quirks, boot tweaks, and machine-local firewall or service choices. - -## Mental Model -This repo is direct module composition around `flake.modules`, not the old inventory-driven dendritic design. - -- Reusable building blocks are exposed as `flake.modules.nixos.` and `flake.modules.homeManager.`. -- Host modules are the composition root. They import the reusable NixOS modules they need, enable Home Manager, and add any host-specific Home Manager imports inline. -- User modules define the Unix user plus that account’s baseline Home Manager setup. -- There is no `config.repo`, inventory schema, profiles layer, or attachment builder anymore. - -In practice: - -- Prefer importing a feature module directly over inventing a repo-local option just to toggle it. -- Put cross-host reusable behavior in `modules/features/`. -- Put account-specific defaults in `modules/users/`. -- Keep private helper files `_`-prefixed so `import-tree` does not expose them as top-level modules. -- Match the existing split between NixOS composition in host modules and Home Manager composition in user or host modules. - -## Current Host Composition -There are three exported hosts: - -- `orion`: server-oriented host with `kiri`, SOPS, and service modules such as Caddy, Gitea, Vaultwarden, Radicale, Actual, and OpenSSH. -- `polaris`: graphical desktop host with `kiri` and `ergon`, hardware imports, Niri, Steam, local desktop features, and host-specific monitor layout. -- `zenith`: graphical laptop host with `kiri` and `ergon`, Niri, laptop hardware support, firmware updates, and host-specific monitor layout. - -When adjusting user-facing software, check whether it belongs in: - -- a user baseline in `modules/users/.nix` -- a reusable Home Manager feature in `modules/features/*.nix` -- a host-local extension inside `modules/hosts//default.nix` - -Be careful not to move host-specific Home Manager imports into a user baseline unless that behavior should apply on every host that imports that user module. - -## Validation And Development Commands -Run commands from the repository root. - -- `nix build --no-link --show-trace .#nixosConfigurations..config.system.build.toplevel`: baseline validation for one host. -- `nix build --no-link --show-trace .#nixosConfigurations.orion.config.system.build.toplevel .#nixosConfigurations.polaris.config.system.build.toplevel .#nixosConfigurations.zenith.config.system.build.toplevel`: validate all defined hosts in one invocation. -- `nixos-rebuild build --flake .#`: use when you specifically want `nixos-rebuild` semantics without activation. -- `nix eval --json .#nixosConfigurations..config.