From f6b645206f041cb997bc7aac2e2783bbc32efb8b Mon Sep 17 00:00:00 2001 From: Eric Litak Date: Wed, 27 Apr 2016 03:32:23 -0700 Subject: factorio: refactor alpha/headless split --- pkgs/games/factorio/default.nix | 129 ++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 66 deletions(-) diff --git a/pkgs/games/factorio/default.nix b/pkgs/games/factorio/default.nix index cf96756b8b6..6cbfba50918 100644 --- a/pkgs/games/factorio/default.nix +++ b/pkgs/games/factorio/default.nix @@ -1,10 +1,7 @@ { stdenv, callPackage, fetchurl, makeWrapper -# Begin libraries , alsaLib, libX11, libXcursor, libXinerama, libXrandr, libXi, mesa_noglu -# Begin download parameters -, username ? "" -, password ? "" , releaseType +, username ? "" , password ? "" }: assert releaseType == "alpha" || releaseType == "headless"; @@ -55,15 +52,51 @@ let fi ''; -in + base = { + name = "factorio-${releaseType}-${version}"; -stdenv.mkDerivation rec { - name = "factorio-${releaseType}-${version}"; + src = fetch.${arch.inTar}.${releaseType}; - src = fetch.${arch.inTar}.${releaseType}; + dontBuild = true; - libPath = stdenv.lib.makeLibraryPath ( - optionals (! isHeadless) [ + # TODO detangle headless/normal mode wrapping, libs, etc. test all urls 32/64/headless/gfx + installPhase = '' + mkdir -p $out/{bin,share/factorio} + cp -a data $out/share/factorio + cp -a bin/${arch.inTar}/factorio $out/bin/factorio + patchelf \ + --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + $out/bin/factorio + ''; + + preferLocalBuild = true; + + meta = { + description = "A game in which you build and maintain factories"; + longDescription = '' + Factorio is a game in which you build and maintain factories. + + You will be mining resources, researching technologies, building + infrastructure, automating production and fighting enemies. Use your + imagination to design your factory, combine simple elements into + ingenious structures, apply management skills to keep it working and + finally protect it from the creatures who don't really like you. + + Factorio has been in development since spring of 2012 and it is + currently in late alpha. + ''; + homepage = https://www.factorio.com/; + license = stdenv.lib.licenses.unfree; + maintainers = with stdenv.lib.maintainers; [ Baughn elitak ]; + platforms = [ "i686-linux" "x86_64-linux" ]; + }; + }; + headless = base; + alpha = base // { + + buildInputs = [ makeWrapper ]; + + libPath = stdenv.lib.makeLibraryPath [ alsaLib libX11 libXcursor @@ -71,61 +104,25 @@ stdenv.mkDerivation rec { libXrandr libXi mesa_noglu - ] - ); - - buildInputs = [ makeWrapper ]; - - dontBuild = true; - - # TODO detangle headless/normal mode wrapping, libs, etc. test all urls 32/64/headless/gfx - installPhase = '' - mkdir -p $out/{bin,share/factorio} - cp -a data $out/share/factorio - cp -a bin/${arch.inTar}/factorio $out/bin/factorio - patchelf \ - --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ - $out/bin/factorio - - '' + optionalString (! isHeadless) ('' - mv $out/bin/factorio $out/bin/factorio.${arch.inTar} - makeWrapper $out/bin/factorio.${arch.inTar} $out/bin/factorio \ - --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib:$libPath \ - --run "$out/share/factorio/update-config.sh" \ - --add-flags "-c \$HOME/.factorio/config.cfg" - # Fortunately, Factorio already supports system-wide installs. - # Unfortunately it's a bit inconvenient to set the paths. - install -m0644 <(cat << EOF - '' + configBaseCfg + '' - EOF - ) $out/share/factorio/config-base.cfg - - install -m0755 <(cat << EOF - '' + updateConfigSh + '' - EOF - ) $out/share/factorio/update-config.sh - cp -a doc-html $out/share/factorio - ''); - - preferLocalBuild = true; - - meta = { - description = "A game in which you build and maintain factories"; - longDescription = '' - Factorio is a game in which you build and maintain factories. - - You will be mining resources, researching technologies, building - infrastructure, automating production and fighting enemies. Use your - imagination to design your factory, combine simple elements into - ingenious structures, apply management skills to keep it working and - finally protect it from the creatures who don't really like you. - - Factorio has been in development since spring of 2012 and it is - currently in late alpha. + ]; + + installPhase = base.installPhase + '' + wrapProgram $out/bin/factorio \ + --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib:$libPath \ + --run "$out/share/factorio/update-config.sh" \ + --add-flags "-c \$HOME/.factorio/config.cfg" + + install -m0644 <(cat << EOF + ${configBaseCfg} + EOF + ) $out/share/factorio/config-base.cfg + + install -m0755 <(cat << EOF + ${updateConfigSh} + EOF + ) $out/share/factorio/update-config.sh + + cp -a doc-html $out/share/factorio ''; - homepage = https://www.factorio.com/; - license = stdenv.lib.licenses.unfree; - maintainers = with stdenv.lib.maintainers; [ Baughn elitak ]; - platforms = [ "i686-linux" "x86_64-linux" ]; }; -} +in stdenv.mkDerivation (if isHeadless then headless else alpha) -- cgit 1.4.1