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.
53 lines
1.3 KiB
Nix
53 lines
1.3 KiB
Nix
{
|
|
pkgs,
|
|
suppressExperimentalWarnings ? false,
|
|
...
|
|
}:
|
|
jail:
|
|
let
|
|
inherit (pkgs) lib;
|
|
helpers = import ./helpers.nix pkgs;
|
|
|
|
rawCombinators = lib.mapAttrs' (
|
|
fileName: _:
|
|
lib.nameValuePair (lib.removeSuffix ".nix" fileName) (
|
|
import ./combinators/${fileName} {
|
|
inherit
|
|
combinators
|
|
helpers
|
|
jail
|
|
lib
|
|
pkgs
|
|
;
|
|
}
|
|
)
|
|
) (builtins.readDir ./combinators);
|
|
|
|
combinators =
|
|
let
|
|
foldCombinator =
|
|
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) combinator;
|
|
in
|
|
lib.foldl' (acc: { name, value }: foldCombinator acc ([ name ] ++ value.aliases or [ ]) value) { } (
|
|
lib.attrsToList rawCombinators
|
|
);
|
|
in
|
|
{
|
|
inherit combinators;
|
|
docs = rawCombinators;
|
|
}
|