From 450e7db0661c904c3f0d5a7002c7e82e4ca34170 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Tue, 4 Oct 2022 20:26:06 -0400 Subject: [PATCH 1/3] 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. From aa88e214ef4ca7aaa7c8ee78402be7b1e572d4d3 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Tue, 4 Oct 2022 20:32:06 -0400 Subject: [PATCH 2/3] blightmud: apply nixpkgs-format For consistency, this commit runs the Blightmud derivation through `nixpkgs-format`. --- pkgs/games/blightmud/default.nix | 49 +++++++++++++++++++------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/pkgs/games/blightmud/default.nix b/pkgs/games/blightmud/default.nix index 57df987b957f..b1c92f32b299 100644 --- a/pkgs/games/blightmud/default.nix +++ b/pkgs/games/blightmud/default.nix @@ -1,5 +1,14 @@ -{ stdenv, lib, fetchFromGitHub, rustPlatform, pkg-config, alsa-lib, openssl -, withTTS ? false, llvmPackages, speechd }: +{ stdenv +, lib +, fetchFromGitHub +, rustPlatform +, pkg-config +, alsa-lib +, openssl +, withTTS ? false +, llvmPackages +, speechd +}: rustPlatform.buildRustPackage rec { pname = "blightmud"; @@ -20,23 +29,25 @@ rustPlatform.buildRustPackage rec { buildInputs = [ alsa-lib openssl ] ++ lib.optional withTTS [ speechd ]; - checkFlags = let - # Most of Blightmud's unit tests pass without trouble in the isolated - # Nixpkgs build env. The following tests need to be skipped. - skipList = [ - "test_connect" - "test_gmcp_negotiation" - "test_ttype_negotiation" - "test_reconnect" - "test_is_connected" - "test_mud" - "test_server" - "test_lua_script" - "timer_test" - "validate_assertion_fail" - ]; - skipFlag = test: "--skip " + test; - in builtins.concatStringsSep " " (builtins.map skipFlag skipList); + checkFlags = + let + # Most of Blightmud's unit tests pass without trouble in the isolated + # Nixpkgs build env. The following tests need to be skipped. + skipList = [ + "test_connect" + "test_gmcp_negotiation" + "test_ttype_negotiation" + "test_reconnect" + "test_is_connected" + "test_mud" + "test_server" + "test_lua_script" + "timer_test" + "validate_assertion_fail" + ]; + skipFlag = test: "--skip " + test; + in + builtins.concatStringsSep " " (builtins.map skipFlag skipList); meta = with lib; { description = "A terminal MUD client written in Rust"; From deed43a7257ea861e00d627b98f0e62d2072d790 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Tue, 4 Oct 2022 20:45:16 -0400 Subject: [PATCH 3/3] blightmud: remove unused derivation arg. --- pkgs/games/blightmud/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/games/blightmud/default.nix b/pkgs/games/blightmud/default.nix index b1c92f32b299..1937f84f88f7 100644 --- a/pkgs/games/blightmud/default.nix +++ b/pkgs/games/blightmud/default.nix @@ -6,7 +6,6 @@ , alsa-lib , openssl , withTTS ? false -, llvmPackages , speechd }: