Do not copy cargo artifacts into a separate output by default

* Copying the cargo artifacts to their own separate output is a good
  idea *in theory* where each derivation produces bins/libs so that
  other things can depend on them without pulling in the cargo artifacts
  as well
* In practice, it's much more likely that a derivation will produce
  cargo artifacts (to be reused in other build/test steps) XOR produce
  the final binaries
* Therefore _not_ separating the outputs will produce less friction when
  forming dependency trees in the general path (e.g. no more forgetting
  to specify `drv.target`)
* If a caller really wants to install cargo artifacts in a separate
  output, they can easily add the customization themselves
This commit is contained in:
Ivan Petkov 2022-01-01 11:12:13 -08:00
parent 0f94b11615
commit 10a60cc085
No known key found for this signature in database
GPG Key ID: BB6F9EFC065832B6
3 changed files with 3 additions and 6 deletions

View File

@ -39,7 +39,7 @@ let
cargoLock = path + /Cargo.lock;
in
if builtins.pathExists cargoToml && builtins.pathExists cargoLock
then (buildDepsOnly args).target
then buildDepsOnly args
else
throw ''
unable to find Cargo.toml and Cargo.lock at ${path}. please ensure one of the following:
@ -68,7 +68,6 @@ in
# as including them will make Nix pull in all sources when installing any binaries.
, doRemapSourcePathPrefix ? true
, nativeBuildInputs ? [ ]
, outputs ? [ "out" ]
, ...
}@args:
let
@ -93,8 +92,6 @@ let
};
additions = {
outputs = outputs ++ lib.optional doCopyTargetToOutput "target";
nativeBuildInputs = nativeBuildInputs ++ [
cargo
configureCargoCommonVarsHook

View File

@ -1,7 +1,7 @@
prepareCargoTargetDirAndCopyToDir() {
# Allow for calling with customized parameters
# or fall back to defaults if none are provided
local dir="${1:-${target}}"
local dir="${1:-${out}}"
local cargoTargetDir="${2:-${CARGO_TARGET_DIR:-target}}"
local dest="${dir}/target.tar.zst"

View File

@ -25,7 +25,7 @@ buildWithCargo {
# NB: explicit call here so that the buildDepsOnly call
# doesn't inherit our build commands
cargoArtifacts = (buildDepsOnly { inherit src; }).target;
cargoArtifacts = buildDepsOnly { inherit src; };
nativeBuildInputs = [ jq ];