Add pushState helper

This commit is contained in:
Alex David 2025-09-28 15:58:58 -07:00
commit 22ec74b9d1
2 changed files with 17 additions and 25 deletions

View file

@ -119,9 +119,7 @@ rec {
]) ])
``` ```
''; '';
__functor = __functor = _: helpers.pushState "deferredPermissions";
_: combinator: state:
state // { deferredPermissions = state.deferredPermissions ++ [ combinator ]; };
}; };
include-once = { include-once = {
@ -165,7 +163,7 @@ rec {
if lib.elem key state.includedOnce then if lib.elem key state.includedOnce then
state state
else else
combinator (state // { includedOnce = state.includedOnce ++ [ key ]; }); combinator (helpers.pushState "includedOnce" key state);
}; };
unsafe-add-raw-args = { unsafe-add-raw-args = {
@ -265,9 +263,7 @@ rec {
] ]
``` ```
''; '';
__functor = __functor = _: helpers.pushState "cleanup";
_: cleanup: state:
state // { cleanup = state.cleanup ++ [ cleanup ]; };
}; };
fake-passwd = { fake-passwd = {
@ -997,23 +993,15 @@ rec {
}: }:
compose [ compose [
# Just set the options on state so dbus can be called multiple times # Just set the options on state so dbus can be called multiple times
( (helpers.pushState "dbusPermissions" {
state: inherit
state own
// { talk
dbusPermissions = state.dbusPermissions ++ [ see
{ call
inherit broadcast
own ;
talk })
see
call
broadcast
;
}
];
}
)
# Then add deferred runtime logic to spin up xdg-dbus-proxy: # Then add deferred runtime logic to spin up xdg-dbus-proxy:
(include-once "dbus" ( (include-once "dbus" (
defer ( defer (
@ -1102,7 +1090,7 @@ rec {
_: path: pkg: _: path: pkg:
compose [ compose [
(ro-bind (toString pkg) path) (ro-bind (toString pkg) path)
(state: state // { additionalRuntimeClosures = state.additionalRuntimeClosures ++ [ pkg ]; }) (helpers.pushState "additionalRuntimeClosures" pkg)
]; ];
}; };

View file

@ -11,4 +11,8 @@ pkgs: rec {
rawOrStr._noescape rawOrStr._noescape
else else
pkgs.lib.strings.escapeShellArg rawOrStr; pkgs.lib.strings.escapeShellArg rawOrStr;
pushState =
key: toPush: state:
state // { ${key} = state.${key} ++ [ toPush ]; };
} }