diff --git a/modules/nixos/programs/sessiond/default.nix b/modules/nixos/programs/sessiond/default.nix index 9f1c2273..076c3a4a 100644 --- a/modules/nixos/programs/sessiond/default.nix +++ b/modules/nixos/programs/sessiond/default.nix @@ -45,20 +45,19 @@ let inherit (utils.systemdUtils.lib) pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit; + mkSystemdUnits = name: component: { + "${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; + }; + sessionComponents = - lib.concatMapAttrs - (name: component: - { - "${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; - }) - session.components; + lib.concatMapAttrs mkSystemdUnits session.components; in sessionComponents // { "${name}.service" = serviceToUnit name session.serviceUnit; diff --git a/modules/nixos/programs/sessiond/submodules/component-type.nix b/modules/nixos/programs/sessiond/submodules/component-type.nix index f0574e54..f210f659 100644 --- a/modules/nixos/programs/sessiond/submodules/component-type.nix +++ b/modules/nixos/programs/sessiond/submodules/component-type.nix @@ -142,8 +142,11 @@ in know how different desktop components interact with each other especially if one of them failed. - * `Service.OOMScoreAdjust=` have different values for different - components so it isn't included. + * Even if we have a way to limit starting desktop components with + `systemd-xdg-autostart-condition`, using `Service.ExecCondition=` would + severely limit possible reuse of desktop components with other + NixOS-module-generated gnome-session sessions so we're not bothering with + those. * Most sandboxing options. Aside from the fact we're dealing with a systemd user unit, much of them are unnecessary and rarely needed (if @@ -163,6 +166,12 @@ in Slice = lib.mkDefault "session.slice"; Restart = lib.mkDefault "on-failure"; TimeoutStopSec = lib.mkDefault 5; + + # We'll assume most of the components are reasonably required so we'll + # set a reasonable middle-in-the-ground value for this one. The user + # should have the responsibility passing judgement for what is best for + # this. + OOMScoreAdjust = lib.mkDefault -500; }; startLimitBurst = lib.mkDefault 3; @@ -178,6 +187,11 @@ in /* Take note the session target unit already has `Wants=$COMPONENT.target` so no need to set dependency ordering directives here. + + And another thing, we also didn't set any dependency ordering directives + to any of sessiond-specific systemd units (if there's any). It is more + likely that the user will design their own desktop session with full + control so this would be better set as empty for less confusion. */ targetUnit = { wants = [ "${config.id}.service" ];