This speeds up the `niv init` command by getting rid of
`nix-prefetch-url` calls (by default). In particular:
* `niv` itself is not added anymore
* `nixpkgs` is fetched from a "known" version
GitHub has deprecated setting the environment variables and paths via
echoing to the stdout:
https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
Thus, this PR brings the code up to data with the recommendations in the
linked post. In short, paths are exposed to subsequent steps by
appending to the file named in `$GITHUB_PATH`, while environment
variables are set by appending `name=value` to the file named in
`$GITHUB_ENV`.
Whereas before niv would simply say that git didn't produce any output,
it now points out that the branch may not exist:
```
*Niv> :main add git git@github.com:nmattia/niv -b foobar
Adding package niv
FATAL: Could not read the output of 'git'.
command: git ls-remote git@github.com:nmattia/niv refs/heads/foobar
Git didn't produce any output. Does the branch 'foobar' exist?
FATAL: One or more packages failed to update:
niv: ExitFailure 1
ERROR: ExitFailure 1
*** Exception: ExitFailure 1
```
Here we make sure that some environment variables are prepended
(GITHUB_PATH, GITHUB_INSECURE). For consistency's sake, other
environment variables (GITHUB_TOKEN, etc) _can_ also be prepended with
NIV_. This also issues a warning if `GITHUB_PATH` or `GITHUB_INSECURE`
is set.
This should hopefully clarify that `--version` shouldn't be used for
GitHub repositories; moreover setting a particular revision is used much
more often than changing the repo name.
When combining Nix Flakes with niv, `builtins.currentSystem` is
disabled. This allows to bootstrap nixpkgs by passing the system from
the flake evaluation.