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 =
_: combinator: state:
state // { deferredPermissions = state.deferredPermissions ++ [ combinator ]; };
__functor = _: helpers.pushState "deferredPermissions";
};
include-once = {
@ -165,7 +163,7 @@ rec {
if lib.elem key state.includedOnce then
state
else
combinator (state // { includedOnce = state.includedOnce ++ [ key ]; });
combinator (helpers.pushState "includedOnce" key state);
};
unsafe-add-raw-args = {
@ -265,9 +263,7 @@ rec {
]
```
'';
__functor =
_: cleanup: state:
state // { cleanup = state.cleanup ++ [ cleanup ]; };
__functor = _: helpers.pushState "cleanup";
};
fake-passwd = {
@ -997,12 +993,7 @@ rec {
}:
compose [
# Just set the options on state so dbus can be called multiple times
(
state:
state
// {
dbusPermissions = state.dbusPermissions ++ [
{
(helpers.pushState "dbusPermissions" {
inherit
own
talk
@ -1010,10 +1001,7 @@ rec {
call
broadcast
;
}
];
}
)
})
# Then add deferred runtime logic to spin up xdg-dbus-proxy:
(include-once "dbus" (
defer (
@ -1102,7 +1090,7 @@ rec {
_: path: pkg:
compose [
(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
else
pkgs.lib.strings.escapeShellArg rawOrStr;
pushState =
key: toPush: state:
state // { ${key} = state.${key} ++ [ toPush ]; };
}