1.3 KiB
1.3 KiB
Agent Guidelines for NixOS Configuration
Build & Deploy Commands
nix flake check- Validate flake configurationbuild <host>- Build configuration for specific host (e.g.,build radish)apply <host>- Deploy to remote host via colmenaapply-local- Apply configuration locally using nhnix build .#nixosConfigurations.<host>.config.system.build.toplevel- Build specific host
Code Style
- Format: Use
nixfmt-rfc-stylefor all .nix files - Imports: List imports first, group by: local modules, external inputs (inputs.*)
- Function args: Multi-line with trailing comma when >3 args:
{ config, lib, pkgs, ... }: - Options: Define in
options.<service>block, implement inconfig = lib.mkIf cfg.enable { ... } - Types: Use
lib.types.*for option types (str, bool, int, etc.) - String interpolation: Use
"${}"for Nix expressions, prefer lib.getExe for binaries - Conditionals: Use
lib.mkIf,lib.mkDefault,lib.mkMergefor NixOS options
Structure
- Host configs in
hosts/<name>/with configuration.nix, default.nix, hardware-configuration.nix - Reusable modules in
modules/andmodules/services/ - Custom packages in
custom-pkgs/using util.package pattern - Secrets managed via agenix in
secrets/directory