Add experimental overlay combinators

This commit is contained in:
Alex David 2026-04-14 22:26:43 -07:00
commit 404e7da9da
4 changed files with 191 additions and 0 deletions

View file

@ -0,0 +1,32 @@
{ combinators, ... }:
let
inherit (combinators) escape unsafe-add-raw-args;
in
{
experimental = true;
sig = "[String] -> String -> Permission";
doc = ''
Creates a tempfs overlay mount at a destination.
The first argument is a list of sources to be composed, the second is the
destination in the jail where to mount the overlayfs.
If multiple sources contain the same files, sources specified later in the
sources list will shadow earlier ones.
At least one source must be specified.
Example:
```nix
overlay-tmp ["/source/foo" "/source/bar"] "/dest"
```
'';
impl =
sources: dest:
assert builtins.length sources > 0;
unsafe-add-raw-args (
builtins.concatStringsSep " " (
map (source: "--overlay-src ${escape source}") sources ++ [ "--tmp-overlay ${escape dest}" ]
)
);
}