Nix adds errexit and failpipe.
Using head will end in 141 SIGPIPE, see: https://unix.stackexchange.com/a/580119/185477
I apply the workaround / fix as suggested on StackExchange.
That way the script runs and can execute the cleanup and diff.
No need for overlays.
Instead create own packages and call them via callPackage.
That will keep them simpler and allows dependency injection.
I can follow existing patterns from nixpkgs, etc.