diff --git a/pkgs/tools/video/rav1e/default.nix b/pkgs/tools/video/rav1e/default.nix index 244aed92f8135..83b4204d2dc51 100644 --- a/pkgs/tools/video/rav1e/default.nix +++ b/pkgs/tools/video/rav1e/default.nix @@ -10,10 +10,29 @@ , zlib , libiconv , Security +, buildPackages }: let rustTargetPlatformSpec = rust.toRustTargetSpec stdenv.hostPlatform; + + # TODO: if another package starts using cargo-c (seems likely), + # factor this out into a makeCargoChook expression in + # pkgs/build-support/rust/hooks/default.nix + ccForBuild = "${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"; + cxxForBuild = "${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++"; + ccForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; + cxxForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"; + rustBuildPlatform = rust.toRustTarget stdenv.buildPlatform; + rustTargetPlatform = rust.toRustTarget stdenv.hostPlatform; + setEnvVars = '' + env \ + "CC_${rustBuildPlatform}"="${ccForBuild}" \ + "CXX_${rustBuildPlatform}"="${cxxForBuild}" \ + "CC_${rustTargetPlatform}"="${ccForHost}" \ + "CXX_${rustTargetPlatform}"="${cxxForHost}" \ + ''; + in rustPlatform.buildRustPackage rec { pname = "rav1e"; version = "0.6.3"; @@ -38,11 +57,13 @@ in rustPlatform.buildRustPackage rec { checkType = "debug"; - postBuild = '' + postBuild = '' + ${setEnvVars} \ cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec} ''; postInstall = '' + ${setEnvVars} \ cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec} '';