From ef582b2805fca03c7f4aa9848cf7935407295139 Mon Sep 17 00:00:00 2001 From: Svein Ove Aas Date: Fri, 22 Jan 2016 23:54:49 +0000 Subject: [PATCH] factorio: init at 0.12.20 --- pkgs/games/factorio/default.nix | 100 ++++++++++++++++++++++++++++++++ pkgs/games/factorio/fetch.nix | 33 +++++++++++ pkgs/games/factorio/fetch.sh | 44 ++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 179 insertions(+) create mode 100644 pkgs/games/factorio/default.nix create mode 100644 pkgs/games/factorio/fetch.nix create mode 100644 pkgs/games/factorio/fetch.sh diff --git a/pkgs/games/factorio/default.nix b/pkgs/games/factorio/default.nix new file mode 100644 index 000000000000..b08f977cda6b --- /dev/null +++ b/pkgs/games/factorio/default.nix @@ -0,0 +1,100 @@ +{ stdenv, callPackage, fetchurl, makeWrapper +# Begin libraries +, alsaLib, libX11, libXcursor, libXinerama, libXrandr, libXi +# Begin download parameters +, username ? "" +, password ? "" +}: + +let + version = "0.12.20"; + + fetch = callPackage ./fetch.nix { username = username; password = password; }; + arch = if stdenv.system == "x86_64-linux" then "x64" + else if stdenv.system == "i686-linux" then "x32" + else abort "Unsupported platform"; + + variants = { + x64 = { + url = "https://www.factorio.com/get-download/${version}/alpha/linux64"; + sha256 = "1xpzrx3q678519qgjl92fxn3qv55hd188x9jp6dcfk2ljhi1gmqk"; + }; + + x32 = { + url = "https://www.factorio.com/get-download/${version}/alpha/linux32"; + sha256 = "1dl1dsp4nni5nda437ckyw1ss6w168g19v51h7cdvb3cgsdb7sab"; + }; + }; +in + +stdenv.mkDerivation rec { + name = "factorio-${version}"; + + src = fetch variants.${arch}; + + libPath = stdenv.lib.makeLibraryPath [ + alsaLib + libX11 + libXcursor + libXinerama + libXrandr + libXi + ]; + + buildInputs = [ makeWrapper ]; + + installPhase = '' + mkdir -p $out/{bin,share/factorio} + cp -a bin/${arch}/factorio $out/bin/factorio.${arch} + cp -a doc-html data $out/share/factorio/ + + # Fortunately, Factorio already supports system-wide installs. + # Unfortunately it's a bit inconvenient to set the paths. + cat > $out/share/factorio/config-base.cfg < $out/share/factorio/update-config.sh < 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 = "";' + echo ' password = "";' + echo ' };' + echo ' };' + echo '}' + + exit 1 +fi diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a8f01dda21f0..24e9808654d8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14110,6 +14110,8 @@ let exult = callPackage ../games/exult { }; + factorio = callPackage ../games/factorio {}; + fairymax = callPackage ../games/fairymax {}; fish-fillets-ng = callPackage ../games/fish-fillets-ng {};