diff --git a/modules/launchd/default.nix b/modules/launchd/default.nix
index 9253626a8b..7d2917e80d 100644
--- a/modules/launchd/default.nix
+++ b/modules/launchd/default.nix
@@ -14,7 +14,7 @@ let
dstDir = "${config.home.homeDirectory}/Library/LaunchAgents";
launchdConfig =
- { name, ... }:
+ { name, config, ... }:
{
options = {
enable = lib.mkEnableOption name;
@@ -55,9 +55,14 @@ let
};
};
- config = {
- config.Label = lib.mkDefault "${labelPrefix}${name}";
- };
+ config = lib.mkMerge [
+ {
+ config.Label = lib.mkDefault "${labelPrefix}${name}";
+ }
+ (lib.mkIf (config.domain == "user") {
+ config.LimitLoadToSessionType = lib.mkDefault "Background";
+ })
+ ];
};
# mutateConfig calls /bin/sh with /bin/wait4path to wait for /nix/store before
@@ -211,6 +216,13 @@ in
esac
}
+ agentIsLoaded() {
+ local domain="$1"
+ local agentName="$2"
+
+ run /bin/launchctl print "$domain/$agentName" >/dev/null 2>&1
+ }
+
# Stop an agent if it's running
bootoutAgent() {
local domain="$1"
@@ -218,21 +230,24 @@ in
verboseEcho "Stopping agent '$domain/$agentName'..."
local bootout_output
- bootout_output=$(run /bin/launchctl bootout --wait "$domain/$agentName" 2>&1) || {
+ if bootout_output=$(run /bin/launchctl bootout --wait "$domain/$agentName" 2>&1); then
+ return 0
+ else
# Only show warning if it's not the common "No such process" error
if [[ "$bootout_output" != *"No such process"* ]]; then
warnEcho "Failed to stop agent '$domain/$agentName': $bootout_output"
+ return 1
else
verboseEcho "Agent '$domain/$agentName' was not running"
+ return 2
fi
- }
+ fi
}
- installAndBootstrapAgent() {
+ installAgentFile() {
local srcPath="$1"
local dstPath="$2"
- local domain="$3"
- local agentName="$4"
+ local agentName="$3"
verboseEcho "Installing agent file to $dstPath"
if ! run install -Dm444 -T "$srcPath" "$dstPath"; then
@@ -240,11 +255,17 @@ in
return 1
fi
+ return 0
+ }
+
+ bootstrapAgent() {
+ local domain="$1"
+ local dstPath="$2"
+ local agentName="$3"
+
verboseEcho "Starting agent '$domain/$agentName'"
local bootstrap_output
bootstrap_output=$(run /bin/launchctl bootstrap "$domain" "$dstPath" 2>&1) || {
- local error_code=$?
-
if [[ "$bootstrap_output" == *"Bootstrap failed: 5: Input/output error"* ]]; then
errorEcho "Failed to start agent '$domain/$agentName' with I/O error (code 5)"
errorEcho "This typically happens when the agent wasn't unloaded before attempting to bootstrap the new agent."
@@ -259,29 +280,55 @@ in
return 0
}
+ restoreAgent() {
+ local oldSrcPath="$1"
+ local dstPath="$2"
+ local oldDomain="$3"
+ local agentName="$4"
+
+ if [[ ! -f "$oldSrcPath" ]]; then
+ warnEcho "Cannot restore previous agent '$oldDomain/$agentName', old file '$oldSrcPath' is missing"
+ return 1
+ fi
+
+ warnEcho "Restoring previous agent '$oldDomain/$agentName'"
+ installAgentFile "$oldSrcPath" "$dstPath" "$agentName" \
+ && bootstrapAgent "$oldDomain" "$dstPath" "$agentName"
+ }
+
processAgent() {
local srcPath="$1"
local dstDir="$2"
- local oldDomainsDir="$3"
- local newDomainsDir="$4"
+ local oldDir="$3"
+ local oldDomainsDir="$4"
+ local newDomainsDir="$5"
local agentFile="''${srcPath##*/}"
local agentName="''${agentFile%.plist}"
local dstPath="$dstDir/$agentFile"
+ local oldSrcPath=""
local oldDomainName
local newDomainName
local oldDomain
local newDomain
+ local oldAgentBootedOut=0
oldDomainName="$(readAgentDomain "$oldDomainsDir" "$agentName")"
newDomainName="$(readAgentDomain "$newDomainsDir" "$agentName")"
oldDomain="$(resolveDomain "$oldDomainName")"
newDomain="$(resolveDomain "$newDomainName")"
+ if [[ -n "$oldDir" ]]; then
+ oldSrcPath="$oldDir/$agentFile"
+ fi
# Skip if unchanged
if cmp -s "$srcPath" "$dstPath" && [[ "$oldDomainName" == "$newDomainName" ]]; then
- verboseEcho "Agent '$newDomain/$agentName' is already up-to-date"
- return 0
+ if agentIsLoaded "$newDomain" "$agentName"; then
+ verboseEcho "Agent '$newDomain/$agentName' is already up-to-date"
+ return 0
+ else
+ verboseEcho "Agent '$newDomain/$agentName' is up-to-date but not loaded"
+ fi
fi
verboseEcho "Processing agent '$newDomain/$agentName'"
@@ -289,11 +336,48 @@ in
# Stop/Unload agent if it's already running
if [[ -f "$dstPath" ]]; then
bootoutAgent "$oldDomain" "$agentName"
+ case "$?" in
+ 0)
+ oldAgentBootedOut=1
+ ;;
+ 2)
+ ;;
+ *)
+ return 1
+ ;;
+ esac
fi
- installAndBootstrapAgent "$srcPath" "$dstPath" "$newDomain" "$agentName"
- # Note: We continue processing even if this agent fails
- return 0
+ if [[ "$oldDomainName" != "$newDomainName" ]]; then
+ bootoutAgent "$newDomain" "$agentName"
+ case "$?" in
+ 0|2)
+ ;;
+ *)
+ if [[ "$oldAgentBootedOut" -eq 1 ]]; then
+ restoreAgent "$oldSrcPath" "$dstPath" "$oldDomain" "$agentName"
+ fi
+ return 1
+ ;;
+ esac
+ fi
+
+ if ! installAgentFile "$srcPath" "$dstPath" "$agentName"; then
+ if [[ "$oldAgentBootedOut" -eq 1 ]]; then
+ restoreAgent "$oldSrcPath" "$dstPath" "$oldDomain" "$agentName"
+ fi
+ return 1
+ fi
+
+ if bootstrapAgent "$newDomain" "$dstPath" "$agentName"; then
+ return 0
+ fi
+
+ if [[ "$oldAgentBootedOut" -eq 1 ]]; then
+ restoreAgent "$oldSrcPath" "$dstPath" "$oldDomain" "$agentName"
+ fi
+
+ return 1
}
removeAgent() {
@@ -328,23 +412,32 @@ in
# Stop and remove the agent
bootoutAgent "$domain" "$agentName"
+ case "$?" in
+ 0|2)
+ ;;
+ *)
+ return 1
+ ;;
+ esac
verboseEcho "Removing agent file '$dstPath'"
if run rm -f $VERBOSE_ARG "$dstPath"; then
verboseEcho "Successfully removed agent file for '$agentName'"
else
warnEcho "Failed to remove agent file '$dstPath'"
+ return 1
fi
return 0
}
setupLaunchAgents() {
- local oldDir newDir oldDomainsDir newDomainsDir dstDir
+ local oldDir newDir oldDomainsDir newDomainsDir dstDir launchdStatus
newDir="$(readlink -m "$newGenPath/LaunchAgents")"
newDomainsDir="$(readlink -m "$newGenPath/LaunchAgentDomains")"
dstDir=${lib.escapeShellArg dstDir}
+ launchdStatus=0
if [[ -n "''${oldGenPath:-}" ]]; then
oldDir="$(readlink -m "$oldGenPath/LaunchAgents")"
@@ -363,29 +456,49 @@ in
fi
verboseEcho "Setting up LaunchAgents in $dstDir"
- [[ -d "$dstDir" ]] || run mkdir -p "$dstDir"
+ if [[ ! -d "$dstDir" ]] && ! run mkdir -p "$dstDir"; then
+ errorEcho "Failed to create LaunchAgents directory '$dstDir'"
+ return 1
+ fi
verboseEcho "Processing new/updated LaunchAgents..."
- find -L "$newDir" -maxdepth 1 -name '*.plist' -type f | while read -r srcPath; do
- processAgent "$srcPath" "$dstDir" "$oldDomainsDir" "$newDomainsDir"
- done
+ while IFS= read -r srcPath; do
+ processAgent "$srcPath" "$dstDir" "$oldDir" "$oldDomainsDir" "$newDomainsDir" \
+ || launchdStatus=1
+ done < <(find -L "$newDir" -maxdepth 1 -name '*.plist' -type f)
# Skip cleanup if there's no previous generation
if [[ -z "$oldDir" || ! -d "$oldDir" ]]; then
+ if [[ "$launchdStatus" -ne 0 ]]; then
+ errorEcho "Failed to activate one or more LaunchAgents"
+ fi
+
verboseEcho "LaunchAgents setup complete"
- return
+ return "$launchdStatus"
fi
verboseEcho "Cleaning up removed LaunchAgents..."
- find -L "$oldDir" -maxdepth 1 -name '*.plist' -type f | while read -r srcPath; do
- removeAgent "$srcPath" "$dstDir" "$newDir" "$oldDomainsDir"
- done
+ while IFS= read -r srcPath; do
+ removeAgent "$srcPath" "$dstDir" "$newDir" "$oldDomainsDir" \
+ || launchdStatus=1
+ done < <(find -L "$oldDir" -maxdepth 1 -name '*.plist' -type f)
+
+ if [[ "$launchdStatus" -ne 0 ]]; then
+ errorEcho "Failed to activate one or more LaunchAgents"
+ fi
+
+ return "$launchdStatus"
}
- setupLaunchAgents
+ launchdStatus=0
+ setupLaunchAgents || launchdStatus=$?
# Restore errexit
set -e
+
+ if [[ "$launchdStatus" -ne 0 ]]; then
+ exit "$launchdStatus"
+ fi
'';
})
];
diff --git a/tests/modules/launchd/agent-domain.nix b/tests/modules/launchd/agent-domain.nix
index 5d672529bb..d4518ffdb7 100644
--- a/tests/modules/launchd/agent-domain.nix
+++ b/tests/modules/launchd/agent-domain.nix
@@ -11,6 +11,8 @@
nmt.script = ''
serviceFile=LaunchAgents/org.nix-community.home.user-service.plist
assertFileExists $serviceFile
+ assertFileContains $serviceFile 'LimitLoadToSessionType'
+ assertFileContains $serviceFile 'Background'
domainFile=LaunchAgentDomains/org.nix-community.home.user-service.domain
assertFileExists $domainFile
diff --git a/tests/modules/launchd/agents.nix b/tests/modules/launchd/agents.nix
index f872714ca9..abaa32c91a 100644
--- a/tests/modules/launchd/agents.nix
+++ b/tests/modules/launchd/agents.nix
@@ -30,8 +30,19 @@
assertFileExists activate
assertFileContains activate 'readAgentDomain'
assertFileContains activate 'resolveDomain'
+ assertFileContains activate 'agentIsLoaded'
+ assertFileContains activate 'if agentIsLoaded "$newDomain" "$agentName"; then'
+ assertFileContains activate 'is up-to-date but not loaded'
assertFileContains activate "printf 'gui/%s"
assertFileContains activate "printf 'user/%s"
+ assertFileContains activate 'restoreAgent "$oldSrcPath" "$dstPath" "$oldDomain" "$agentName"'
+ assertFileContains activate 'bootoutAgent "$newDomain" "$agentName"'
+ assertFileContains activate 'processAgent "$srcPath" "$dstDir" "$oldDir" "$oldDomainsDir" "$newDomainsDir" \'
+ assertFileContains activate '|| launchdStatus=1'
+ assertFileContains activate 'done < <(find -L "$newDir" -maxdepth 1 -name'
+ assertFileContains activate 'done < <(find -L "$oldDir" -maxdepth 1 -name'
+ assertFileContains activate 'if [[ "$launchdStatus" -ne 0 ]]; then'
+ assertFileContains activate 'exit "$launchdStatus"'
'';
};
}
diff --git a/tests/modules/programs/git/expected-agent-daily.plist b/tests/modules/programs/git/expected-agent-daily.plist
index 1ea3a38481..aa5fcfe447 100644
--- a/tests/modules/programs/git/expected-agent-daily.plist
+++ b/tests/modules/programs/git/expected-agent-daily.plist
@@ -4,6 +4,8 @@
Label
org.nix-community.home.git-maintenance-daily
+ LimitLoadToSessionType
+ Background
ProgramArguments
/bin/sh
diff --git a/tests/modules/programs/git/expected-agent-hourly.plist b/tests/modules/programs/git/expected-agent-hourly.plist
index 90780fb8c7..dd17dfd826 100644
--- a/tests/modules/programs/git/expected-agent-hourly.plist
+++ b/tests/modules/programs/git/expected-agent-hourly.plist
@@ -4,6 +4,8 @@
Label
org.nix-community.home.git-maintenance-hourly
+ LimitLoadToSessionType
+ Background
ProgramArguments
/bin/sh
diff --git a/tests/modules/programs/git/expected-agent-weekly.plist b/tests/modules/programs/git/expected-agent-weekly.plist
index e2c8a3f946..3e4c091206 100644
--- a/tests/modules/programs/git/expected-agent-weekly.plist
+++ b/tests/modules/programs/git/expected-agent-weekly.plist
@@ -4,6 +4,8 @@
Label
org.nix-community.home.git-maintenance-weekly
+ LimitLoadToSessionType
+ Background
ProgramArguments
/bin/sh
diff --git a/tests/modules/programs/nh/darwin/launchd.plist b/tests/modules/programs/nh/darwin/launchd.plist
index 987f210534..173ae36278 100644
--- a/tests/modules/programs/nh/darwin/launchd.plist
+++ b/tests/modules/programs/nh/darwin/launchd.plist
@@ -4,6 +4,8 @@
Label
org.nix-community.home.nh-clean
+ LimitLoadToSessionType
+ Background
ProgramArguments
/bin/sh
diff --git a/tests/modules/programs/opencode/web-service-environment-file.plist b/tests/modules/programs/opencode/web-service-environment-file.plist
index 7c91f87a87..e4e2f5c718 100644
--- a/tests/modules/programs/opencode/web-service-environment-file.plist
+++ b/tests/modules/programs/opencode/web-service-environment-file.plist
@@ -11,6 +11,8 @@
Label
org.nix-community.home.opencode-web
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/programs/opencode/web-service.plist b/tests/modules/programs/opencode/web-service.plist
index 086160812d..40dfafdd95 100644
--- a/tests/modules/programs/opencode/web-service.plist
+++ b/tests/modules/programs/opencode/web-service.plist
@@ -11,6 +11,8 @@
Label
org.nix-community.home.opencode-web
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/borgmatic/darwin/expected-agent.plist b/tests/modules/services/borgmatic/darwin/expected-agent.plist
index 53436923f6..60cb68eb24 100644
--- a/tests/modules/services/borgmatic/darwin/expected-agent.plist
+++ b/tests/modules/services/borgmatic/darwin/expected-agent.plist
@@ -4,6 +4,8 @@
Label
org.nix-community.home.borgmatic
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/colima/darwin/colima-docker-cli-expected.plist b/tests/modules/services/colima/darwin/colima-docker-cli-expected.plist
index 6cc241d696..025f486307 100644
--- a/tests/modules/services/colima/darwin/colima-docker-cli-expected.plist
+++ b/tests/modules/services/colima/darwin/colima-docker-cli-expected.plist
@@ -22,6 +22,8 @@
Label
org.nix-community.home.colima-default
+ LimitLoadToSessionType
+ Background
ProgramArguments
/bin/sh
diff --git a/tests/modules/services/colima/darwin/expected-agent.plist b/tests/modules/services/colima/darwin/expected-agent.plist
index 15a64c6aa8..86a8d57ad3 100644
--- a/tests/modules/services/colima/darwin/expected-agent.plist
+++ b/tests/modules/services/colima/darwin/expected-agent.plist
@@ -18,6 +18,8 @@
Label
org.nix-community.home.colima-default
+ LimitLoadToSessionType
+ Background
ProgramArguments
/bin/sh
diff --git a/tests/modules/services/emacs/darwin/expected-agent.plist b/tests/modules/services/emacs/darwin/expected-agent.plist
index cc9b768245..266e9ed86e 100644
--- a/tests/modules/services/emacs/darwin/expected-agent.plist
+++ b/tests/modules/services/emacs/darwin/expected-agent.plist
@@ -11,6 +11,8 @@
Label
org.nix-community.home.emacs
+ LimitLoadToSessionType
+ Background
ProgramArguments
/bin/sh
diff --git a/tests/modules/services/git-sync/darwin/expected-agent.plist b/tests/modules/services/git-sync/darwin/expected-agent.plist
index 53d8156e1b..c55c385446 100644
--- a/tests/modules/services/git-sync/darwin/expected-agent.plist
+++ b/tests/modules/services/git-sync/darwin/expected-agent.plist
@@ -4,6 +4,8 @@
Label
org.nix-community.home.git-sync-test
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/glance/default-settings.nix b/tests/modules/services/glance/default-settings.nix
index 85fe14ebf2..f183fe7dbe 100644
--- a/tests/modules/services/glance/default-settings.nix
+++ b/tests/modules/services/glance/default-settings.nix
@@ -18,6 +18,8 @@
serviceFile=$(normalizeStorePaths $serviceFile)
assertFileExists "$serviceFile"
assertFileContent "$serviceFile" ${./glance.plist}
+ assertFileContains "$serviceFile" 'LimitLoadToSessionType'
+ assertFileContains "$serviceFile" 'Background'
domainFile=LaunchAgentDomains/org.nix-community.home.glance.domain
assertFileContent "$domainFile" ${builtins.toFile "expected-domain" "user\n"}
diff --git a/tests/modules/services/glance/glance.plist b/tests/modules/services/glance/glance.plist
index d6b84a53d6..ed418d3647 100644
--- a/tests/modules/services/glance/glance.plist
+++ b/tests/modules/services/glance/glance.plist
@@ -6,6 +6,8 @@
Label
org.nix-community.home.glance
+ LimitLoadToSessionType
+ Background
ProgramArguments
/bin/sh
diff --git a/tests/modules/services/gpg-agent/expected-agent.plist b/tests/modules/services/gpg-agent/expected-agent.plist
index 093e313711..b950fc50ce 100644
--- a/tests/modules/services/gpg-agent/expected-agent.plist
+++ b/tests/modules/services/gpg-agent/expected-agent.plist
@@ -16,6 +16,8 @@
Label
org.nix-community.home.gpg-agent
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/home-manager-auto-expire/darwin/expected-agent.plist b/tests/modules/services/home-manager-auto-expire/darwin/expected-agent.plist
index 5d9742466b..78c4d42082 100644
--- a/tests/modules/services/home-manager-auto-expire/darwin/expected-agent.plist
+++ b/tests/modules/services/home-manager-auto-expire/darwin/expected-agent.plist
@@ -4,6 +4,8 @@
Label
org.nix-community.home.home-manager-auto-expire
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/imapnotify/darwin/launchd.plist b/tests/modules/services/imapnotify/darwin/launchd.plist
index 4fb9555cb2..1b6dd6a8cf 100644
--- a/tests/modules/services/imapnotify/darwin/launchd.plist
+++ b/tests/modules/services/imapnotify/darwin/launchd.plist
@@ -13,6 +13,8 @@
Label
org.nix-community.home.imapnotify-hm-example.com
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/nix-gc/darwin/expected-agent.plist b/tests/modules/services/nix-gc/darwin/expected-agent.plist
index 4691c2e41d..4566188626 100644
--- a/tests/modules/services/nix-gc/darwin/expected-agent.plist
+++ b/tests/modules/services/nix-gc/darwin/expected-agent.plist
@@ -4,6 +4,8 @@
Label
org.nix-community.home.nix-gc
+ LimitLoadToSessionType
+ Background
ProgramArguments
/bin/sh
diff --git a/tests/modules/services/ollama/darwin/expected-agent.plist b/tests/modules/services/ollama/darwin/expected-agent.plist
index daeccc78b7..05a46a477b 100644
--- a/tests/modules/services/ollama/darwin/expected-agent.plist
+++ b/tests/modules/services/ollama/darwin/expected-agent.plist
@@ -20,6 +20,8 @@
Label
org.nix-community.home.ollama
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/podman/darwin/basic-expected-agent.plist b/tests/modules/services/podman/darwin/basic-expected-agent.plist
index 341a43b33b..cb4b1657bf 100644
--- a/tests/modules/services/podman/darwin/basic-expected-agent.plist
+++ b/tests/modules/services/podman/darwin/basic-expected-agent.plist
@@ -11,6 +11,8 @@
Label
org.nix-community.home.podman-machine-podman-machine-default
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/podman/darwin/custom-machines-dev-expected-agent.plist b/tests/modules/services/podman/darwin/custom-machines-dev-expected-agent.plist
index 3668a1fc8c..0679c89af2 100644
--- a/tests/modules/services/podman/darwin/custom-machines-dev-expected-agent.plist
+++ b/tests/modules/services/podman/darwin/custom-machines-dev-expected-agent.plist
@@ -11,6 +11,8 @@
Label
org.nix-community.home.podman-machine-dev-machine
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/proton-pass-agent/basic-service-expected.plist b/tests/modules/services/proton-pass-agent/basic-service-expected.plist
index 84c4ecd1ea..af1e1d3a99 100644
--- a/tests/modules/services/proton-pass-agent/basic-service-expected.plist
+++ b/tests/modules/services/proton-pass-agent/basic-service-expected.plist
@@ -6,6 +6,8 @@
Label
org.nix-community.home.proton-pass-agent
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/proton-pass-agent/full-service-expected.plist b/tests/modules/services/proton-pass-agent/full-service-expected.plist
index 16c1a5600c..8f7220a755 100644
--- a/tests/modules/services/proton-pass-agent/full-service-expected.plist
+++ b/tests/modules/services/proton-pass-agent/full-service-expected.plist
@@ -6,6 +6,8 @@
Label
org.nix-community.home.proton-pass-agent
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/ssh-agent/darwin/basic-service-expected.plist b/tests/modules/services/ssh-agent/darwin/basic-service-expected.plist
index 8a44b3ce7d..e235fe89d7 100644
--- a/tests/modules/services/ssh-agent/darwin/basic-service-expected.plist
+++ b/tests/modules/services/ssh-agent/darwin/basic-service-expected.plist
@@ -11,6 +11,8 @@
Label
org.nix-community.home.ssh-agent
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/ssh-agent/darwin/pkcs11-service-expected.plist b/tests/modules/services/ssh-agent/darwin/pkcs11-service-expected.plist
index a660ba35d5..c54acf4dd9 100644
--- a/tests/modules/services/ssh-agent/darwin/pkcs11-service-expected.plist
+++ b/tests/modules/services/ssh-agent/darwin/pkcs11-service-expected.plist
@@ -11,6 +11,8 @@
Label
org.nix-community.home.ssh-agent
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/ssh-agent/darwin/timeout-service-expected.plist b/tests/modules/services/ssh-agent/darwin/timeout-service-expected.plist
index 6442e73c6f..32e28fe5df 100644
--- a/tests/modules/services/ssh-agent/darwin/timeout-service-expected.plist
+++ b/tests/modules/services/ssh-agent/darwin/timeout-service-expected.plist
@@ -11,6 +11,8 @@
Label
org.nix-community.home.ssh-agent
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/syncthing/expected-agent.plist b/tests/modules/services/syncthing/expected-agent.plist
index 79550be9ea..18cecc9fbd 100644
--- a/tests/modules/services/syncthing/expected-agent.plist
+++ b/tests/modules/services/syncthing/expected-agent.plist
@@ -11,6 +11,8 @@
Label
org.nix-community.home.syncthing
+ LimitLoadToSessionType
+ Background
ProcessType
Background
ProgramArguments
diff --git a/tests/modules/services/yubikey-agent/darwin/service.nix b/tests/modules/services/yubikey-agent/darwin/service.nix
index c8bd674f42..f3f694d423 100644
--- a/tests/modules/services/yubikey-agent/darwin/service.nix
+++ b/tests/modules/services/yubikey-agent/darwin/service.nix
@@ -23,6 +23,8 @@
Label
org.nix-community.home.yubikey-agent
+ ${"\t"}LimitLoadToSessionType
+ ${"\t"}Background
ProcessType
Background
ProgramArguments