1 /* This file defines all OpenRA packages under `openraPackages`,
2 e.g. the OpenRA release engine can be found at `openraPackages.engines.release` (see `engines.nix`),
3 or the out-of-tree mod "Combined Arms" can be found at `openraPackages.mods.ca` (see `mods.nix`).
4 The `openra` package is just an alias to `openraPackages.engines.release`,
5 and just provides the mods included in the source code of the engine.
6 Additional engines or mods can be added with `openraPackages.buildOpenRAEngine` (function around `engine.nix`)
7 and `openraPackages.buildOpenRAMod` (function around `mod.nix`), respectively.
12 /* Building an engine or out-of-tree mod is very similar,
13 but different enough not to be able to build them with the same package definition,
14 so instaed we define what is common between them in a separate file.
16 Although `callPackage` could be used, it would require undoing `makeOverridable`,
17 because `common.nix` does not define a package, but just an attribute set,
18 which is directly passed as part of the argument to the engines and mods `callPackage`,
19 so either the attributes added by `makeOverridable` have to be removed
20 or the engine and mod package definitions will need to add `...` to the argument list.
23 f = import ./common.nix;
24 fArgs = lib.functionArgs f;
25 in f (builtins.intersectAttrs fArgs pkgs // {
29 /* Building a set of engines or mods requires some dependencies as well,
30 so the sets will actually be defined as a function instead,
31 requiring the dependencies and returning the actual set.
33 Not all dependencies for defining a engine or mod set are shared,
34 so additional arguments can be passed as well.
36 The builders for engines and mods allow to delay specifying the name,
37 by returning a function that expects a name, which we use, in this case,
38 to base the name on the attribute name instead, preventing the need to specify the name twice
39 if the attribute name and engine/mod name are equal.
41 callWithName = name: value: if lib.isFunction value then value name else value;
42 buildOpenRASet = f: args: pkgs.recurseIntoAttrs (lib.mapAttrs callWithName (f ({
43 inherit (pkgs) fetchFromGitHub;
45 sed -i 's/curl/curl --insecure/g' $out/thirdparty/{fetch-thirdparty-deps,noget}.sh
46 $out/thirdparty/fetch-thirdparty-deps.sh
50 in pkgs.recurseIntoAttrs rec {
51 # The whole attribute set is destructered to ensure those (and only those) attributes are given
52 # and to provide defaults for those that are optional.
53 buildOpenRAEngine = { name ? null, version, description, homepage, mods, src }@engine:
54 # Allow specifying the name at a later point if no name has been given.
55 let builder = name: pkgs.callPackage ./engine.nix (common // {
56 engine = engine // { inherit name; };
58 in if name == null then builder else builder name;
60 # See `buildOpenRAEngine`.
61 buildOpenRAMod = { name ? null, version, title, description, homepage, src, engine, assetsError ? "" }@mod: ({ version, mods ? [], src }@engine:
62 let builder = name: pkgs.callPackage ./mod.nix (common // {
63 mod = mod // { inherit name assetsError; };
64 engine = engine // { inherit mods; };
66 in if name == null then builder else builder name) engine;
68 # See `buildOpenRASet`.
69 engines = buildOpenRASet (import ./engines.nix) { inherit buildOpenRAEngine; };
70 mods = buildOpenRASet (import ./mods.nix) { inherit buildOpenRAMod; };