From 482b61e1423f264279bb321b8d8c93fb766d4927 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 5 Apr 2023 01:27:38 -0700 Subject: [PATCH 1/2] default-crate-overrides.nix: prevent `git fetch` The build.rs script shipped with evdev-sys attempts to detect cross compilation and uses a completely different codepath which does a `git fetch` inside the build script. This doesn't work in nixpkgs. This PR adds a `touch libevdev/.git` to trick the `build.rs` into thinking that it is not necessary to do a `git fetch`. Thanks to @figsoda for finding this more-elegant solution to the problem (my original solution needed to patch `build.rs`): https://github.com/NixOS/nixpkgs/pull/224893#pullrequestreview-1373809617 Tested on: - [x] `aarch64-linux` (cross from `x86_64-linux`) --- pkgs/build-support/rust/default-crate-overrides.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/rust/default-crate-overrides.nix b/pkgs/build-support/rust/default-crate-overrides.nix index 441c6dfaf9c30ca..a0e3c8fabea0629 100644 --- a/pkgs/build-support/rust/default-crate-overrides.nix +++ b/pkgs/build-support/rust/default-crate-overrides.nix @@ -36,6 +36,9 @@ , alsa-lib , graphene , protobuf +, autoconf +, automake +, libtool , ... }: @@ -85,8 +88,16 @@ in }; evdev-sys = attrs: { - nativeBuildInputs = [ pkg-config ]; + nativeBuildInputs = + [ pkg-config + python3 autoconf automake libtool # used only if HOST!=TARGET + ]; buildInputs = [ libevdev ]; + + # This prevents libevdev's build.rs from trying to `git fetch` when HOST!=TARGET + prePatch = '' + touch libevdev/.git + ''; }; expat-sys = attrs: { From 579b812b0e0395d10aa55507e2f6c2e0763fb565 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 6 Apr 2023 13:43:22 -0700 Subject: [PATCH 2/2] https://github.com/NixOS/nixpkgs/pull/224893#pullrequestreview-1375521876 --- pkgs/build-support/rust/default-crate-overrides.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/rust/default-crate-overrides.nix b/pkgs/build-support/rust/default-crate-overrides.nix index a0e3c8fabea0629..ce8217b403e6082 100644 --- a/pkgs/build-support/rust/default-crate-overrides.nix +++ b/pkgs/build-support/rust/default-crate-overrides.nix @@ -88,10 +88,11 @@ in }; evdev-sys = attrs: { - nativeBuildInputs = - [ pkg-config - python3 autoconf automake libtool # used only if HOST!=TARGET - ]; + nativeBuildInputs = [ + pkg-config + ] ++ lib.optionals (stdenv.buildPlatform.config != stdenv.hostPlatform.config) [ + python3 autoconf automake libtool + ]; buildInputs = [ libevdev ]; # This prevents libevdev's build.rs from trying to `git fetch` when HOST!=TARGET