Add wrap-entry combinator

This commit is contained in:
Alex David 2025-06-07 15:19:45 -07:00
commit 8d9acc76f3
2 changed files with 37 additions and 4 deletions

View file

@ -133,7 +133,11 @@
This can write to `$RUNTIME_ARGS` to push additional bubblewrap flags
dependant on runtime conditions.
For example:
Note that anything added here is *not* run inside the jail. To run
arbitrary things at runtime inside the jail see
[wrap-entry](#wrap-entry).
Example:
```nix
add-runtime ${"''"}
# binds /foo only if /bar exists on the host
@ -148,6 +152,35 @@
;
};
wrap-entry = {
sig = "(String -> String) -> Combinator";
doc = ''
Wraps the binary to be jailed in a bash script that will be the new
entrypoint to the jail.
This similar in spirit to the [add-runtime combinator](#add-runtime),
except that this runs *inside* the jail, while `add-runtime` runs before
the jail starts.
Example:
```nix
wrap-entry (entry: ${"''"}
echo 'Inside the jail!'
''${entry}
echo 'Cleaning up...'
${"''"})
```
'';
impl = _:
getWrapper: state: state // {
entry = lib.getExe (pkgs.writeShellApplication {
name = "${state.name}-jail-wrapper";
text = getWrapper state.entry;
});
}
;
};
add-pkg-deps = {
sig = "[Package] -> Combinator";
doc = ''