nixguix: Improve git origins detection
Without this, some git repositories are detected as file (due to upstream misqualification too). This does some extra effort to detect those to avoid sending noise to loaders.
This also refactors some common code to build vcs artifacts to avoid duplication.
Related to T3781 Depends on !435 (closed)
Migrated from D8620 (view on Phabricator)