launchd: fix user domain agents

User-domain agents need the Background session type to bootstrap into user/501, and activation should fail rather than silently unloading services when launchctl bootstrap fails.
This commit is contained in:
Austin Horstman 2026-06-30 23:17:56 -05:00
parent 2a37d71bbe
commit 2f3da3d45f
30 changed files with 208 additions and 28 deletions

View file

@ -4,6 +4,8 @@
<dict>
<key>Label</key>
<string>org.nix-community.home.borgmatic</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -22,6 +22,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.colima-default</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>

View file

@ -18,6 +18,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.colima-default</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>

View file

@ -11,6 +11,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.emacs</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>

View file

@ -4,6 +4,8 @@
<dict>
<key>Label</key>
<string>org.nix-community.home.git-sync-test</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -18,6 +18,8 @@
serviceFile=$(normalizeStorePaths $serviceFile)
assertFileExists "$serviceFile"
assertFileContent "$serviceFile" ${./glance.plist}
assertFileContains "$serviceFile" '<key>LimitLoadToSessionType</key>'
assertFileContains "$serviceFile" '<string>Background</string>'
domainFile=LaunchAgentDomains/org.nix-community.home.glance.domain
assertFileContent "$domainFile" ${builtins.toFile "expected-domain" "user\n"}

View file

@ -6,6 +6,8 @@
<true/>
<key>Label</key>
<string>org.nix-community.home.glance</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>

View file

@ -16,6 +16,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.gpg-agent</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -4,6 +4,8 @@
<dict>
<key>Label</key>
<string>org.nix-community.home.home-manager-auto-expire</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -13,6 +13,8 @@
<true/>
<key>Label</key>
<string>org.nix-community.home.imapnotify-hm-example.com</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -4,6 +4,8 @@
<dict>
<key>Label</key>
<string>org.nix-community.home.nix-gc</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>

View file

@ -20,6 +20,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.ollama</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -11,6 +11,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.podman-machine-podman-machine-default</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -11,6 +11,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.podman-machine-dev-machine</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -6,6 +6,8 @@
<true/>
<key>Label</key>
<string>org.nix-community.home.proton-pass-agent</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -6,6 +6,8 @@
<true/>
<key>Label</key>
<string>org.nix-community.home.proton-pass-agent</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -11,6 +11,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.ssh-agent</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -11,6 +11,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.ssh-agent</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -11,6 +11,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.ssh-agent</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -11,6 +11,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.syncthing</string>
<key>LimitLoadToSessionType</key>
<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>

View file

@ -23,6 +23,8 @@
</dict>
<key>Label</key>
<string>org.nix-community.home.yubikey-agent</string>
${"\t"}<key>LimitLoadToSessionType</key>
${"\t"}<string>Background</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>