Also fixes a small issue in the update.py:
The upstream API seems to have changed in a sense that the demo is not
available in experimental channel anymore. Hence the original update.py
script would fail, due to the missing `demo` key in the experimental
channel. I added a sane failure path which just ignores if a release
type (like `demo`) is missing in the channel, in order to increase the
scripts resilience.
Prior to this change, `update.py` fails with `KeyError: 'alpha'` when upstream
does not have a version in the `experimental` channel:
./update.py --username XXXXXXXX --token "$(wl-paste)"
Traceback (most recent call last):
File "./update.py", line 180, in <module>
app.run(main)
File "/nix/store/854z51wg8fj1s6ghxasp1xxx8khb3r8v-python3-3.8.9-env/lib/python3.8/site-packages/absl/app.py", line 303, in run
_run_main(main, args)
File "/nix/store/854z51wg8fj1s6ghxasp1xxx8khb3r8v-python3-3.8.9-env/lib/python3.8/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "./update.py", line 162, in main
new_our_versions = generate_our_versions(factorio_versions)
File "./update.py", line 92, in generate_our_versions
version = factorio_versions[release_channel.name][release_type.name]
KeyError: 'alpha'
I chose to make it so that the versions in nixpkgs' `factorio-*` packages are
either experimental (when available) or stable, as this seems like the most
coherent approach
The updateScript knows how to automatically fetch and update the version
data from the Factorio versions API (and update the hashes
appropriately), which makes it easier to update whenever experimental
does.
The download URL will redirect to the login page if credentials are not
present, but will return an error if the credentials are wrong.
Since we know we always expect credentials, we can fail the fetch in
the preHook if they're not provided.
We can't use e.g. builtins.throw because we want the fetchurl derivation
to be evaluated in all cases - because that's the mechanism which allows
you to just manually add the tarball to the Nix store.