mirror of
https://github.com/lhns/steam-frame-nix.git
synced 2026-10-06 05:00:24 +02:00
lib: mkPatch extraArgs (further JS arguments, may be build outputs)
This commit is contained in:
1 parent
227705b20d
commit
c672cffc9e
1 file changed
+24
-10
+24
-10
@@ -28,14 +28,28 @@ in {
|
|||||||
|
|
||||||
# name: file name (and default signatures entry); src: the patch file;
|
# name: file name (and default signatures entry); src: the patch file;
|
||||||
# signatures: `sigs` (default: signatures.json entry `name`, else none);
|
# signatures: `sigs` (default: signatures.json entry `name`, else none);
|
||||||
# opts: JSON-serialisable options.
|
# opts: JSON-serialisable options; extraArgs: files or derivations with JS
|
||||||
mkPatch = { name, src, signatures ? sigFile.patches.${name}.modules or { }, opts ? { } }:
|
# expressions passed as further arguments after hooks (built with
|
||||||
pkgs.writeText "${name}.js" ''
|
# runCommand, so they may be build outputs, e.g. generated data).
|
||||||
(${builtins.readFile src}
|
mkPatch = { name, src, signatures ? sigFile.patches.${name}.modules or { }, opts ? { }, extraArgs ? [ ] }:
|
||||||
)(${builtins.readFile ./finders.js}
|
if extraArgs == [ ] then
|
||||||
, ${builtins.toJSON signatures}
|
pkgs.writeText "${name}.js" ''
|
||||||
, ${builtins.toJSON opts}
|
(${builtins.readFile src}
|
||||||
, ${builtins.readFile ./hooks.js}
|
)(${builtins.readFile ./finders.js}
|
||||||
)
|
, ${builtins.toJSON signatures}
|
||||||
'';
|
, ${builtins.toJSON opts}
|
||||||
|
, ${builtins.readFile ./hooks.js}
|
||||||
|
)
|
||||||
|
''
|
||||||
|
else
|
||||||
|
pkgs.runCommand "${name}.js" { } ''
|
||||||
|
{
|
||||||
|
echo '('; cat ${src}; echo ')('; cat ${./finders.js}
|
||||||
|
echo ','; echo ${pkgs.lib.escapeShellArg (builtins.toJSON signatures)}
|
||||||
|
echo ','; echo ${pkgs.lib.escapeShellArg (builtins.toJSON opts)}
|
||||||
|
echo ','; cat ${./hooks.js}
|
||||||
|
for f in ${pkgs.lib.escapeShellArgs (map (f: "${f}") extraArgs)}; do echo ','; cat "$f"; done
|
||||||
|
echo ')'
|
||||||
|
} > $out
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user