diff options
author | Svein Ove Aas <sveina@gmail.com> | 2016-01-22 23:54:49 +0000 |
---|---|---|
committer | Svein Ove Aas <sveina@gmail.com> | 2016-01-23 13:15:18 +0000 |
commit | ef582b2805fca03c7f4aa9848cf7935407295139 (patch) | |
tree | 04ddb415dc7779500f586f2b90894edad89e653c /pkgs/games/factorio/fetch.sh | |
parent | ecc48af0ce20e24a7e4d56e663f5752d69384644 (diff) | |
download | nixlib-ef582b2805fca03c7f4aa9848cf7935407295139.tar nixlib-ef582b2805fca03c7f4aa9848cf7935407295139.tar.gz nixlib-ef582b2805fca03c7f4aa9848cf7935407295139.tar.bz2 nixlib-ef582b2805fca03c7f4aa9848cf7935407295139.tar.lz nixlib-ef582b2805fca03c7f4aa9848cf7935407295139.tar.xz nixlib-ef582b2805fca03c7f4aa9848cf7935407295139.tar.zst nixlib-ef582b2805fca03c7f4aa9848cf7935407295139.zip |
factorio: init at 0.12.20
Diffstat (limited to 'pkgs/games/factorio/fetch.sh')
-rw-r--r-- | pkgs/games/factorio/fetch.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/pkgs/games/factorio/fetch.sh b/pkgs/games/factorio/fetch.sh new file mode 100644 index 000000000000..ad9766736867 --- /dev/null +++ b/pkgs/games/factorio/fetch.sh @@ -0,0 +1,44 @@ +source $stdenv/setup + +# Curl flags to increase reliability a bit. +# +# Can't use fetchurl, for several reasons. One is that we definitely +# don't want --insecure for the login, though we need it for the +# download as their download cert isn't in the standard linux bundle. +curl="curl \ + --max-redirs 20 \ + --retry 3 \ + --cacert /etc/ssl/certs/ca-bundle.crt \ + $curlOpts \ + $NIX_CURL_FLAGS" + +# We don't want the password to be on any program's argv, as it may be +# visible in /proc. Writing it to file with echo should be safe, since +# it's a shell builtin. +echo "password=$password" > password +# Might as well hide the username as well. +echo "username-or-email=$username" > username + +# Log in. We don't especially care about the result, but let's check if login failed. +$curl -c cookies -d @username -d @password $loginUrl -D headers > /dev/null + +if grep -q 'Location: /' headers; then + # Now download. We need --insecure for this, but the sha256 should cover us. + $curl -b cookies --insecure --location $url > $out +else + echo 'Login failed' + echo 'Please set username and password with config.nix,' + echo 'or /etc/nix/nixpkgs-config.nix if on NixOS.' + echo + echo 'Example:' + echo '{' + echo ' packageOverrides = pkgs: rec {' + echo ' factorio = pkgs.factorio.override {' + echo ' username = "<username or email address>";' + echo ' password = "<password>";' + echo ' };' + echo ' };' + echo '}' + + exit 1 +fi |