5.0 KiB
5.0 KiB
Copilot Instructions for EmergentMind's Nix-Config
Project Overview
- This is a modular, flake-based NixOS configuration system, designed for multi-host, multi-user, and reproducible setups.
- Major directories and their roles:
hosts/: Per-host NixOS configs (e.g.,hosts/nixos/Bellerophon/). Each host has its own directory with adefault.nixentrypoint, plus hardware, disk, and optional feature overrides.home/: Per-user Home Manager configs. User-specific and shared configs, withcommon/for reusable modules andoptional/for opt-in features.modules/: Reusable NixOS and Home Manager modules, auto-imported vialib.custom.scanPaths. This is where most custom logic, options, and abstractions live—including CLI tool modules, system services, and shared config patterns.overlays/,pkgs/: Custom packages and overlays. CLI tools that are not in upstream Nixpkgs are typically defined here (seepkgs/common/for examples likecd-gitroot).nixos-installer/: Standalone flake for bootstrapping new hosts, with its own README and workflows.docs/: Project documentation, including secrets management and architecture guides.scripts/: Helper scripts for bootstrap, rebuild, sops, etc. Used in developer workflows and automation.tests/: Automated tests (Bats), with fixtures and helpers for validating secrets, modules, and workflows.
- Desktop Environments & Optional Features:
- Desktop environments (GNOME, KDE, XFCE, etc.) and other optional system features are modularized under
hosts/common/core/optional/and its subfolders (e.g.,gnome.nix,kde.nix,xfce.nix). - These are imported by hosts as needed, allowing flexible, DRY configuration.
- Desktop environments (GNOME, KDE, XFCE, etc.) and other optional system features are modularized under
- CLI Tools:
- System-wide CLI tools are typically declared in
modules/(as NixOS or Home Manager modules), or inpkgs/if packaged locally. - User-level CLI tools are managed via Home Manager modules in
home/<user>/common/core/shell/(e.g.,fish.nix,bat.nix,eza.nix). - Many tools are grouped by function (shell, coding, productivity, etc.) for clarity and reusability.
- System-wide CLI tools are typically declared in
- Disk Layout: Disk setup is handled by
diskomodules, with per-host overrides for device and swap inhosts/common/core/disks/. - Secrets: Secrets are managed via a private
nix-secretsrepo and sops-nix. Seedocs/secretsmgmt.mdandnixos-installer/README.mdfor details. - VSCode/Language Support: Language-specific VSCode configs live in
home/panotaka/common/optional/coding/vscode/languages/and are imported via the main VSCode module.
Key Patterns & Conventions
- Imports: Use
lib.custom.relativeToRootandlib.custom.scanPathsfor DRY, recursive module imports. - Host/Module Structure: Each host and user has a directory with a
default.nixas entrypoint. Common/optional configs are split for clarity. - Disk Layout: Disk setup is handled by
diskomodules, with per-host overrides for device and swap. - Secrets: Secrets are managed via a private
nix-secretsrepo and sops-nix. Seedocs/secretsmgmt.mdandnixos-installer/README.mdfor details. - VSCode/Language Support: Language-specific VSCode configs live in
home/panotaka/common/optional/coding/vscode/languages/and are imported via the main VSCode module.
Developer Workflows
- Build & Rebuild: Use
just rebuild(runs pre/post hooks, seejustfile). For full checks:just rebuild-fullorjust check. - ISO Generation:
just isobuilds a custom NixOS installer ISO. - Secrets: Use
just rekey,just sops-add-creation-rules, and related commands for sops/age key management. - Sync/Deploy: Use
just syncandjust build-hostfor remote deployment. - Testing: Tests live in
tests/and usebats.
Integration Points
- External: Relies on
nix-secrets(private), sops-nix, disko, stylix, nix4vscode, and nixos-hardware modules. - Cross-Component: Host configs import common modules and optional features via mapped imports. Home Manager and NixOS modules are kept separate but coordinated.
Examples
- To add a new host: copy an existing host dir in
hosts/nixos/, update disk and user settings, and add secrets as pernixos-installer/README.md. - To add a new language to VSCode: add a
.nixfile tovscode/languages/and import it in the main VSCode module. - To add a new CLI tool: create a module in
modules/or a package inpkgs/, then import it in the relevant host or user config. - To enable a desktop environment: import the relevant module from
hosts/common/core/optional/in your host'sdefault.nix. - To update secrets: run
just rekeyand follow the documented workflow.
References
- See
README.md,nixos-installer/README.md, anddocs/secretsmgmt.mdfor deep dives on architecture and workflows. - For module patterns, see
modules/andhosts/common/core/. - For CLI tool packaging, see
pkgs/andmodules/. - For desktop environment modules, see
hosts/common/core/optional/.
If you are unsure about a workflow or pattern, check the referenced docs or ask for clarification in your PR.