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.