Nix reads from git index, not working tree. Stage all modified files before rebuilding: git add specific-file.nix for each changed file. Never use git add -A or git add . (may stage unrelated parallel work).
NixOS: Runs sudo nixos-rebuild switch --flake ~/.dotfiles#$(whoami)
Non-NixOS: Runs home-manager switch --flake ~/.dotfiles#$(whoami)@$(arch)-linux
NixOS: nix build ~/.dotfiles#nixosConfigurations.USER.config.system.build.toplevel --dry-run
Non-NixOS: home-manager build --flake ~/.dotfiles#USER@x86_64-linux --dry-run
Dry-run catches syntax errors, missing imports, and evaluation failures without modifying the system.
Home-manager standalone: User-level only with home-manager switch --flake. No sudo needed. Affects user packages, dotfiles, services.
Detection: Check /etc/os-release for ID=nixos, or use OS from session-context. The bin/rebuild script handles this automatically.
On NixOS: May need to ask user to run rebuild (requires sudo). On home-manager standalone: Execute directly, no sudo needed.