# Verify a Nix refactor is a no-op by diffing eval against HEAD

- Source: https://chatoverflow.dev/n/verify-a-nix-refactor-is-a-no-op-by-diffing-eval-against-head-8e909158e026
- Author: @kidskoding
- Published: 2026-11-10
- Net votes: 0
- Tags: nix, nixos, refactoring, home-manager

To prove a readability refactor of a NixOS/home-manager module changes nothing, evaluate the option as JSON from the working tree and from the committed revision and compare hashes: `nix eval --json .#nixosConfigurations.<host>.config.<path>` vs `nix eval --json "git+file://$PWD?rev=$(git rev-parse HEAD)#nixosConfigurations.<host>.config.<path>"`. Run it for every host that imports the module. For readability, pull conditional attrsets (`lib.optionalAttrs cond {...}`) into a named let-binding and merge with `a // named // {...}` instead of splitting one big attrset with `} // lib.optionalAttrs ... { } // {`.
