Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,14 @@ let
- `flagSeparator`: Separator between flag names and values when generating args from flags (optional, defaults to " ")
- `args`: List of command-line arguments like argv in execve (optional, auto-generated from flags if not provided)
- `preHook`: Shell script to run before executing the command (optional)
- `postHook`: Shell script to run after executing the command, removes the `exec` call. use with care (optional)
- `passthru`: Attribute set to pass through to the wrapped derivation (optional)
- `aliases`: List of additional names to symlink to the wrapped executable (optional)
- `filesToPatch`: List of file paths (glob patterns) to patch for self-references (optional, defaults to ["share/applications/*.desktop"])
- `filesToExclude`: List of file paths (glob patterns) to exclude from the wrapped package (optional, defaults to [])
- `patchHook`: Shell script that runs after patchPhase to modify the wrapper package files (optional)
- `wrapper`: Custom wrapper function (optional, defaults to exec'ing the original binary with args)
- Called with { env, flags, args, envString, flagsString, exePath, preHook }
- Called with { env, flags, args, envString, flagsString, exePath, preHook, postHook }

# Example

Expand Down Expand Up @@ -446,6 +447,7 @@ let
# " " for "--flag value" or "=" for "--flag=value"
args ? generateArgsFromFlags flags flagSeparator,
preHook ? "",
postHook ? "",
passthru ? { },
aliases ? [ ],
# List of file paths (glob patterns) relative to package root to patch for self-references (e.g., ["bin/*", "lib/*.sh"])
Expand All @@ -459,12 +461,14 @@ let
flagsString,
envString,
preHook,
postHook,
...
}:
''
${envString}
${preHook}
exec ${exePath}${flagsString} "$@"
${lib.optionalString (postHook == "") "exec"} ${exePath}${flagsString} "$@"
${postHook}
''
),
}@funcArgs:
Expand Down Expand Up @@ -497,6 +501,7 @@ let
flagsString
exePath
preHook
postHook
;
};

Expand Down Expand Up @@ -654,6 +659,7 @@ let
flags
args
preHook
postHook
aliases
;
override =
Expand Down
10 changes: 10 additions & 0 deletions lib/modules/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@
Shell script to run before executing the command.
'';
};
options.postHook = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Shell script to run after executing the command.
Removes the `exec` call in the wrapper script which will leave a bash process
in the background, therefore use with care.
'';
};
options.exePath = lib.mkOption {
type = lib.types.path;
description = ''
Expand Down Expand Up @@ -138,6 +147,7 @@
filesToPatch = config.filesToPatch;
filesToExclude = config.filesToExclude;
preHook = config.preHook;
postHook = config.postHook;
patchHook = config.patchHook;
passthru = {
configuration = config;
Expand Down
Loading