Skip to content

Commit 534982f

Browse files
authored
{buildPackage,buildDepsOnly}: add cargoBuildExtraArgs option (#1010)
1 parent 4e8618a commit 534982f

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
Ultimately this should make no difference since the Nix store will reset all
1212
ownership permissions anyway, but it may avoid some spurious errors on certain
1313
systems.
14-
* `cargoNextest` now has a `cargoNextestArchiveExtraArgs` option for passing
15-
flags to nextest archive invocations.
14+
* `buildPackage` and `buildDepsOnly` now has a `cargoBuildExtraArgs` option for
15+
passing arguments specifically to `cargoBuildCommand`.
16+
* `cargoNextest` now accepts `cargoNextestArchiveExtraArgs` for passing
17+
flags to `cargo nextest archive` invocations.
1618

1719
## [0.23.2] - 2026-03-23
1820

docs/API.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ to influence its behavior.
105105
* `CARGO_PROFILE` can be set on the derivation to alter which cargo profile
106106
is selected; setting it to `""` will omit specifying a profile
107107
altogether.
108+
* `cargoBuildExtraArgs`: additional flags to be passed in the `cargoBuildCommand`
109+
invocation
110+
- Default value: `""`
108111
* `cargoCheckCommand`: A cargo (check) invocation to run during the derivation's build
109112
phase (in order to cache additional artifacts)
110113
- Default value: `"cargo check --profile release ${cargoCheckExtraArgs}"`
@@ -156,6 +159,7 @@ environment variables during the build, you can bring them back via
156159
`.overrideAttrs`.
157160

158161
* `cargoBuildCommand`
162+
* `cargoBuildExtraArgs`
159163
* `cargoCheckCommand`
160164
* `cargoCheckExtraArgs`
161165
* `cargoExtraArgs`
@@ -204,6 +208,9 @@ install hooks.
204208
* `CARGO_PROFILE` can be set on the derivation to alter which cargo profile
205209
is selected; setting it to `""` will omit specifying a profile
206210
altogether.
211+
* `cargoBuildExtraArgs`: additional flags to be passed in the `cargoBuildCommand`
212+
invocation
213+
- Default value: `""`
207214
* `cargoExtraArgs`: additional flags to be passed in the cargo invocation (e.g.
208215
enabling specific features)
209216
- Default value: `"--locked"`
@@ -233,6 +240,7 @@ environment variables during the build, you can bring them back via
233240
`.overrideAttrs`.
234241

235242
* `cargoBuildCommand`
243+
* `cargoBuildExtraArgs`
236244
* `cargoExtraArgs`
237245
* `cargoTestCommand`
238246
* `cargoTestExtraArgs`

lib/buildDepsOnly.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
cargoBuildCommand ? "cargoWithProfile build",
1111
cargoCheckCommand ? "cargoWithProfile check",
1212
cargoExtraArgs ? "--locked",
13+
cargoBuildExtraArgs ? "",
1314
cargoTestCommand ? "cargoWithProfile test",
1415
cargoTestExtraArgs ? "--no-run",
1516
...
@@ -20,6 +21,7 @@ let
2021
"cargoCheckCommand"
2122
"cargoCheckExtraArgs"
2223
"cargoExtraArgs"
24+
"cargoBuildExtraArgs"
2325
"cargoTestCommand"
2426
"cargoTestExtraArgs"
2527
"outputHashes"
@@ -75,7 +77,7 @@ mkCargoDerivation (
7577
buildPhaseCargoCommand =
7678
args.buildPhaseCargoCommand or ''
7779
${cargoCheckCommand} ${cargoExtraArgs} ${cargoCheckExtraArgs}
78-
${cargoBuildCommand} ${cargoExtraArgs}
80+
${cargoBuildCommand} ${cargoExtraArgs} ${cargoBuildExtraArgs}
7981
'';
8082

8183
checkPhaseCargoCommand =

lib/buildPackage.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{
1313
cargoBuildCommand ? "cargoWithProfile build",
1414
cargoExtraArgs ? "--locked",
15+
cargoBuildExtraArgs ? "",
1516
cargoTestCommand ? "cargoWithProfile test",
1617
cargoTestExtraArgs ? "",
1718
...
@@ -23,6 +24,7 @@ let
2324
cleanedArgs = removeAttrs args [
2425
"cargoBuildCommand"
2526
"cargoExtraArgs"
27+
"cargoBuildExtraArgs"
2628
"cargoTestCommand"
2729
"cargoTestExtraArgs"
2830
"outputHashes"
@@ -57,7 +59,7 @@ mkCargoDerivation (
5759
buildPhaseCargoCommand =
5860
args.buildPhaseCargoCommand or ''
5961
cargoBuildLog=$(mktemp cargoBuildLogXXXX.json)
60-
${cargoBuildCommand} --message-format json-render-diagnostics ${cargoExtraArgs} >"$cargoBuildLog"
62+
${cargoBuildCommand} --message-format json-render-diagnostics ${cargoExtraArgs} ${cargoBuildExtraArgs} >"$cargoBuildLog"
6163
'';
6264

6365
checkPhaseCargoCommand =

0 commit comments

Comments
 (0)