Skip to content

Commit

Permalink
various: change cargoExtraArgs defaults to include --locked (ipet…
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetkov authored Aug 27, 2023
1 parent ef5d11e commit 43db881
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 14 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

### Changed
* **Breaking** (technically): `buildDepsOnly`, `buildPackage`, `cargoBuild`,
`cargoClippy`, `cargoDoc`, `cargoLlvmCov`, and `cargoTest`'s defaults have
been changed such that if `cargoExtraArgs` have not been set, a default value
of `--locked` will be used. This ensures that a project's committed
`Cargo.lock` is exactly what is expected (without implicit changes at build
time) but this may end up rejecting builds which were previously passing. To
get the old behavior back, set `cargoExtraArgs = "";`

## [0.13.1] - 2023-08-22

### Changed
Expand Down
2 changes: 2 additions & 0 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ in
sha256 = "sha256-sNwizxYVUNyv5InR8HS+CyUsroA79h/FpouS+fMWJUI=";
};

cargoExtraArgs = "--offline";
doCheck = false; # Tests need llvm-tools installed
buildInputs = lib.optionals isDarwin [
pkgs.libiconv
Expand Down Expand Up @@ -576,6 +577,7 @@ in
postUnpack = ''
cd $sourceRoot/workspace
sourceRoot="."
[[ -f Cargo.lock ]] || ln ../Cargo.lock
'';
cargoLock = ./workspace-not-at-root/workspace/Cargo.lock;
cargoToml = ./workspace-not-at-root/workspace/Cargo.toml;
Expand Down
14 changes: 7 additions & 7 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ to influence its behavior.
- Default value: `"--all-targets"` if `doCheck` is set to true, `""` otherwise
* `cargoExtraArgs`: additional flags to be passed in the cargo invocation (e.g.
enabling specific features)
- Default value: `""`
- Default value: `"--locked"`
* `cargoTestCommand`: A cargo invocation to run during the derivation's check
phase
- Default value: `"cargo test --profile release"`
Expand Down Expand Up @@ -197,7 +197,7 @@ install hooks.
altogether.
* `cargoExtraArgs`: additional flags to be passed in the cargo invocation (e.g.
enabling specific features)
- Default value: `""`
- Default value: `"--locked"`
* `cargoTestCommand`: A cargo invocation to run during the derivation's check
phase
- Default value: `"cargo test --profile release"`
Expand Down Expand Up @@ -363,7 +363,7 @@ Except where noted below, all derivation attributes are delegated to
#### Optional attributes
* `cargoExtraArgs`: additional flags to be passed in the cargo invocation (e.g.
enabling specific features)
- Default value: `""`
- Default value: `"--locked"`

#### Remove attributes
The following attributes will be removed before being lowered to
Expand Down Expand Up @@ -403,7 +403,7 @@ Except where noted below, all derivation attributes are delegated to
- Default value: `"--all-targets"`
* `cargoExtraArgs`: additional flags to be passed in the cargo invocation (e.g.
enabling specific features)
- Default value: `""`
- Default value: `"--locked"`

#### Native build dependencies
The `clippy` package is automatically appended as a native build input to any
Expand Down Expand Up @@ -447,7 +447,7 @@ Except where noted below, all derivation attributes are delegated to
- Default value: `"--no-deps"`
* `cargoExtraArgs`: additional flags to be passed in the cargo invocation (e.g.
enabling specific features)
- Default value: `""`
- Default value: `"--locked"`

#### Remove attributes
The following attributes will be removed before being lowered to
Expand Down Expand Up @@ -517,7 +517,7 @@ Except where noted below, all derivation attributes are delegated to

#### Optional attributes
* `cargoExtraArgs`: additional flags to be passed in the cargo invocation
- Default value: `""`
- Default value: `"--locked"`
* `cargoLlvmCovCommand`: cargo-llvm-cov command to run
- Default value: `"test"`
* `cargoLlvmCovExtraArgs`: additional flags to be passed in the cargo
Expand Down Expand Up @@ -653,7 +653,7 @@ Except where noted below, all derivation attributes are delegated to

#### Optional attributes
* `cargoExtraArgs`: additional flags to be passed in the cargo invocation
- Default value: `""`
- Default value: `"--locked"`
* `cargoTestArgs`: additional flags to be passed in the cargo
invocation
- Default value: `""`
Expand Down
2 changes: 1 addition & 1 deletion lib/buildDepsOnly.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{ cargoBuildCommand ? "cargoWithProfile build"
, cargoCheckCommand ? "cargoWithProfile check"
, cargoExtraArgs ? ""
, cargoExtraArgs ? "--locked"
, cargoTestCommand ? "cargoWithProfile test"
, cargoTestExtraArgs ? ""
, ...
Expand Down
2 changes: 1 addition & 1 deletion lib/buildPackage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}:

{ cargoBuildCommand ? "cargoWithProfile build"
, cargoExtraArgs ? ""
, cargoExtraArgs ? "--locked"
, cargoTestCommand ? "cargoWithProfile test"
, cargoTestExtraArgs ? ""
, ...
Expand Down
2 changes: 1 addition & 1 deletion lib/cargoBuild.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
}:

{ cargoArtifacts
, cargoExtraArgs ? ""
, cargoExtraArgs ? "--locked"
, ...
}@origArgs:
let
Expand Down
2 changes: 1 addition & 1 deletion lib/cargoClippy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{ cargoArtifacts
, cargoClippyExtraArgs ? "--all-targets"
, cargoExtraArgs ? ""
, cargoExtraArgs ? "--locked"
, ...
}@origArgs:
let
Expand Down
2 changes: 1 addition & 1 deletion lib/cargoDoc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
}:

{ cargoDocExtraArgs ? "--no-deps"
, cargoExtraArgs ? ""
, cargoExtraArgs ? "--locked"
, ...
}@origArgs:
let
Expand Down
2 changes: 1 addition & 1 deletion lib/cargoLlvmCov.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, cargo-llvm-cov
}:

{ cargoExtraArgs ? ""
{ cargoExtraArgs ? "--locked"
, cargoLlvmCovCommand ? "test"
, cargoLlvmCovExtraArgs ? "--lcov --output-path $out"
, ...
Expand Down
2 changes: 1 addition & 1 deletion lib/cargoTest.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
}:

{ cargoArtifacts
, cargoExtraArgs ? ""
, cargoExtraArgs ? "--locked"
, cargoTestExtraArgs ? ""
, ...
}@origArgs:
Expand Down

0 comments on commit 43db881

Please sign in to comment.