Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

factorio: use requireFile with better error msg and split off API docs to devdoc #301816

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 34 additions & 32 deletions pkgs/games/factorio/default.nix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved to pkgs/by-name

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
, makeDesktopItem
, makeWrapper
, releaseType
, requireFile
, stdenv
, wayland

Expand All @@ -37,7 +38,7 @@ let

mods = args.mods or [ ];

helpMsg = ''
helpMsg = version: ''

===FETCH FAILED===
Please ensure you have set the username and token with config.nix, or
Expand All @@ -60,10 +61,10 @@ let

Alternatively, instead of providing the username+token, you may manually
download the release through https://factorio.com/download , then add it to
the store using e.g.:
the Nix store using e.g.:

releaseType=alpha
version=0.17.74
releaseType=${releaseType}
version=${version}
nix-prefetch-url file://\''$HOME/Downloads/factorio_\''${releaseType}_x64_\''${version}.tar.xz --name factorio_\''${releaseType}_x64-\''${version}.tar.xz

Note the ultimate "_" is replaced with "-" in the --name arg!
Expand Down Expand Up @@ -105,34 +106,28 @@ let
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
(if username != "" && token != "" then
(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 = ''
echo -n "${username}" >username
echo -n "${token}" >token
'';
failureHook = ''
cat <<EOF
${helpMsg}
EOF
'';
}));
})) else requireFile {
inherit name sha256;
message = helpMsg version;
});
};

configBaseCfg = ''
Expand Down Expand Up @@ -268,8 +263,15 @@ let
};
alpha = demo // {

outputs = [ "out" "devdoc" ];
installPhase = demo.installPhase + ''
cp -a doc-html $out/share/factorio
mkdir -p $devdoc/share/doc
cp -a doc-html $devdoc/share/doc/factorio
'';

postFixup = ''
# postInstall itself is insufficient _multioutDocs hook in preFixup moves this to $doc output instead.
moveToOutput "share/doc" "$devdoc"
'';
};
};
Expand Down