about summary refs log tree commit diff
path: root/pkgs/development/compilers/rust/rustc.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-10-15 23:23:42 +0000
committerYureka <yuka@yuka.dev>2022-10-16 19:09:09 +0200
commitada5320ea36e6db415c0c0f53283f4b05d7863bd (patch)
tree87374a86ba3301b8d7e4afc48b90ab754fac7434 /pkgs/development/compilers/rust/rustc.nix
parentab7742206a5ba8fd673726d02ef3584bb9f4d262 (diff)
rustc: add missing xz dependency
The "bootstrap" and "installer" crates depend on lzma-sys, which will
build its own version of xz if it can't find the liblzma.pc through
pkg-config.  Even though it's used as a library, xz here is a native
build input, as it is used by the build system rather than the end
product.
Diffstat (limited to 'pkgs/development/compilers/rust/rustc.nix')
-rw-r--r--pkgs/development/compilers/rust/rustc.nix13
1 files changed, 11 insertions, 2 deletions
diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index e3c20bebd499c..668046ac12bc8 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -2,7 +2,7 @@
 , llvmShared, llvmSharedForBuild, llvmSharedForHost, llvmSharedForTarget, llvmPackages
 , fetchurl, file, python3
 , darwin, cmake, rust, rustPlatform
-, pkg-config, openssl
+, pkg-config, openssl, xz
 , libiconv
 , which, libffi
 , withBundledLLVM ? false
@@ -41,6 +41,13 @@ in stdenv.mkDerivation rec {
   # See: https://github.com/NixOS/nixpkgs/pull/56540#issuecomment-471624656
   stripDebugList = [ "bin" ];
 
+  # The Rust pkg-config crate does not support prefixed pkg-config executables[1],
+  # but it does support checking these idiosyncratic PKG_CONFIG_${TRIPLE}
+  # environment variables.
+  # [1]: https://github.com/rust-lang/pkg-config-rs/issues/53
+  "PKG_CONFIG_${builtins.replaceStrings ["-"] ["_"] (rust.toRustTarget stdenv.buildPlatform)}" =
+    "${pkgsBuildHost.stdenv.cc.targetPrefix}pkg-config";
+
   NIX_LDFLAGS = toString (
        # when linking stage1 libstd: cc: undefined reference to `__cxa_begin_catch'
        optional (stdenv.isLinux && !withBundledLLVM) "--push-state --as-needed -lstdc++ --pop-state"
@@ -148,9 +155,11 @@ in stdenv.mkDerivation rec {
   # use it for the normal build. This disables cmake in Nix.
   dontUseCmakeConfigure = true;
 
+  depsBuildBuild = [ pkg-config ];
+
   nativeBuildInputs = [
     file python3 rustPlatform.rust.rustc cmake
-    which libffi removeReferencesTo pkg-config
+    which libffi removeReferencesTo pkg-config xz
   ];
 
   buildInputs = [ openssl ]