From 1299b8156a07ecb0a79849fcf805759d75f747f2 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Thu, 4 Jan 2024 17:30:35 +0800 Subject: [PATCH] programs/gnome-session: add optional timer, socket, and path systemd unit option for desktop components --- .../nixos/programs/gnome-session/default.nix | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/modules/nixos/programs/gnome-session/default.nix b/modules/nixos/programs/gnome-session/default.nix index 9dfe5bf6..cd501d23 100644 --- a/modules/nixos/programs/gnome-session/default.nix +++ b/modules/nixos/programs/gnome-session/default.nix @@ -104,6 +104,78 @@ let default = {}; }; + timerUnit = lib.mkOption { + type = + let + inherit (utils.systemdUtils.unitOptions) timerOptions commonUnitOptions; + inherit (utils.systemdUtils.lib) unitConfig; + in + with lib.types; nullOr (submodule [ + commonUnitOptions + timerOptions + unitConfig + ]); + description = '' + An optional systemd timer configuration to be generated. This should + be configured if the session is managed by systemd. + + :::{.note} + This has the same options as {option}`systemd.user.timers.` + but without certain options from stage 2 counterparts such as + `reloadTriggers` and `restartTriggers`. + ::: + ''; + default = null; + }; + + socketUnit = lib.mkOption { + type = + let + inherit (utils.systemdUtils.unitOptions) socketOptions commonUnitOptions; + inherit (utils.systemdUtils.lib) unitConfig; + in + with lib.types; nullOr (submodule [ + commonUnitOptions + socketOptions + unitConfig + ]); + description = '' + An optional systemd socket configuration to be generated. This should + be configured if the session is managed by systemd. + + :::{.note} + This has the same options as {option}`systemd.user.sockets.` + but without certain options from stage 2 counterparts such as + `reloadTriggers` and `restartTriggers`. + ::: + ''; + default = null; + }; + + pathUnit = lib.mkOption { + type = + let + inherit (utils.systemdUtils.unitOptions) pathOptions commonUnitOptions; + inherit (utils.systemdUtils.lib) unitConfig; + in + with lib.types; nullOr (submodule [ + commonUnitOptions + pathOptions + unitConfig + ]); + description = '' + An optional systemd path configuration to be generated. This should + be configured if the session is managed by systemd. + + :::{.note} + This has the same options as {option}`systemd.user.paths.` + but without certain options from stage 2 counterparts such as + `reloadTriggers` and `restartTriggers`. + ::: + ''; + default = null; + }; + id = lib.mkOption { type = lib.types.str; description = '' @@ -379,12 +451,19 @@ let # with various NixOS options like `systemd.packages` and the like. systemdUserUnits = let - inherit (utils.systemdUtils.lib) serviceToUnit targetToUnit; + inherit (utils.systemdUtils.lib) + pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit; componentsUnits = lib.foldlAttrs (acc: name: component: acc // { "${component.id}.service" = serviceToUnit component.id component.serviceUnit; "${component.id}.target" = targetToUnit component.id component.targetUnit; + } // lib.optionalAttrs (component.socketUnit != null) { + "${component.id}.socket" = socketToUnit component.id component.socketUnit; + } // lib.optionalAttrs (component.timerUnit != null) { + "${component.id}.timer" = timerToUnit component.id component.timerUnit; + } // lib.optionalAttrs (component.pathUnit != null) { + "${component.id}.path" = pathToUnit component.id component.pathUnit; }) {} config.components; in