Add reset combinator

This commit is contained in:
Alex David 2025-11-10 11:50:37 -08:00
commit 98a6bd032c
4 changed files with 53 additions and 0 deletions

28
lib/combinators/reset.nix Normal file
View file

@ -0,0 +1,28 @@
_: {
sig = "Permission";
doc = ''
Resets the jail state back to the initial empty state.
All permissions before this one (including ones set in
[`basePermissions`](advanced-configuration.md#basepermissions)) are
removed.
This is useful if you have some permissions set in
[`basePermissions`](advanced-configuration.md#basepermissions) that you
want for most of your jails, but want to remove them in a one-off jail.
Example:
```nix
jail "some-package" some-package (combinators: with combinators; [
# First, use reset to remove the base combinators:
reset
# Then, re-apply the base combinators you want:
base
bind-nix-store-runtime-closure
fake-passwd
])
```
'';
impl = state: state.initialState;
}