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.
This commit is contained in:
parent
c9a9197078
commit
86aa2a57d3
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user