{ 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 <