Add experimental combinator handling

I have a few combinator ideas that I'd like to try adding but I still
haven't fully fleshed them out yet. In order to reduce breaking people's
setup, this introduces a new `experimental` flag on combinators that
separates them on the docs website to let users know that their design
may not be fully finalized yet.
This commit is contained in:
Alex David 2026-04-14 22:23:19 -07:00
commit 731ba22f60
5 changed files with 45 additions and 12 deletions

View file

@ -1,4 +1,9 @@
pkgs: jail:
{
pkgs,
suppressExperimentalWarnings ? false,
...
}:
jail:
let
inherit (pkgs) lib;
helpers = import ./helpers.nix pkgs;
@ -21,21 +26,26 @@ let
combinators =
let
foldCombinator =
acc: names: combinatorImpl:
acc: names: combinator:
if lib.length names == 0 then
acc
else
let
name = lib.head names;
combinatorImpl =
if combinator.experimental or false && !suppressExperimentalWarnings then
builtins.warn "jail.nix combinator ${name} is experimental!" combinator.impl
else
combinator.impl;
in
if acc ? ${name} then
throw "duplicate combinator ${name}"
else
foldCombinator (acc // { ${name} = combinatorImpl; }) (lib.tail names) combinatorImpl;
foldCombinator (acc // { ${name} = combinatorImpl; }) (lib.tail names) combinator;
in
lib.foldl' (
acc: { name, value }: foldCombinator acc ([ name ] ++ value.aliases or [ ]) value.impl
) { } (lib.attrsToList rawCombinators);
lib.foldl' (acc: { name, value }: foldCombinator acc ([ name ] ++ value.aliases or [ ]) value) { } (
lib.attrsToList rawCombinators
);
in
{
inherit combinators;

View file

@ -1,13 +1,14 @@
{
jailNixCfg@{
pkgs,
additionalCombinators ? _: { },
basePermissions ? import ./base-permissions.nix pkgs,
bubblewrapPackage ? pkgs.bubblewrap,
...
}:
let
inherit (pkgs) lib;
builtinCombinators = (import ./combinators.nix pkgs jail).combinators;
builtinCombinators = (import ./combinators.nix jailNixCfg jail).combinators;
allCombinators = builtinCombinators // additionalCombinators builtinCombinators;