Merge pull request #239235 from mdarocha/openra-refactor

openraPackages_2019: remove dependency on dotnetPackages
This commit is contained in:
Sandro 2023-06-27 18:05:28 +02:00 committed by GitHub
commit d9ec93ad3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 45 deletions

View file

@ -2,7 +2,7 @@
and out-of-tree mod packages (mod.nix).
*/
{ lib, makeSetupHook, curl, unzip, dos2unix, pkg-config, makeWrapper
, lua, mono, dotnetPackages, python3
, lua, mono, python3
, libGL, freetype, openal, SDL2
, zenity
}:
@ -40,24 +40,7 @@ in {
'';
packageAttrs = {
buildInputs = with dotnetPackages; [
FuzzyLogicLibrary
MaxMindDb
MaxMindGeoIP2
MonoNat
NewtonsoftJson
NUnit3
NUnitConsole
OpenNAT
RestSharp
SharpFont
SharpZipLib
SmartIrc4net
StyleCopMSBuild
StyleCopPlusMSBuild
] ++ [
libGL
];
buildInputs = [ libGL ];
# TODO: Test if this is correct.
nativeBuildInputs = [

View file

@ -6,9 +6,7 @@
Additional engines or mods can be added with `openraPackages.buildOpenRAEngine` (function around `engine.nix`)
and `openraPackages.buildOpenRAMod` (function around `mod.nix`), respectively.
*/
pkgs:
with pkgs.lib;
{ pkgs, lib }:
let
/* Building an engine or out-of-tree mod is very similar,
@ -21,7 +19,10 @@ let
so either the attributes added by `makeOverridable` have to be removed
or the engine and mod package definitions will need to add `...` to the argument list.
*/
common = let f = import ./common.nix; in f (builtins.intersectAttrs (functionArgs f) pkgs // {
common = let
f = import ./common.nix;
fArgs = lib.functionArgs f;
in f (builtins.intersectAttrs fArgs pkgs // {
lua = pkgs.lua5_1;
# It is not necessary to run the game, but it is nicer to be given an error dialog in the case of failure,
# rather than having to look to the logs why it is not starting.
@ -40,8 +41,8 @@ let
to base the name on the attribute name instead, preventing the need to specify the name twice
if the attribute name and engine/mod name are equal.
*/
callWithName = name: value: if isFunction value then value name else value;
buildOpenRASet = f: args: pkgs.recurseIntoAttrs (mapAttrs callWithName (f ({
callWithName = name: value: if lib.isFunction value then value name else value;
buildOpenRASet = f: args: pkgs.recurseIntoAttrs (lib.mapAttrs callWithName (f ({
inherit (pkgs) fetchFromGitHub;
postFetch = ''
sed -i 's/curl/curl --insecure/g' $out/thirdparty/{fetch-thirdparty-deps,noget}.sh
@ -56,14 +57,16 @@ in pkgs.recurseIntoAttrs rec {
# Allow specifying the name at a later point if no name has been given.
let builder = name: pkgs.callPackage ./engine.nix (common // {
engine = engine // { inherit name; };
}); in if name == null then builder else builder name;
});
in if name == null then builder else builder name;
# See `buildOpenRAEngine`.
buildOpenRAMod = { name ? null, version, title, description, homepage, src, engine, assetsError ? "" }@mod: ({ version, mods ? [], src }@engine:
let builder = name: pkgs.callPackage ./mod.nix (common // {
mod = mod // { inherit name assetsError; };
engine = engine // { inherit mods; };
}); in if name == null then builder else builder name) engine;
});
in if name == null then builder else builder name) engine;
# See `buildOpenRASet`.
engines = buildOpenRASet (import ./engines.nix) { inherit buildOpenRAEngine; };

View file

@ -14,9 +14,7 @@
, engine
}:
with lib;
stdenv.mkDerivation (recursiveUpdate packageAttrs rec {
stdenv.mkDerivation (lib.recursiveUpdate packageAttrs rec {
pname = "openra_2019";
version = "${engine.name}-${engine.version}";
@ -27,7 +25,7 @@ stdenv.mkDerivation (recursiveUpdate packageAttrs rec {
configurePhase = ''
runHook preConfigure
make version VERSION=${escapeShellArg version}
make version VERSION=${lib.escapeShellArg version}
runHook postConfigure
'';
@ -48,7 +46,7 @@ stdenv.mkDerivation (recursiveUpdate packageAttrs rec {
postInstall = ''
${wrapLaunchGame "" "openra"}
${concatStrings (map (mod: ''
${lib.concatStrings (map (mod: ''
makeWrapper $out/bin/openra $out/bin/openra-${mod} --add-flags Game.Mod=${mod}
'') engine.mods)}
'';

View file

@ -14,14 +14,12 @@
, engine
}:
with lib;
let
engineSourceName = engine.src.name or "engine";
modSourceName = mod.src.name or "mod";
# Based on: https://build.opensuse.org/package/show/home:fusion809/openra-ura
in stdenv.mkDerivation (recursiveUpdate packageAttrs rec {
in stdenv.mkDerivation (lib.recursiveUpdate packageAttrs rec {
name = "${pname}-${version}";
pname = "openra_2019-${mod.name}";
inherit (mod) version;
@ -54,8 +52,8 @@ in stdenv.mkDerivation (recursiveUpdate packageAttrs rec {
configurePhase = ''
runHook preConfigure
make version VERSION=${escapeShellArg version}
make -C ${engineSourceName} version VERSION=${escapeShellArg engine.version}
make version VERSION=${lib.escapeShellArg version}
make -C ${engineSourceName} version VERSION=${lib.escapeShellArg engine.version}
runHook postConfigure
'';
@ -67,22 +65,22 @@ in stdenv.mkDerivation (recursiveUpdate packageAttrs rec {
make -C ${engineSourceName} install-engine install-common-mod-files DATA_INSTALL_DIR=$out/lib/${pname}
cp -r ${engineSourceName}/mods/{${concatStringsSep "," ([ "common" "modcontent" ] ++ engine.mods)}} mods/* \
cp -r ${engineSourceName}/mods/{${lib.concatStringsSep "," ([ "common" "modcontent" ] ++ engine.mods)}} mods/* \
$out/lib/${pname}/mods/
substitute ${./mod-launch-game.sh} $out/lib/openra_2019-${mod.name}/launch-game.sh \
--subst-var out \
--subst-var-by name ${escapeShellArg mod.name} \
--subst-var-by title ${escapeShellArg mod.title} \
--subst-var-by assetsError ${escapeShellArg mod.assetsError}
--subst-var-by name ${lib.escapeShellArg mod.name} \
--subst-var-by title ${lib.escapeShellArg mod.title} \
--subst-var-by assetsError ${lib.escapeShellArg mod.assetsError}
chmod +x $out/lib/openra_2019-${mod.name}/launch-game.sh
${wrapLaunchGame "_2019-${mod.name}" "openra-${mod.name}"}
substitute ${./openra-mod.desktop} $(mkdirp $out/share/applications)/${pname}.desktop \
--subst-var-by name ${escapeShellArg mod.name} \
--subst-var-by title ${escapeShellArg mod.title} \
--subst-var-by description ${escapeShellArg mod.description}
--subst-var-by name ${lib.escapeShellArg mod.name} \
--subst-var-by title ${lib.escapeShellArg mod.title} \
--subst-var-by description ${lib.escapeShellArg mod.description}
cp README.md $(mkdirp $out/share/doc/packages/${pname})/README.md

View file

@ -37247,7 +37247,10 @@ with pkgs;
otto-matic = callPackage ../games/otto-matic { };
openraPackages_2019 = import ../games/openra_2019 pkgs.__splicedPackages;
openraPackages_2019 = import ../games/openra_2019 {
inherit lib;
pkgs = pkgs.__splicedPackages;
};
openra_2019 = openraPackages_2019.engines.release;