mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-13 12:13:46 +01:00
- clarify 'just niri' (<hostname>-niri) vs 'just local' (bare hostname) - note where overlays/hardening packages live - note the Noctalia config location and host-specific <host>.toml overrides
4.2 KiB
4.2 KiB
Repository Agent Guide
This flake manages NixOS hosts, macOS via nix-darwin, shared Home Manager profiles, and Colmena
deployments. Keep repository guidance here; reusable global rules live in agents/AGENTS.md. See
agents/README.md for their scope and symlink installation targets.
Where Changes Belong
flake.nixdefines inputs;outputs/default.nixcomposes outputs forx86_64-linux,aarch64-linux, andaarch64-darwin.modules/contains system modules;home/contains Home Manager modules. Put shared behavior here rather than duplicating it in host configurations.hosts/contains host-specific configuration;outputs/<system>/src/wires hosts into outputs.vars/andlib/provide shared values and helpers. Usemyvarsand existing abstractions instead of hardcoding usernames or paths.secrets/contains agenix definitions; secret material also comes from a private external repo.overlays/andhardening/hold package overlays and hardened (nixpak/bwrap) wrappers.- Noctalia (the Wayland shell) is configured in
home/linux/gui/base/noctalia/config/config.toml, which theprograms.noctaliamodule validates at build time. Host-specific overrides go in ahost-<name>.tomlthere (merged afterconfig.toml).
Commands and Platforms
- Prefer recipes in Justfile; use
just --listto discover available commands andjust --show <recipe>to inspect behavior before running them. - The Justfile uses Nushell. Preserve
[linux]/[macos]guards and host naming conventions. - Deploy by hostname: NixOS desktops are
<hostname>-niri(just niri); other NixOS hosts, VMs, and macOS hosts use the bare hostname (just local, mapping tonixos-switch, ordarwin-build/darwin-switchon macOS). Arguments differ per platform; check both when changing shared behavior. nix developprovides formatters and linters. If needed,nix shell nixpkgs#just nixpkgs#nushellprovides the task runner and its shell.
Validation
- For Nix changes, run
just fmtand inspect the diff: it formats all Nix files. Nix style isnixfmtwith width 100. - For supported non-Nix files, use
prettier --write <file>andprettier --check <file>; configuration lives in.prettierrc.yaml. Spelling checks usetyposand.typos.toml. - Run
just testfor configuration changes. It evaluates.#evalTestsacross Linux and Darwin; the output must betrue. Exit code zero withfalseis a failed suite. - Eval tests are
expr.nix/expected.nixpairs underoutputs/<system>/tests/. Update focused cases when changing behavior covered by those tests. - Use
nix flake checkfor broader flake checks. A host build can validate changes beyond eval:nix build .#nixosConfigurations.<host>.config.system.build.toplevel. - Documentation-only changes need formatting checks and
git diff --check; Nix tests may be skipped. Report checks run, skipped, or blocked, including the command and reason for failures.
Nix Conventions
- Use
kebab-case.nixfilenames andinherit (...)for attribute imports. - Prefer
lib.mkIf,lib.optional, andlib.optionalsfor conditional configuration. - Use
lib.mkDefaultfor defaults andlib.mkForceonly when necessary. - Give module options a
descriptionand preserve platform-specific conditions.
Command Hazards
just up,just upp, andjust up-nixuse--commit-lock-file. When a commit is not authorized, usenix flake update <input>for a scoped input update without committing.- Deployment and upload recipes change systems; use eval/build commands for validation. Remote
deployment requires an explicit request. When deployment behavior changes, report the exact
justcommand to run. just clean,just gc,just ggc, andjust gameremove history or amend commits; they are not validation steps and require explicit authorization for their target and scope.- Do not use
just penvoffor process inspection: it can expose secret values.