wrapper-manager-fds/lib: add option to make compiled wrappers

Also fix a bunch of things such as the correct filename for the Nix
store path and everything.
This commit is contained in:
Gabriel Arazas 2024-07-01 22:30:57 +08:00
parent 253e5f583c
commit 33746744c3

View File

@ -11,16 +11,18 @@
mkWrapper = { mkWrapper = {
arg0, arg0,
executableName ? arg0, executableName ? arg0,
makeWrapperArgs ? [ ], isBinary ? true,
makeWrapperArgs ? [ ],
nativeBuildInputs ? [ ], nativeBuildInputs ? [ ],
passthru ? { }, passthru ? { },
}@args: }@args:
pkgs.runCommand "wrapper-manager-script-${arg0}" ( pkgs.runCommand "wrapper-manager-script-${executableName}" (
(builtins.removeAttrs args [ "executableName" "arg0" ]) (builtins.removeAttrs args [ "executableName" "arg0" "isBinary" ])
// { // {
inherit makeWrapperArgs; inherit makeWrapperArgs;
nativeBuildInputs = nativeBuildInputs ++ [ pkgs.makeWrapper ]; nativeBuildInputs = nativeBuildInputs ++
(if isBinary then [ pkgs.makeBinaryWrapper ] else [ pkgs.makeWrapper ]);
passthru = passthru // { passthru = passthru // {
wrapperScript = { inherit arg0 executableName; }; wrapperScript = { inherit arg0 executableName; };
@ -28,12 +30,15 @@
} }
) '' ) ''
mkdir -p $out/bin mkdir -p $out/bin
makeWrapper ${arg0} "$out/bin/${executableName}" ''${makeWrapperArgs[@]} makeWrapper "${arg0}" "$out/bin/${executableName}" ''${makeWrapperArgs[@]}
''; '';
/* Similar to `mkWrapper` but include the output of the given package. */
mkWrappedPackage = { mkWrappedPackage = {
package, package,
executableName ? package.meta.mainProgram or package.pname, executableName ? package.meta.mainProgram or package.pname,
extraPackages ? [ ],
isBinary ? true,
postBuild ? "", postBuild ? "",
nativeBuildInputs ? [ ], nativeBuildInputs ? [ ],
@ -41,20 +46,20 @@
passthru ? { }, passthru ? { },
}@args: }@args:
pkgs.symlinkJoin ( pkgs.symlinkJoin (
(builtins.removeAttrs args [ "package" "executableName" ]) (builtins.removeAttrs args [ "package" "executableName" "extraPackages" "isBinary" ])
// { // {
name = "wrapper-manager-wrapped-package-${package.pname}"; name = "wrapper-manager-wrapped-package-${package.pname}";
paths = [ package ]; paths = [ package ] ++ extraPackages;
inherit makeWrapperArgs; inherit makeWrapperArgs;
nativeBuildInputs = nativeBuildInputs ++ [ pkgs.makeWrapper ]; nativeBuildInputs = nativeBuildInputs ++
(if isBinary then [ pkgs.makeBinaryWrapper ] else [ pkgs.makeWrapper ]);
passthru = passthru // { passthru = passthru // {
wrapperScript = { inherit executableName package; }; wrapperScript = { inherit executableName package; };
}; };
postBuild = '' postBuild = ''
${postBuild} ${postBuild}
wrapProgram "${lib.getExe' package executableName}" ''${makeWrapperArgs[@]} wrapProgram "$out/bin/${executableName}" ''${makeWrapperArgs[@]}
''; '';
}); });
} }