4 /* Building an engine or out-of-tree mod is very similar,
5 but different enough not to be able to build them with the same package definition,
6 so instaed we define what is common between them in a separate file.
8 Although `callPackage` could be used, it would require undoing `makeOverridable`,
9 because `common.nix` does not define a package, but just an attribute set,
10 which is directly passed as part of the argument to the engines and mods `callPackage`,
11 so either the attributes added by `makeOverridable` have to be removed
12 or the engine and mod package definitions will need to add `...` to the argument list.
14 common = let f = import ./common.nix; in f (builtins.intersectAttrs (builtins.functionArgs f) pkgs // {
16 # It is not necessary to run the game, but it is nicer to be given an error dialog in the case of failure,
17 # rather than having to look to the logs why it is not starting.
18 inherit (pkgs.gnome) zenity;
21 /* Building a set of engines or mods requires some dependencies as well,
22 so the sets will actually be defined as a function instead,
23 requiring the dependencies and returning the actual set.
25 Not all dependencies for defining a engine or mod set are shared,
26 so additional arguments can be passed as well.
28 The builders for engines and mods allow to delay specifying the name,
29 by returning a function that expects a name, which we use, in this case,
30 to base the name on the attribute name instead, preventing the need to specify the name twice
31 if the attribute name and engine/mod name are equal.
33 buildOpenRASet = f: args: builtins.mapAttrs (name: value: if builtins.isFunction value then value name else value) (f ({
34 inherit (pkgs) fetchFromGitHub;
36 sed -i 's/curl/curl --insecure/g' $out/thirdparty/{fetch-thirdparty-deps,noget}.sh
37 $out/thirdparty/fetch-thirdparty-deps.sh
42 # The whole attribute set is destructered to ensure those (and only those) attributes are given
43 # and to provide defaults for those that are optional.
44 buildOpenRAEngine = { name ? null, version, description, homepage, mods, src, installExperimental ? "" }@engine:
45 # Allow specifying the name at a later point if no name has been given.
46 let builder = name: pkgs.callPackage ./engine.nix (common // {
47 engine = engine // { inherit name installExperimental; };
48 }); in if name == null then builder else builder name;
50 # See `buildOpenRAEngine`.
51 buildOpenRAMod = { name ? null, version, title, description, homepage, src, engine }@mod: ({ version, mods ? [], src }@engine:
52 let builder = name: pkgs.callPackage ./mod.nix (common // {
53 mod = mod // { inherit name; };
54 engine = engine // { inherit mods; };
55 }); in if name == null then builder else builder name) engine;
57 # See `buildOpenRASet`.
58 engines = buildOpenRASet (import ./engines.nix) { inherit buildOpenRAEngine; };
59 mods = buildOpenRASet (import ./mods.nix) { inherit buildOpenRAMod; };