Files
home-manager/tests/modules/launchd/agent-launcher.nix
Samiser aab62b300b launchd: add waitForNixStore agent option
By default agents are started via /bin/sh with /bin/wait4path, which
makes every Home Manager agent show up as "sh" in System Settings >
Login Items & Extensions. Allow opting out per agent, in which case
the command is exec'd through a launcher script named after the agent
so it is displayed under its own name.
2026-07-28 12:21:39 -05:00

32 lines
979 B
Nix

{
config = {
launchd.agents."launcher-service" = {
enable = true;
waitForNixStore = false;
config = {
ProgramArguments = [
"/some/command"
"--with-arguments"
"foo"
];
};
};
nmt.script = ''
serviceFile=LaunchAgents/org.nix-community.home.launcher-service.plist
assertFileExists $serviceFile
# The agent should exec a launcher script named after it, so that it
# is displayed under its own name in Login Items & Extensions
assertFileRegex $serviceFile '<string>/nix/store/[^<]*/bin/launcher-service</string>'
# Ensure the agent wasn't started through a shell wrapper.
assertFileNotRegex $serviceFile '<string>/bin/sh</string>'
launcher=$(sed -n 's|.*<string>\(/nix/store/[^<]*/bin/launcher-service\)</string>.*|\1|p' \
"$(_abs $serviceFile)")
assertFileContains "$launcher" 'exec /some/command --with-arguments foo'
'';
};
}