3.1 KiB
3.1 KiB
Gemini Context & Project Guidelines
This file serves as persistent contextual memory for the Gemini CLI when working on this NixOS configuration project.
Architecture: The den Framework
This repository manages NixOS and Home Manager configurations using the den framework. The approach here drastically differs from standard NixOS setups.
Core Concepts & Rules
- Freeform Schemas over Custom Options: Do not use legacy Nix module options (
lib.mkOption,lib.mkIf) to define simple user/host properties (like email addresses, domains, or names). Instead, attach properties directly to the host or user definition objects inhosts/<name>/default.nixorusers/<name>.nix. Den's freeform entity schemas will pass these through the context pipeline automatically. - Parametric Aspects: When a module requires access to host or user variables (like
user.emailorhost.domain), the aspect MUST be wrapped inden.lib.parametric.- Example:
lux.myapp = den.lib.parametric { includes = [ ({ user, ... }: { ... }) ]; };
- Example:
- Decentralized Host & User Definitions: Do not centralize host definitions in a single file. Follow the
quasigodreference structure:- Hosts declare themselves in
modules/hosts/<hostname>/default.nix(e.g.,den.hosts.x86_64-linux.orion = { ... }). - Users bind themselves to hosts in their own user files in
modules/users/<username>.nix(e.g.,den.hosts.x86_64-linux.orion.users.kiri = userAccount // { ... }).
- Hosts declare themselves in
- App Categories & Naming:
/modules/desktop/: GUI, Wayland, display managers, WMs./modules/dev/: Developer tools, terminal, neovim./modules/apps/: User-level software (PIM, Bitwarden, MPV, Email). Note:pim.nixstands for Personal Information Management and is an app, not a user definition./modules/services/: System-level daemons (Caddy, Gitea, Vaultwarden)./modules/profiles/: Aggregations (like workstation/server).
Common Pitfalls & Lessons Learned
home-managervshomeManager: When defining class configurations inside a parametric function, the key for Home Manager is strictlyhomeManager(camelCase). Writinghome-manager.programs...will cause evaluation errors becausehome-manageris not the class name used by the schema.useris an Object: In context parameters ({ user, ... }:),useris an attribute set, not a string. Do not interpolate it directly as a string ("${user}"); use${user.name}.- Namespace Inclusion: The project uses the
luxnamespace. When an aspect needs to pull in other aspects, usewith lux; [ ... ]rather than writing outden.ful.lux...repeatedly. - Abstracting Paths: Never hardcode
/home/<username>. InsidehomeManagermodules, useconfig.home.homeDirectory. Insidenixosmodules (like SOPS), use/home/${user.name}whereuseris provided by the parametric context. - Git Status dependency: When moving, creating, or renaming files (
mv,mkdir), they must be staged in Git (git add <file>) before runningnix flake check, otherwise the flake evaluator will not see the changes and will throw "undefined variable" or "path does not exist" errors.