10 Commits

Author SHA1 Message Date
Austin Horstman
02618d94f8 nh: use systemd escaping for cleanup argument lists
Use the shared helper to preserve argument boundaries in ExecStart, including embedded newlines. Keep legacy strings and Darwin behavior unchanged, and cover the newline case in a Linux regression test.
2026-09-12 22:02:25 -05:00
OddMagnet
d3c99311d7 nh: accept a list for clean.extraArgs
Splitting the string on spaces broke arguments that legitimately contain
one, such as `--keep-since=1 day`. Accept a list of strings alongside the
string instead, each element being one argument, and restore the previous
behaviour for strings on both platforms: command line text that systemd
splits on Linux, a single argument on Darwin.

Darwin users passing several flags in one string have to switch to a list
to work around the launchd quoting.

On Linux the arguments are only appended when non-empty, which drops a
trailing space from ExecStart.
2026-09-12 22:02:25 -05:00
OddMagnet
3e05f1d3cd nh: split clean.extraArgs into separate launchd arguments
On darwin, clean.extraArgs was appended to ProgramArguments as a single
list element, so the launchd module rendered it as one shell-quoted word
and nh received every flag as a single argument:

  nh clean user '--keep 5 --keep-since 3d'
  error: unexpected argument '--keep 5 --keep-since 3d' found

Linux is unaffected: there extraArgs is interpolated into ExecStart as
text, and systemd splits that into arguments itself. Split on spaces so
both platforms treat the option the same way, dropping empty fields so
that an unset or space-padded value contributes no arguments.

The existing darwin test never set extraArgs, which is why this went
unnoticed. Add a case covering the option's own documented example.
2026-09-12 22:02:25 -05:00
Austin Horstman
165228b0ef launchd: restore gui domain defaults
User-domain agents are not rediscovered from the user LaunchAgents directory after reboot. Let built-in agents inherit the GUI default while keeping explicit user-domain configuration available.
2026-07-15 10:29:26 -05:00
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
Wael Nasreddine
eec72f1278 launchd: wait for /nix/store before starting agent (#8609)
On Darwin, launchd may attempt to start agents before the Nix store is
mounted and available. This leads to failures when the agent's executable
or arguments reside in the Nix store.

This change wraps the agent's command in a shell script that uses
/bin/wait4path to ensure /nix/store is ready before executing the
original program. It also ensures that ProgramArguments are correctly
escaped and concatenated.
2026-01-27 21:51:48 -08:00
Foxocube
4e97102bd4 nh: add options for specific flakes (#7566)
* nh: Add options for specific flakes
* nh: Add tests for specific flake options

---------

Co-authored-by: Foxocube <git@foxocube.xyz>
2025-07-31 12:41:29 -05:00
Ali Jamadi
e8a3e2c1e0 nh: fix clean option behaviour for Darwin 2025-06-30 21:12:20 -05:00
Austin Horstman
06c1392ca8 tests: implement auto importing for modules
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-06-22 23:58:37 -05:00
Austin Horstman
273ad32fbb tests/nh: init tests (#6819) 2025-04-14 12:07:02 -05:00