Skip to content

Commit

Permalink
cargo: move cert info to fetch-cargo-tarball
Browse files Browse the repository at this point in the history
As proposed in #82496, we should only set the related env vars for the fetcher instead of breaking the function of cargo itself.
  • Loading branch information
linsui authored and zowoq committed Jan 31, 2023
1 parent ee2db08 commit 9bc4f34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 3 additions & 0 deletions pkgs/build-support/rust/fetch-cargo-tarball/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ in stdenv.mkDerivation ({
${cargoUpdateHook}
# Override the `http.cainfo` option usually specified in `.cargo/config`.
export CARGO_HTTP_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
cargo vendor $name --respect-source-config | cargo-vendor-normalise > $CARGO_CONFIG
# Create an empty vendor directory when there is no dependency to vendor
Expand Down
13 changes: 3 additions & 10 deletions pkgs/development/compilers/rust/cargo.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib, stdenv, pkgsHostHost
, file, curl, pkg-config, python3, openssl, cmake, zlib
, installShellFiles, makeWrapper, cacert, rustPlatform, rustc
, installShellFiles, makeWrapper, rustPlatform, rustc
, CoreFoundation, Security
, auditable ? false # TODO: change to true when this is the default
}:
Expand Down Expand Up @@ -28,7 +28,7 @@ rustPlatform.buildRustPackage {
(lib.getDev pkgsHostHost.curl)
zlib
];
buildInputs = [ cacert file curl python3 openssl zlib ]
buildInputs = [ file curl python3 openssl zlib ]
++ lib.optionals stdenv.isDarwin [ CoreFoundation Security ];

# cargo uses git-rs which is made for a version of libgit2 from recent master that
Expand All @@ -39,14 +39,7 @@ rustPlatform.buildRustPackage {
RUSTC_BOOTSTRAP = 1;

postInstall = ''
# NOTE: We override the `http.cainfo` option usually specified in
# `.cargo/config`. This is an issue when users want to specify
# their own certificate chain as environment variables take
# precedence
wrapProgram "$out/bin/cargo" \
--suffix PATH : "${rustc}/bin" \
--set CARGO_HTTP_CAINFO "${cacert}/etc/ssl/certs/ca-bundle.crt" \
--set SSL_CERT_FILE "${cacert}/etc/ssl/certs/ca-bundle.crt"
wrapProgram "$out/bin/cargo" --suffix PATH : "${rustc}/bin"
installManPage src/tools/cargo/src/etc/man/*
Expand Down

0 comments on commit 9bc4f34

Please sign in to comment.