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.
Instead, sources now record either `branch` or `tag`. The fetcher
specifies the correct ref (`/refs/heads/...` or `/refs/tags/...`) which
works in the newest version of Nix. The `ref` attribute can still be set
to override the logic.
This updates the sources.nix to replace the `outPath` field of package
`foo` with the content of envionment variable `NIV_OVERRIDE_foo`. In the
environment variable name, all characters outside of `[a-zA-Z0-9_]` are
escaped to `_`.
Some results were fetched _way_ too many times. All IO operations run in
updates are now cached. This makes `niv` effectively twice as fast.
*before:*
```
~/niv$ time niv add git git@github.com:nmattia/niv
Adding package niv
Writing new sources file
Done: Adding package niv
real 0m3.603s
user 0m0.079s
sys 0m0.031s
```
*after:*
```
~/niv$ time niv add git git@github.com:nmattia/niv
Adding package niv
Writing new sources file
Done: Adding package niv
real 0m1.387s
user 0m0.049s
sys 0m0.007s
```
This adds a few configuration options to `niv init`:
* `--no-nixpkgs`: skips the import of nixpkgs
* `--nixpkgs-branch`: specifies the branch to use for nixpkgs
* `--nixpkgs`: specifies the repo to use for nixpkgs
NOTE: this changes the default nixpkgs branch from nixos-19.09 to
release-19.09.