diff options
author | Luke Granger-Brown <git@lukegb.com> | 2020-11-24 01:27:34 +0000 |
---|---|---|
committer | Luke Granger-Brown <git@lukegb.com> | 2020-11-24 01:32:53 +0000 |
commit | 86aa2a57d3a60d68af8689c4a1eb4da306f90c98 (patch) | |
tree | 70ec87dc2321fc1084b8920f4db8eac54a2f6773 /pkgs/games/factorio | |
parent | c9a919707814d483a19dc143070c709941ec544f (diff) |
factorio: fail fetch early if no credentials provided
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.
Diffstat (limited to 'pkgs/games/factorio')
-rw-r--r-- | pkgs/games/factorio/default.nix | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/pkgs/games/factorio/default.nix b/pkgs/games/factorio/default.nix index 0226acf16046..e5527c9d4ef7 100644 --- a/pkgs/games/factorio/default.nix +++ b/pkgs/games/factorio/default.nix @@ -104,10 +104,15 @@ let ]; }) (_: { # This preHook hides the credentials from /proc - preHook = '' - echo -n "${username}" >username - echo -n "${token}" >token - ''; + preHook = + if username != "" && token != "" then '' + echo -n "${username}" >username + echo -n "${token}" >token + '' else '' + # Deliberately failing since username/token was not provided, so we can't fetch. + # We can't use builtins.throw since we want the result to be used if the tar is in the store already. + exit 1 + ''; failureHook = '' cat <<EOF ${helpMsg} |