Split combinators into files

The `lib/combinators.nix` file was getting quite long and some ideas I
have for future combinators may even require ancillary files. To help
scale these changes, this commit breaks each combinator into its own
file under the `lib/combinators` directory.
This commit is contained in:
Alex David 2025-10-04 09:34:19 -07:00
commit 6181276ae1
54 changed files with 1531 additions and 1260 deletions

View file

@ -0,0 +1,32 @@
{ helpers, ... }:
{
sig = "String -> Permission";
doc = ''
Adds arbitrary logic to run when the jail exits.
This is designed to be an easy way to register cleanup actions for things
created in [add-runtime](#add-runtime). These scripts run in the same
scope as `add-runtime` so any shell variables defined there will be in
scope.
The cleanup actions may run even if the runtime doesn't— for example if a
previous runtime exits non-zero the jail will exit prematurely, but the
cleanup actions will still run.
Example:
```nix
compose [
(add-runtime ${"''"}
TMP_FILE=$(mktemp)
do-something "$TMP_FILE"
${"''"})
(add-cleanup ${"''"}
if [ -e "${"''"}''${TMP_FILE-}" ]; then
rm "$TMP_FILE"
fi
${"''"})
]
```
'';
impl = helpers.pushState "cleanup";
}