2.home-manager/tests/modules/launchd/agent-domain.nix
Austin Horstman 2f3da3d45f 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.
2026-06-30 23:39:07 -05:00

22 lines
655 B
Nix

{
config = {
launchd.agents."user-service" = {
enable = true;
domain = "user";
config.ProgramArguments = [
"/some/command"
];
};
nmt.script = ''
serviceFile=LaunchAgents/org.nix-community.home.user-service.plist
assertFileExists $serviceFile
assertFileContains $serviceFile '<key>LimitLoadToSessionType</key>'
assertFileContains $serviceFile '<string>Background</string>'
domainFile=LaunchAgentDomains/org.nix-community.home.user-service.domain
assertFileExists $domainFile
assertFileContent $domainFile ${builtins.toFile "expected-domain" "user\n"}
'';
};
}