openraPackages_2019: remove usages of with lib;

This commit is contained in:
mdarocha 2023-06-22 17:09:40 +02:00
parent f55321995c
commit 8f3b487ee4
3 changed files with 25 additions and 24 deletions

View file

@ -8,9 +8,9 @@
*/
pkgs:
with pkgs.lib;
let
lib = pkgs.lib;
/* Building an engine or out-of-tree mod is very similar,
but different enough not to be able to build them with the same package definition,
so instaed we define what is common between them in a separate file.
@ -21,7 +21,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 +43,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 +59,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