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;
|
||||
helpers = import ./helpers.nix pkgs;
|
||||
|
||||
rawCombinators =
|
||||
lib.mapAttrs
|
||||
(
|
||||
_: file:
|
||||
import file {
|
||||
inherit
|
||||
combinators
|
||||
helpers
|
||||
jail
|
||||
lib
|
||||
pkgs
|
||||
;
|
||||
}
|
||||
)
|
||||
{
|
||||
add-cleanup = ./combinators/add-cleanup.nix;
|
||||
add-path = ./combinators/add-path.nix;
|
||||
add-pkg-deps = ./combinators/add-pkg-deps.nix;
|
||||
add-runtime = ./combinators/add-runtime.nix;
|
||||
add-seccomp = ./combinators/add-seccomp.nix;
|
||||
base = ./combinators/base.nix;
|
||||
bind-nix-store-runtime-closure = ./combinators/bind-nix-store-runtime-closure.nix;
|
||||
bind-pkg = ./combinators/bind-pkg.nix;
|
||||
camera = ./combinators/camera.nix;
|
||||
compose = ./combinators/compose.nix;
|
||||
dbus = ./combinators/dbus.nix;
|
||||
defer = ./combinators/defer.nix;
|
||||
escape = ./combinators/escape.nix;
|
||||
fake-passwd = ./combinators/fake-passwd.nix;
|
||||
fwd-env = ./combinators/fwd-env.nix;
|
||||
gpu = ./combinators/gpu.nix;
|
||||
gui = ./combinators/gui.nix;
|
||||
include-once = ./combinators/include-once.nix;
|
||||
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;
|
||||
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: combinatorImpl:
|
||||
if lib.length names == 0 then
|
||||
acc
|
||||
else
|
||||
let
|
||||
name = lib.head names;
|
||||
in
|
||||
if acc ? ${name} then
|
||||
throw "duplicate combinator ${name}"
|
||||
else
|
||||
foldCombinator (acc // { ${name} = combinatorImpl; }) (lib.tail names) combinatorImpl;
|
||||
in
|
||||
lib.foldl' (
|
||||
acc: { name, value }: foldCombinator acc ([ name ] ++ value.aliases or [ ]) value.impl
|
||||
) { } (lib.attrsToList rawCombinators);
|
||||
in
|
||||
{
|
||||
inherit combinators;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue