mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-04-18 18:19:12 +00:00
nixos/programs/{gnome-session,sessiond}: improve code
This commit is contained in:
parent
b9f5a68061
commit
485ac7a4c4
@ -115,15 +115,15 @@ let
|
|||||||
)
|
)
|
||||||
cfg.sessions;
|
cfg.sessions;
|
||||||
|
|
||||||
sessionSystemdUnits = lib.mapAttrsToList
|
sessionSystemdUnits = lib.concatMapAttrs
|
||||||
(name: session:
|
(name: session:
|
||||||
let
|
let
|
||||||
inherit (utils.systemdUtils.lib)
|
inherit (utils.systemdUtils.lib)
|
||||||
pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit;
|
pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit;
|
||||||
componentsUnits =
|
componentsUnits =
|
||||||
lib.foldlAttrs
|
lib.concatMapAttrs
|
||||||
(acc: name: component:
|
(name: component:
|
||||||
acc // {
|
{
|
||||||
"${component.id}.service" = serviceToUnit component.id component.serviceUnit;
|
"${component.id}.service" = serviceToUnit component.id component.serviceUnit;
|
||||||
"${component.id}.target" = targetToUnit component.id component.targetUnit;
|
"${component.id}.target" = targetToUnit component.id component.targetUnit;
|
||||||
} // lib.optionalAttrs (component.socketUnit != null) {
|
} // lib.optionalAttrs (component.socketUnit != null) {
|
||||||
@ -133,7 +133,6 @@ let
|
|||||||
} // lib.optionalAttrs (component.pathUnit != null) {
|
} // lib.optionalAttrs (component.pathUnit != null) {
|
||||||
"${component.id}.path" = pathToUnit component.id component.pathUnit;
|
"${component.id}.path" = pathToUnit component.id component.pathUnit;
|
||||||
})
|
})
|
||||||
{ }
|
|
||||||
session.components;
|
session.components;
|
||||||
in
|
in
|
||||||
componentsUnits // {
|
componentsUnits // {
|
||||||
@ -312,6 +311,6 @@ in
|
|||||||
# is more elegant and surprisingly trivial) but this requires
|
# is more elegant and surprisingly trivial) but this requires
|
||||||
# reimplementing parts of nixpkgs systemd-lib and we're lazy bastards so
|
# reimplementing parts of nixpkgs systemd-lib and we're lazy bastards so
|
||||||
# no.
|
# no.
|
||||||
systemd.user.units = lib.mkMerge sessionSystemdUnits;
|
systemd.user.units = sessionSystemdUnits;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -39,16 +39,16 @@ let
|
|||||||
)
|
)
|
||||||
cfg.sessions;
|
cfg.sessions;
|
||||||
|
|
||||||
sessionSystemdUnits = lib.mapAttrsToList
|
sessionSystemdUnits = lib.concatMapAttrs
|
||||||
(name: session:
|
(name: session:
|
||||||
let
|
let
|
||||||
inherit (utils.systemdUtils.lib)
|
inherit (utils.systemdUtils.lib)
|
||||||
pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit;
|
pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit;
|
||||||
|
|
||||||
sessionComponents =
|
sessionComponents =
|
||||||
lib.foldlAttrs
|
lib.concatMapAttrs
|
||||||
(acc: name: component:
|
(name: component:
|
||||||
acc // {
|
{
|
||||||
"${component.id}.service" = serviceToUnit component.id component.serviceUnit;
|
"${component.id}.service" = serviceToUnit component.id component.serviceUnit;
|
||||||
"${component.id}.target" = targetToUnit component.id component.targetUnit;
|
"${component.id}.target" = targetToUnit component.id component.targetUnit;
|
||||||
} // lib.optionalAttrs (component.socketUnit != null) {
|
} // lib.optionalAttrs (component.socketUnit != null) {
|
||||||
@ -58,7 +58,6 @@ let
|
|||||||
} // lib.optionalAttrs (component.pathUnit != null) {
|
} // lib.optionalAttrs (component.pathUnit != null) {
|
||||||
"${component.id}.path" = pathToUnit component.id component.pathUnit;
|
"${component.id}.path" = pathToUnit component.id component.pathUnit;
|
||||||
})
|
})
|
||||||
{ }
|
|
||||||
session.components;
|
session.components;
|
||||||
in
|
in
|
||||||
sessionComponents // {
|
sessionComponents // {
|
||||||
@ -193,7 +192,7 @@ in
|
|||||||
|
|
||||||
# Import those systemd units from sessiond as well.
|
# Import those systemd units from sessiond as well.
|
||||||
systemd.packages = [ cfg.package ];
|
systemd.packages = [ cfg.package ];
|
||||||
systemd.user.units = lib.mkMerge sessionSystemdUnits;
|
systemd.user.units = sessionSystemdUnits;
|
||||||
|
|
||||||
# We're disabling the upstream sessiond service since we have our own set
|
# We're disabling the upstream sessiond service since we have our own set
|
||||||
# of sessiond sessions here.
|
# of sessiond sessions here.
|
||||||
|
Loading…
Reference in New Issue
Block a user