fix: use user domain instead of gui for hm sops-nix launchd agent#966
Open
Eason20000 wants to merge 1 commit into
Open
fix: use user domain instead of gui for hm sops-nix launchd agent#966Eason20000 wants to merge 1 commit into
Eason20000 wants to merge 1 commit into
Conversation
Eason20000
force-pushed
the
hm-launchd-user-domain
branch
from
July 10, 2026 11:45
1a4f684 to
dc278a6
Compare
Using gui/UID domain requires an Aqua GUI session, which is unavailable on headless macOS servers. The user/UID domain is available after any login (SSH or GUI) and works with the Background session type. - Set LimitLoadToSessionType = "Background" in the agent plist - Change activation script domain-target from gui/ to user/
Eason20000
force-pushed
the
hm-launchd-user-domain
branch
from
July 10, 2026 12:07
dc278a6 to
91c125e
Compare
Eason20000
marked this pull request as draft
July 10, 2026 12:22
Eason20000
marked this pull request as ready for review
July 10, 2026 12:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Home Manager sops-nix fails to activate on headless macOS servers. The activation script runs:
launchctl bootstrap gui/$(id -u) ...which fails with:
The
gui/UIDdomain only exists when the user has an Aqua (GUI) login session. Machines accessed exclusively via SSH (headless Mac Mini, EC2 Mac instances, CI build servers) never create this domain.Root cause
Two issues in
modules/home-manager/sops.nix:gui/$(id -u …)—gui/UIDdomain requires an Aqua sessionLimitLoadToSessionType— defaults toAqua, which maps togui/UIDFix
The
user/UIDdomain exists after any login — GUI or SSH (pam_launchd.socreates it). Background agents loaded into this domain do not require a graphical session.Two-line change:
LimitLoadToSessionType = "Background"in the LaunchAgent plist so the agent is loadable intouser/UIDgui/touser/Evidence
Home Manager's own launchd module (link) already supports this distinction:
Apple's
launchd.plist(5)man page (shipped with every macOS release) defines four session types:Aqua— requires GUI login (maps togui/UID)Background— per-user context, parent of all sessions for a user (maps touser/UID)StandardIO— non-GUI login sessions (SSH per-session)LoginWindow— pre-login contextStackOverflow confirmation (link):
Verified
gui/501+user/501user/501only125: Domain does not supportThe
Backgroundsession type covers both use cases — a single session type suffices without needing an array.