From fd25625351d83e78d1f3ff9c8fb21cdd9a99e5b3 Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 13:45:40 -0600 Subject: [PATCH] fix(mcpx): render daemon environment as Service.Environment entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The home-manager module passed services.mcpx.environment through at the service level of systemd.user.services.mcpx, where the unit type freeform serialized it as a literal [environment] section. sd-switch refuses to parse the generated unit (the cascade deploy round-3 abort, code#5088), and systemd's own parser tolerates and silently drops the unknown section — the daemon environment with it. Render cfg.environment into home-manager's typed Service.Environment list instead (lib.mapAttrsToList to NAME=value entries, values verbatim). The old comment's premise does not hold: home-manager injects no per-service Service.Environment (session variables reach units through the user manager's environment.d), and list definitions concatenate in the module system. Both re-tested; evidence in the PR. --- pkgs/mcpx/modules/home-manager.nix | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkgs/mcpx/modules/home-manager.nix b/pkgs/mcpx/modules/home-manager.nix index 709afacabe..e3bee009d3 100644 --- a/pkgs/mcpx/modules/home-manager.nix +++ b/pkgs/mcpx/modules/home-manager.nix @@ -61,13 +61,19 @@ in systemd.user.services.mcpx = { Unit.Description = "mcpx daemon"; Install.WantedBy = [ "default.target" ]; - # Via the service-level `environment` attribute, not - # Service.Environment: home-manager injects its own - # Service.Environment (session variables) and the two - # definitions do not merge. - inherit (cfg) environment; Service = { ExecStart = "${cfg.package}/bin/mcpx daemon --config ${cfg.configFile}"; + # The daemon environment, as [Service] Environment= + # entries through home-manager's typed list option. + # List definitions merge in the module system, so other + # contributors' entries concatenate with these; and + # session variables never compete here — home-manager + # delivers those to the user manager via environment.d, + # not as per-service Environment= lines. (A service-level + # `environment` attribute, by contrast, falls through + # the unit type's freeform and is serialized as a literal + # [environment] section — code#5088.) + Environment = lib.mapAttrsToList (name: value: "${name}=${value}") cfg.environment; Restart = "always"; TimeoutStopSec = 20; WorkingDirectory = "%h";