From 8a819d416fec5fca0675a46b0669b983dc282770 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Tue, 22 Oct 2024 18:53:11 +0100 Subject: [PATCH] factorio: nixfmt --- pkgs/by-name/fa/factorio/package.nix | 252 +++++++++++++++------------ 1 file changed, 140 insertions(+), 112 deletions(-) diff --git a/pkgs/by-name/fa/factorio/package.nix b/pkgs/by-name/fa/factorio/package.nix index 8dd35b1e4b63..5442eae4b333 100644 --- a/pkgs/by-name/fa/factorio/package.nix +++ b/pkgs/by-name/fa/factorio/package.nix @@ -1,33 +1,35 @@ -{ lib -, alsa-lib -, factorio-utils -, fetchurl -, libGL -, libICE -, libSM -, libX11 -, libXcursor -, libXext -, libXi -, libXinerama -, libXrandr -, libpulseaudio -, libxkbcommon -, makeDesktopItem -, makeWrapper -, releaseType -, stdenv -, wayland +{ + lib, + alsa-lib, + factorio-utils, + fetchurl, + libGL, + libICE, + libSM, + libX11, + libXcursor, + libXext, + libXi, + libXinerama, + libXrandr, + libpulseaudio, + libxkbcommon, + makeDesktopItem, + makeWrapper, + releaseType, + stdenv, + wayland, -, mods-dat ? null -, versionsJson ? ./versions.json -, username ? "" -, token ? "" # get/reset token at https://factorio.com/profile -, experimental ? false # true means to always use the latest branch -, ... -} @ args: + mods-dat ? null, + versionsJson ? ./versions.json, + username ? "", + token ? "", # get/reset token at https://factorio.com/profile + experimental ? false, # true means to always use the latest branch + ... +}@args: -assert releaseType == "alpha" +assert + releaseType == "alpha" || releaseType == "headless" || releaseType == "demo" || releaseType == "expansion"; @@ -86,55 +88,69 @@ let versions = importJSON versionsJson; binDists = makeBinDists versions; - actual = binDists.${stdenv.hostPlatform.system}.${releaseType}.${branch} or (throw "Factorio ${releaseType}-${branch} binaries for ${stdenv.hostPlatform.system} are not available for download."); + actual = + binDists.${stdenv.hostPlatform.system}.${releaseType}.${branch} + or (throw "Factorio ${releaseType}-${branch} binaries for ${stdenv.hostPlatform.system} are not available for download."); - makeBinDists = versions: + makeBinDists = + versions: let - f = path: name: value: + f = + path: name: value: if builtins.isAttrs value then - if value ? "name" then - makeBinDist value - else - builtins.mapAttrs (f (path ++ [ name ])) value + if value ? "name" then makeBinDist value else builtins.mapAttrs (f (path ++ [ name ])) value else throw "expected attrset at ${toString path} - got ${toString value}"; in builtins.mapAttrs (f [ ]) versions; - makeBinDist = { name, version, tarDirectory, url, sha256, needsAuth }: { - inherit version tarDirectory; - src = - if !needsAuth then - fetchurl { inherit name url sha256; } - else - (lib.overrideDerivation - (fetchurl { - inherit name url sha256; - curlOptsList = [ - "--get" - "--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 + makeBinDist = + { + name, + version, + tarDirectory, + url, + sha256, + needsAuth, + }: + { + inherit version tarDirectory; + src = + if !needsAuth then + fetchurl { inherit name url sha256; } + else + (lib.overrideDerivation + (fetchurl { + inherit name url sha256; + curlOptsList = [ + "--get" + "--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 <