summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Marshall <andrew@johnandrewmarshall.com>2023-03-14 11:06:31 -0400
committerKerstin <kerstin@erictapen.name>2023-04-09 17:04:56 +0200
commitc5ef4af03f4838cb38d4c1c37b8d3d2a4c683407 (patch)
treeb5f927a9fd4cc646b141324faf497c78f64f92f3
parent3c384353a64ee069240af601aa6781bb556351cf (diff)
downloadnixpkgs-c5ef4af03f4838cb38d4c1c37b8d3d2a4c683407.tar
nixpkgs-c5ef4af03f4838cb38d4c1c37b8d3d2a4c683407.tar.gz
nixpkgs-c5ef4af03f4838cb38d4c1c37b8d3d2a4c683407.tar.bz2
nixpkgs-c5ef4af03f4838cb38d4c1c37b8d3d2a4c683407.tar.lz
nixpkgs-c5ef4af03f4838cb38d4c1c37b8d3d2a4c683407.tar.xz
nixpkgs-c5ef4af03f4838cb38d4c1c37b8d3d2a4c683407.tar.zst
nixpkgs-c5ef4af03f4838cb38d4c1c37b8d3d2a4c683407.zip
factorio: Formatting
Format with nixpkgs-fmt and alphabetize.
-rw-r--r--pkgs/games/factorio/default.nix110
1 files changed, 67 insertions, 43 deletions
diff --git a/pkgs/games/factorio/default.nix b/pkgs/games/factorio/default.nix
index 41dd9625adb..5706c222843 100644
--- a/pkgs/games/factorio/default.nix
+++ b/pkgs/games/factorio/default.nix
@@ -1,17 +1,33 @@
-{ lib, stdenv, fetchurl, makeWrapper, makeDesktopItem
-, alsa-lib, libpulseaudio, libX11, libXcursor, libXinerama, libXrandr, libXi, libGL
-, libSM, libICE, libXext, factorio-utils
+{ lib
+, alsa-lib
+, factorio-utils
+, fetchurl
+, libGL
+, libICE
+, libSM
+, libX11
+, libXcursor
+, libXext
+, libXi
+, libXinerama
+, libXrandr
+, libpulseaudio
+, makeDesktopItem
+, makeWrapper
 , releaseType
-, mods ? []
+, stdenv
+
+, mods ? [ ]
 , mods-dat ? null
 , versionsJson ? ./versions.json
-, username ? "", token ? "" # get/reset token at https://factorio.com/profile
+, username ? ""
+, token ? "" # get/reset token at https://factorio.com/profile
 , experimental ? false # true means to always use the latest branch
 }:
 
 assert releaseType == "alpha"
-    || releaseType == "headless"
-    || releaseType == "demo";
+  || releaseType == "headless"
+  || releaseType == "demo";
 
 let
 
@@ -68,16 +84,17 @@ let
   actual = binDists.${stdenv.hostPlatform.system}.${releaseType}.${branch} or (throw "Factorio ${releaseType}-${branch} binaries for ${stdenv.hostPlatform.system} are not available for download.");
 
   makeBinDists = versions:
-    let f = path: name: value:
-      if builtins.isAttrs value then
-        if value ? "name" then
-          makeBinDist value
+    let
+      f = path: name: value:
+        if builtins.isAttrs value then
+          if value ? "name" then
+            makeBinDist value
+          else
+            builtins.mapAttrs (f (path ++ [ name ])) value
         else
-          builtins.mapAttrs (f (path ++ [ name ])) value
-      else
-        throw "expected attrset at ${toString path} - got ${toString value}";
+          throw "expected attrset at ${toString path} - got ${toString value}";
     in
-      builtins.mapAttrs (f []) versions;
+    builtins.mapAttrs (f [ ]) versions;
   makeBinDist = { name, version, tarDirectory, url, sha256, needsAuth }: {
     inherit version tarDirectory;
     src =
@@ -89,26 +106,29 @@ let
             inherit name url sha256;
             curlOptsList = [
               "--get"
-              "--data-urlencode" "username@username"
-              "--data-urlencode" "token@token"
+              "--data-urlencode"
+              "username@username"
+              "--data-urlencode"
+              "token@token"
             ];
           })
-          (_: { # This preHook hides the credentials from /proc
-                preHook =
-                  if username != "" && token != "" then ''
-                    echo -n "${username}" >username
-                    echo -n "${token}"    >token
-                  '' else ''
-                    # Deliberately failing since username/token was not provided, so we can't fetch.
-                    # We can't use builtins.throw since we want the result to be used if the tar is in the store already.
-                    exit 1
-                  '';
-                failureHook = ''
-                  cat <<EOF
-                  ${helpMsg}
-                  EOF
-                '';
-              }));
+          (_: {
+            # This preHook hides the credentials from /proc
+            preHook =
+              if username != "" && token != "" then ''
+                echo -n "${username}" >username
+                echo -n "${token}"    >token
+              '' else ''
+                # Deliberately failing since username/token was not provided, so we can't fetch.
+                # We can't use builtins.throw since we want the result to be used if the tar is in the store already.
+                exit 1
+              '';
+            failureHook = ''
+              cat <<EOF
+              ${helpMsg}
+              EOF
+            '';
+          }));
   };
 
   configBaseCfg = ''
@@ -149,9 +169,12 @@ let
         $out/bin/factorio
     '';
 
-    passthru.updateScript = if (username != "" && token != "") then [
-      ./update.py "--username=${username}" "--token=${token}"
-    ] else null;
+    passthru.updateScript =
+      if (username != "" && token != "") then [
+        ./update.py
+        "--username=${username}"
+        "--token=${token}"
+      ] else null;
 
     meta = {
       description = "A game in which you build and maintain factories";
@@ -184,16 +207,16 @@ let
 
       libPath = lib.makeLibraryPath [
         alsa-lib
-        libpulseaudio
+        libGL
+        libICE
+        libSM
         libX11
         libXcursor
+        libXext
+        libXi
         libXinerama
         libXrandr
-        libXi
-        libGL
-        libSM
-        libICE
-        libXext
+        libpulseaudio
       ];
 
       installPhase = base.installPhase + ''
@@ -244,4 +267,5 @@ let
     };
   };
 
-in stdenv.mkDerivation (releases.${releaseType})
+in
+stdenv.mkDerivation (releases.${releaseType})