mirror of
https://github.com/nix-community/home-manager.git
synced 2026-10-03 20:19:19 +00:00
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.
32 lines
979 B
Nix
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'
|
|
'';
|
|
};
|
|
}
|