2024-07-31 13:51:40 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-07-01 07:14:48 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
options.build = {
|
2024-07-02 03:38:30 +00:00
|
|
|
isBinary = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
description = ''
|
|
|
|
Sets the build step to create a tiny compiled executable for the
|
|
|
|
wrapper. By default, it is set to `true`.
|
2024-07-31 05:28:21 +00:00
|
|
|
|
|
|
|
::: {.warning}
|
|
|
|
Binary wrappers cannot have runtime expansion in its arguments
|
|
|
|
especially when setting environment variables that needs it. For this,
|
|
|
|
you'll have to switch to shell wrappers (e.g., `build.isBinary =
|
|
|
|
false`).
|
|
|
|
:::
|
2024-07-02 03:38:30 +00:00
|
|
|
'';
|
|
|
|
default = true;
|
|
|
|
example = false;
|
|
|
|
};
|
|
|
|
|
2024-07-08 13:12:31 +00:00
|
|
|
extraSetup = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
2024-07-01 07:14:48 +00:00
|
|
|
description = ''
|
2024-07-08 13:12:31 +00:00
|
|
|
Additional script for setting up the wrapper script derivation.
|
2024-07-01 07:14:48 +00:00
|
|
|
'';
|
2024-07-08 13:12:31 +00:00
|
|
|
default = "";
|
2024-07-01 07:14:48 +00:00
|
|
|
};
|
|
|
|
|
2024-07-23 13:40:28 +00:00
|
|
|
extraPassthru = lib.mkOption {
|
|
|
|
type = with lib.types; attrsOf anything;
|
|
|
|
description = ''
|
|
|
|
Set of data to be passed through `passthru` of the resulting
|
|
|
|
derivation.
|
|
|
|
'';
|
|
|
|
default = { };
|
|
|
|
};
|
|
|
|
|
2024-07-01 07:14:48 +00:00
|
|
|
toplevel = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
readOnly = true;
|
|
|
|
internal = true;
|
|
|
|
description = "A derivation containing the wrapper script.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-02 03:38:30 +00:00
|
|
|
config = {
|
|
|
|
build = {
|
2024-07-08 13:12:31 +00:00
|
|
|
toplevel =
|
2024-07-02 03:38:30 +00:00
|
|
|
let
|
2024-07-31 13:51:40 +00:00
|
|
|
mkWrapBuild =
|
|
|
|
wrappers:
|
2024-07-08 13:12:31 +00:00
|
|
|
lib.concatMapStrings (v: ''
|
|
|
|
makeWrapper "${v.arg0}" "${builtins.placeholder "out"}/bin/${v.executableName}" ${lib.concatStringsSep " " v.makeWrapperArgs}
|
|
|
|
'') wrappers;
|
2024-07-09 08:03:30 +00:00
|
|
|
|
2024-07-31 13:51:40 +00:00
|
|
|
mkDesktopEntries = desktopEntries: builtins.map (entry: pkgs.makeDesktopItem entry) desktopEntries;
|
2024-07-11 09:30:40 +00:00
|
|
|
|
2024-07-31 13:51:40 +00:00
|
|
|
desktopEntries = mkDesktopEntries (lib.attrValues config.xdg.desktopEntries);
|
2024-07-02 03:38:30 +00:00
|
|
|
in
|
2024-07-31 13:51:40 +00:00
|
|
|
pkgs.symlinkJoin {
|
|
|
|
passthru = config.build.extraPassthru;
|
|
|
|
name = "wrapper-manager-fds-wrapped-package";
|
|
|
|
paths = desktopEntries ++ config.basePackages;
|
|
|
|
nativeBuildInputs =
|
|
|
|
if config.build.isBinary then [ pkgs.makeBinaryWrapper ] else [ pkgs.makeWrapper ];
|
|
|
|
postBuild = ''
|
|
|
|
${config.build.extraSetup}
|
|
|
|
${mkWrapBuild (lib.attrValues config.wrappers)}
|
|
|
|
'';
|
|
|
|
};
|
2024-07-02 03:38:30 +00:00
|
|
|
};
|
2024-07-01 07:14:48 +00:00
|
|
|
};
|
|
|
|
}
|