Implement combinator aliases
To make it easier to rename combinators without breaking anyone's configuration, this change allows combinators to specify a list of `aliases` that are also exported from `jail.combinators`. The aliases are also documented on the documentation website.
This commit is contained in:
parent
49aa817e4f
commit
7acd363b6d
2 changed files with 40 additions and 73 deletions
|
|
@ -3,79 +3,39 @@ let
|
||||||
inherit (pkgs) lib;
|
inherit (pkgs) lib;
|
||||||
helpers = import ./helpers.nix pkgs;
|
helpers = import ./helpers.nix pkgs;
|
||||||
|
|
||||||
rawCombinators =
|
rawCombinators = lib.mapAttrs' (
|
||||||
lib.mapAttrs
|
fileName: _:
|
||||||
(
|
lib.nameValuePair (lib.removeSuffix ".nix" fileName) (
|
||||||
_: file:
|
import ./combinators/${fileName} {
|
||||||
import file {
|
inherit
|
||||||
inherit
|
combinators
|
||||||
combinators
|
helpers
|
||||||
helpers
|
jail
|
||||||
jail
|
lib
|
||||||
lib
|
pkgs
|
||||||
pkgs
|
;
|
||||||
;
|
}
|
||||||
}
|
)
|
||||||
)
|
) (builtins.readDir ./combinators);
|
||||||
{
|
|
||||||
add-cleanup = ./combinators/add-cleanup.nix;
|
combinators =
|
||||||
add-path = ./combinators/add-path.nix;
|
let
|
||||||
add-pkg-deps = ./combinators/add-pkg-deps.nix;
|
foldCombinator =
|
||||||
add-runtime = ./combinators/add-runtime.nix;
|
acc: names: combinatorImpl:
|
||||||
add-seccomp = ./combinators/add-seccomp.nix;
|
if lib.length names == 0 then
|
||||||
base = ./combinators/base.nix;
|
acc
|
||||||
bind-nix-store-runtime-closure = ./combinators/bind-nix-store-runtime-closure.nix;
|
else
|
||||||
bind-pkg = ./combinators/bind-pkg.nix;
|
let
|
||||||
camera = ./combinators/camera.nix;
|
name = lib.head names;
|
||||||
compose = ./combinators/compose.nix;
|
in
|
||||||
dbus = ./combinators/dbus.nix;
|
if acc ? ${name} then
|
||||||
defer = ./combinators/defer.nix;
|
throw "duplicate combinator ${name}"
|
||||||
escape = ./combinators/escape.nix;
|
else
|
||||||
fake-passwd = ./combinators/fake-passwd.nix;
|
foldCombinator (acc // { ${name} = combinatorImpl; }) (lib.tail names) combinatorImpl;
|
||||||
fwd-env = ./combinators/fwd-env.nix;
|
in
|
||||||
gpu = ./combinators/gpu.nix;
|
lib.foldl' (
|
||||||
gui = ./combinators/gui.nix;
|
acc: { name, value }: foldCombinator acc ([ name ] ++ value.aliases or [ ]) value.impl
|
||||||
include-once = ./combinators/include-once.nix;
|
) { } (lib.attrsToList rawCombinators);
|
||||||
jail-to-host-channel = ./combinators/jail-to-host-channel.nix;
|
|
||||||
mount-cwd = ./combinators/mount-cwd.nix;
|
|
||||||
network = ./combinators/network.nix;
|
|
||||||
no-die-with-parent = ./combinators/no-die-with-parent.nix;
|
|
||||||
no-new-session = ./combinators/no-new-session.nix;
|
|
||||||
noescape = ./combinators/noescape.nix;
|
|
||||||
notifications = ./combinators/notifications.nix;
|
|
||||||
open-urls-in-browser = ./combinators/open-urls-in-browser.nix;
|
|
||||||
persist-home = ./combinators/persist-home.nix;
|
|
||||||
pipewire = ./combinators/pipewire.nix;
|
|
||||||
pulse = ./combinators/pulse.nix;
|
|
||||||
readonly = ./combinators/readonly.nix;
|
|
||||||
readonly-paths-from-var = ./combinators/readonly-paths-from-var.nix;
|
|
||||||
readonly-runtime-args = ./combinators/readonly-runtime-args.nix;
|
|
||||||
readwrite = ./combinators/readwrite.nix;
|
|
||||||
readwrite-runtime-args = ./combinators/readwrite-runtime-args.nix;
|
|
||||||
reset = ./combinators/reset.nix;
|
|
||||||
ro-bind = ./combinators/ro-bind.nix;
|
|
||||||
runtime-deep-ro-bind = ./combinators/runtime-deep-ro-bind.nix;
|
|
||||||
rw-bind = ./combinators/rw-bind.nix;
|
|
||||||
set-argv = ./combinators/set-argv.nix;
|
|
||||||
set-env = ./combinators/set-env.nix;
|
|
||||||
set-hostname = ./combinators/set-hostname.nix;
|
|
||||||
share-ns = ./combinators/share-ns.nix;
|
|
||||||
time-zone = ./combinators/time-zone.nix;
|
|
||||||
tmpfs = ./combinators/tmpfs.nix;
|
|
||||||
try-fwd-env = ./combinators/try-fwd-env.nix;
|
|
||||||
try-readonly = ./combinators/try-readonly.nix;
|
|
||||||
try-readwrite = ./combinators/try-readwrite.nix;
|
|
||||||
try-ro-bind = ./combinators/try-ro-bind.nix;
|
|
||||||
try-rw-bind = ./combinators/try-rw-bind.nix;
|
|
||||||
unsafe-add-raw-args = ./combinators/unsafe-add-raw-args.nix;
|
|
||||||
unsafe-dbus = ./combinators/unsafe-dbus.nix;
|
|
||||||
unsafe-x11 = ./combinators/unsafe-x11.nix;
|
|
||||||
wayland = ./combinators/wayland.nix;
|
|
||||||
wrap-entry = ./combinators/wrap-entry.nix;
|
|
||||||
write-text = ./combinators/write-text.nix;
|
|
||||||
xwayland = ./combinators/xwayland.nix;
|
|
||||||
};
|
|
||||||
combinators = lib.mapAttrs (_: combinatorObj: combinatorObj.impl) rawCombinators;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit combinators;
|
inherit combinators;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,13 @@
|
||||||
|
|
||||||
**${name} :: ${combinatorObj.sig}**
|
**${name} :: ${combinatorObj.sig}**
|
||||||
|
|
||||||
|
${
|
||||||
|
if combinatorObj ? aliases then
|
||||||
|
"Aliases: ${lib.concatMapStringsSep ", " (alias: "`${alias}`") combinatorObj.aliases}"
|
||||||
|
else
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
${combinatorObj.doc}
|
${combinatorObj.doc}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue