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.
22 lines
655 B
Nix
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"}
|
|
'';
|
|
};
|
|
}
|