Skip to content

Commit 71e85a2

Browse files
committed
wrapPackage: move "$@" from template into default args
Instead of hardcoding "$@" in the wrapper template, include it in the default args list. The template no longer appends "$@" on its own. This means passing explicit args to wrapPackage gives full control over whether "$@" is included. The default args (from flags) still append "$@" for backward compatibility. Removes the custom wrapper function override from wrapper.nix since wrapPackage's template no longer conflicts with the module's "$@" injection. Add CHANGELOG documenting breaking changes.
1 parent 18219d3 commit 71e85a2

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
### Breaking changes
6+
7+
- `wrapPackage`: when passing explicit `args`, `"$@"` is no longer
8+
appended automatically by the wrapper template. If you pass custom
9+
`args` and want passthrough, include `"$@"` in your args list.
10+
The default `args` (generated from `flags`) still includes `"$@"`.
11+
12+
- `flagSeparator` default changed from `" "` to `null`. The old `" "`
13+
default was misleading: it produced separate argv entries, not a
14+
space-joined arg. `null` now means separate argv entries. If you
15+
were explicitly passing `flagSeparator = " "` to get separate args,
16+
remove it (or change to `null`).
17+
18+
### Added
19+
20+
- `lib/modules/command.nix`: base module with shared command spec
21+
(args, env, hooks, exePath) used by both wrapper and systemd outputs.
22+
- `lib/modules/flags.nix`: flags module with per-flag ordering via
23+
`{ value, order }` submodules. Default order is 1000. Reading
24+
`config.flags` returns clean values (order is transparent).
25+
- `wrapper.nix` injects `"$@"` into args at order 1001, controllable
26+
via the ordering system.
27+
- `outputs.wrapper` as the canonical output path (config.wrapper is
28+
a backward-compatible alias).

lib/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ let
451451
flags ? { },
452452
flagSeparator ? null,
453453
# null for "--flag" "value" (separate args) or "=" for "--flag=value"
454-
args ? generateArgsFromFlags flags flagSeparator,
454+
args ? generateArgsFromFlags flags flagSeparator ++ [ "$@" ],
455455
preHook ? "",
456456
postHook ? "",
457457
passthru ? { },
@@ -473,7 +473,7 @@ let
473473
''
474474
${envString}
475475
${preHook}
476-
${lib.optionalString (postHook == "") "exec"} ${exePath}${flagsString} "$@"
476+
${lib.optionalString (postHook == "") "exec"} ${exePath}${flagsString}
477477
${postHook}
478478
''
479479
),

lib/modules/wrapper.nix

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,6 @@
6565
configuration = config;
6666
}
6767
// config.passthru;
68-
# Custom wrapper function: "$@" is already in args, so don't add it again
69-
wrapper =
70-
{
71-
exePath,
72-
flagsString,
73-
envString,
74-
preHook,
75-
postHook,
76-
...
77-
}:
78-
''
79-
${envString}
80-
${preHook}
81-
${lib.optionalString (postHook == "") "exec"} ${exePath}${flagsString}
82-
${postHook}
83-
'';
8468
};
8569
};
8670
options.wrapper = lib.mkOption {

0 commit comments

Comments
 (0)