Nix Module Workflow
Use this skill when implementing configuration changes in modules/, hosts/, packages/, or overlays/.
Where to Change What
- •User program/service config:
modules/home/programs/*.nix,modules/home/services/*.nix - •macOS-specific behavior:
modules/darwin/* - •Linux-specific behavior:
modules/nixos/* - •Host wiring:
hosts/darwin/work/*.nix,hosts/nixos/* - •Shared defaults/helpers:
modules/shared/*,lib/*
Module Pattern
Follow modules/*/template.nix style:
- •Define
options.<path>.enable = lib.mkEnableOption ... - •Gate config with
lib.mkIf config.<path>.enable { ... } - •Keep modules focused and composable.
Change Procedure
- •Prefer editing an existing module before creating a new one.
- •Add or update options and implementation.
- •Enable module in the target host/home config.
- •Validate with
nix flake checkand relevant build command. - •Apply with
switchonly after successful build.
Naming and Layout
- •Use feature-based filenames:
modules/home/programs/<tool>.nix - •Keep host names explicit (
lunar,nixos-ry6a) - •Put custom packages in
packages/<name>/default.nix - •Put overlays in
overlays/<name>/default.nix