summary refs log tree commit diff
path: root/pkgs/games/factorio
diff options
context:
space:
mode:
authorEric Litak <elitak@gmail.com>2016-04-27 03:32:23 -0700
committerJoachim Fasting <joachifm@fastmail.fm>2016-05-05 20:11:52 +0200
commitf6b645206f041cb997bc7aac2e2783bbc32efb8b (patch)
tree3e8b2d3eeb06bc1b5ace609df5172f4c4461b2e4 /pkgs/games/factorio
parent23fd70b71951b7b1446d7803e714bf55a291d694 (diff)
downloadnixpkgs-f6b645206f041cb997bc7aac2e2783bbc32efb8b.tar
nixpkgs-f6b645206f041cb997bc7aac2e2783bbc32efb8b.tar.gz
nixpkgs-f6b645206f041cb997bc7aac2e2783bbc32efb8b.tar.bz2
nixpkgs-f6b645206f041cb997bc7aac2e2783bbc32efb8b.tar.lz
nixpkgs-f6b645206f041cb997bc7aac2e2783bbc32efb8b.tar.xz
nixpkgs-f6b645206f041cb997bc7aac2e2783bbc32efb8b.tar.zst
nixpkgs-f6b645206f041cb997bc7aac2e2783bbc32efb8b.zip
factorio: refactor alpha/headless split
Diffstat (limited to 'pkgs/games/factorio')
-rw-r--r--pkgs/games/factorio/default.nix129
1 files 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)