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

init openra-mods #53163

Closed
wants to merge 1 commit into from
Closed

init openra-mods #53163

wants to merge 1 commit into from

Conversation

msteen
Copy link
Contributor

@msteen msteen commented Jan 2, 2019

Motivation for this change

There are many more OpenRA mods than those supplied by default in the OpenRA engine, 10 of those are included in this PR (thanks to @fusion809). All of the included mods follow the same structure, so a generic package definitions has been defined.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@@ -0,0 +1,25 @@
diff --git a/Makefile b/Makefile
Copy link
Member

Choose a reason for hiding this comment

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

You are providing a bunch of patches that deactivate fetch-engine.sh. Why not just replace the file itself to a script that does no-op or a symlink to ${coreutils}/bin/true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, sometimes you become blind to obvious solutions like these. A symlink was not allowed, but makeWrapper ${coreutils}/bin/true fetch-engine.sh works great.

name = "d2";
version = "124";
title = "Dune II";
description = "Re-imaginging of the original Command & Conquer: Red Alert 2 game";
Copy link
Member

@veprbl veprbl Jan 2, 2019

Choose a reason for hiding this comment

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

There seem to be some mismatched descriptions.

'';

in [
{
Copy link
Member

Choose a reason for hiding this comment

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

In nixpkgs a more idiomatic approach would be to introduce a function like buildOpenRAMod (come up with a better name) and then to have attribute set:

{
  inherit buildOpenRAMod;

  redalert2 = buildOpenRAMod {
    version = "123";
    engine = {
      # ...
    };
    # ...
  };

  # ...
}

Then buildOpenRAMod can be reused by external mods.

Copy link
Contributor Author

@msteen msteen Jan 2, 2019

Choose a reason for hiding this comment

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

This can already be done by just importing pkgs/games/openra-mods/default.nix, which I would argue is just as common practice, but I agree a function is prettier.

@@ -0,0 +1,16 @@
#!/bin/sh
Copy link
Member

Choose a reason for hiding this comment

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

Great wrapper. Probably doesn't belong here, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where else would it go?

dontStrip = true;

meta = {
description = mod.description;
Copy link
Member

Choose a reason for hiding this comment

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

inherit (mod) description;

lua = lua5_1;
inherit (gnome3) zenity;
} // attrs);
}) (import ../games/openra-mods/mods.nix { inherit fetchFromGitHub; }));
Copy link
Member

Choose a reason for hiding this comment

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

Can this replace openra?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered it, but it will complicate the generic mod package definition, because it is structured around having a mod with an engine. I can try to make the mod optional and adding a bunch of conditionals, but if that becomes to unwieldy, I will keep it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried it, but it would complicate matters too much, better to keep it packaged separately.

makeWrapper $out/lib/openra-${mod.name}/launch-game.sh $out/bin/openra-${mod.name} \
--run "cd $out/lib/openra-${mod.name}"

cp -r ${engine.src.name}/{${concatStringsSep "," [
Copy link
Member

Choose a reason for hiding this comment

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

I don't see why you need to do concatStringsSep in nix antiquotation here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to? No. Want to? Yes, this way I can clearly see the list of files that need to be copied over.

description = mod.description;
homepage = mod.homepage;
maintainers = with maintainers; [ msteen ];
license = licenses.gpl3;
Copy link
Member

Choose a reason for hiding this comment

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

Did you really check that every mod is gpl3?

pkgs/games/openra-mods/mods.nix Show resolved Hide resolved
--subst-var-by title ${escapeShellArg mod.title}

mkdir -p $out/share/doc/packages/openra-${mod.name}
cp README.md $out/share/doc/packages/openra-${mod.name}/README.md
Copy link
Member

Choose a reason for hiding this comment

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

Can use

install -Dm444 README.md $out/share/doc/packages/openra-${mod.name}/README.md

it will even create the directory for you

makeWrapper $out/lib/openra-${mod.name}/launch-game.sh $out/bin/openra-${mod.name} \
--run "cd $out/lib/openra-${mod.name}"

cp -r ${engine.src.name}/{${concatStringsSep "," [
Copy link
Member

Choose a reason for hiding this comment

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

is it documented somewhere what files are needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I based it on https://build.opensuse.org/package/view_file/home:fusion809/openra-ura/PKGBUILD?expand=1, but it in turn is based on what is installed by the engine. Maybe I can leverage the Makefile that does the installation https://github.com/OpenRA/OpenRA/blob/bleed/Makefile to not having to have a hardcoded list anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, leveraging the Makefile of the engine, this code is no longer needed.

@@ -0,0 +1,293 @@
{ fetchFromGitHub }:
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a way to keep this file up to date?

@msteen msteen mentioned this pull request Jan 3, 2019
10 tasks
@msteen
Copy link
Contributor Author

msteen commented Jan 3, 2019

Closing in favor of #53300.

@msteen msteen closed this Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants