From c5ef4af03f4838cb38d4c1c37b8d3d2a4c683407 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 14 Mar 2023 11:06:31 -0400 Subject: [PATCH] factorio: Formatting Format with nixpkgs-fmt and alphabetize. --- pkgs/games/factorio/default.nix | 110 +++++++++++++++++++------------- 1 file changed, 67 insertions(+), 43 deletions(-) diff --git a/pkgs/games/factorio/default.nix b/pkgs/games/factorio/default.nix index 41dd9625adb8..5706c2228435 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 <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 <