- •Use
nix evalandnix buildto experiment with your changes. - •New files are not discoverable by Nix until you
git addthem. - •Prefer
libfunctions overbuiltinswhen both exist (e.g.lib.mapoverbuiltins.map). - •Don't guess hostnames or other configuration names. Use
nix flake showornix replto discover them.
Exploring flake outputs
- •Use
nix flake showto see what a flake exposes. - •Pipe expressions to
nix repl .#for deeper exploration. Flake outputs are loaded as top-level variables (e.g.echo 'builtins.attrNames nixosConfigurations' | nix repl .#).
Looking up documentation
- •Use
man configuration.nixto explore available module options. This returns NixOS options on Linux and nix-darwin options on macOS. - •Use
man home-configuration.nixto explore home-manager module options. - •Use
echo ':doc lib.mkIf' | nix repl nixpkgsto check documentation onlibfunctions. Many include type signatures and examples.
Source-diving
- •Use
EDITOR=cat nix edit nixpkgs#<package>to view a package's source. Does not work with modules. - •Use
nix flake metadata <flake> --json | jq -r '.path'to get a flake's store path, then read files directly from it to source-dive modules and other definitions. - •Never search
/nix/storebroadly — it's massive and will take forever. Always resolve the specific store path you need first.