Rework check_nix_freshness to use a dynamically scoped variable