From 450e7db0661c904c3f0d5a7002c7e82e4ca34170 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Tue, 4 Oct 2022 20:26:06 -0400 Subject: [PATCH] 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 --- pkgs/games/blightmud/default.nix | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/pkgs/games/blightmud/default.nix b/pkgs/games/blightmud/default.nix index 32c9ddb65347..57df987b957f 100644 --- a/pkgs/games/blightmud/default.nix +++ b/pkgs/games/blightmud/default.nix @@ -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.