blightmud: use rustPlatform.bindgenHook

By using `rustPlatform.bindgenHook` as a `nativeBuildInput` the
Blightmud derivation's custom LIBCLANG_PATH and preBuild step can be
removed outright. See the languages frameworks Rust hooks docs[0] for
more information.

[0]: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md#hooks-hooks
This commit is contained in:
Daniel McCarney 2022-10-04 20:26:06 -04:00
parent bcf1085724
commit 450e7db066

View File

@ -16,33 +16,10 @@ rustPlatform.buildRustPackage rec {
buildFeatures = lib.optional withTTS "tts";
nativeBuildInputs = [ pkg-config ];
nativeBuildInputs = [ pkg-config rustPlatform.bindgenHook ];
buildInputs = [ alsa-lib openssl ] ++ lib.optional withTTS [ speechd ];
# Building the speech-dispatcher-sys crate for TTS support requires setting
# LIBCLANG_PATH.
LIBCLANG_PATH = lib.optionalString withTTS "${llvmPackages.libclang.lib}/lib";
preBuild = lib.optionalString withTTS ''
# When building w/ TTS the speech-dispatcher-sys crate's build.rs uses
# rust-bindgen with libspeechd. This bypasses the normal nixpkgs CC wrapper
# so we have to adapt the BINDGEN_EXTRA_CLANG_ARGS env var to compensate. See
# this blog post[0] for more information.
#
# [0]: https://hoverbear.org/blog/rust-bindgen-in-nix/
export BINDGEN_EXTRA_CLANG_ARGS="$(< ${stdenv.cc}/nix-support/libc-cflags) \
$(< ${stdenv.cc}/nix-support/cc-cflags) \
-isystem ${llvmPackages.libclang.lib}/lib/clang/${
lib.getVersion llvmPackages.clang
}/include \
-idirafter ${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.config}/${
lib.getVersion stdenv.cc.cc
}/include \
-idirafter ${speechd}/include"
'';
checkFlags = let
# Most of Blightmud's unit tests pass without trouble in the isolated
# Nixpkgs build env. The following tests need to be skipped.