mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2025-01-06 21:42:35 +03:00
Merge pull request #198835 from YellowOnion/factorio-patch
factorio: better mod support
This commit is contained in:
commit
36c0938cc5
@ -39,7 +39,7 @@ let
|
||||
} // cfg.extraSettings;
|
||||
serverSettingsFile = pkgs.writeText "server-settings.json" (builtins.toJSON (filterAttrsRecursive (n: v: v != null) serverSettings));
|
||||
serverAdminsFile = pkgs.writeText "server-adminlist.json" (builtins.toJSON cfg.admins);
|
||||
modDir = pkgs.factorio-utils.mkModDirDrv cfg.mods;
|
||||
modDir = pkgs.factorio-utils.mkModDirDrv cfg.mods cfg.mods-dat;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@ -136,6 +136,15 @@ in
|
||||
derivations via nixos-channel. Until then, this is for experts only.
|
||||
'';
|
||||
};
|
||||
mods-dat = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = lib.mdDoc ''
|
||||
Mods settings can be changed by specifying a dat file, in the [mod
|
||||
settings file
|
||||
format](https://wiki.factorio.com/Mod_settings_file_format).
|
||||
'';
|
||||
};
|
||||
game-name = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "Factorio Game";
|
||||
|
@ -3,6 +3,8 @@
|
||||
, libSM, libICE, libXext, factorio-utils
|
||||
, releaseType
|
||||
, mods ? []
|
||||
, 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
|
||||
}:
|
||||
@ -60,7 +62,7 @@ let
|
||||
|
||||
# NB `experimental` directs us to take the latest build, regardless of its branch;
|
||||
# hence the (stable, experimental) pairs may sometimes refer to the same distributable.
|
||||
versions = importJSON ./versions.json;
|
||||
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.");
|
||||
@ -129,7 +131,7 @@ let
|
||||
fi
|
||||
'';
|
||||
|
||||
modDir = factorio-utils.mkModDirDrv mods;
|
||||
modDir = factorio-utils.mkModDirDrv mods mods-dat;
|
||||
|
||||
base = with actual; {
|
||||
pname = "factorio-${releaseType}";
|
||||
|
@ -3,7 +3,7 @@
|
||||
{ lib, stdenv }:
|
||||
with lib;
|
||||
{
|
||||
mkModDirDrv = mods: # a list of mod derivations
|
||||
mkModDirDrv = mods: modsDatFile: # a list of mod derivations
|
||||
let
|
||||
recursiveDeps = modDrv: [modDrv] ++ map recursiveDeps modDrv.deps;
|
||||
modDrvs = unique (flatten (map recursiveDeps mods));
|
||||
@ -18,7 +18,9 @@ with lib;
|
||||
# NB: there will only ever be a single zip file in each mod derivation's output dir
|
||||
ln -s $modDrv/*.zip $out
|
||||
done
|
||||
'';
|
||||
'' + (lib.optionalString (modsDatFile != null) ''
|
||||
cp ${modsDatFile} $out/mod-settings.dat
|
||||
'');
|
||||
};
|
||||
|
||||
modDrv = { allRecommendedMods, allOptionalMods }:
|
||||
|
Loading…
Reference in New Issue
Block a user