From bd67428b38dd9548f0b7849ce1072f80dae72320 Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Wed, 5 Feb 2025 20:56:30 +0800 Subject: [PATCH] libnfc: Use autotools to build, fix broken darwin support Without this the following error occurs on real device like PN532: ``` $ LIBNFC_DEVICE=pn532_uart:/dev/tty.usbserial-110 nfc-list nfc-list uses libnfc 1.8.0 error libnfc.bus.uart Unable to set serial port speed to 115200 baud. Speed value must be one of those defined in termios(3). error libnfc.driver.pn532_uart pn53x_check_communication error nfc-list: ERROR: Unable to open NFC device: pn532_uart:/dev/tty.usbserial-110 ``` --- pkgs/by-name/li/libnfc/package.nix | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/li/libnfc/package.nix b/pkgs/by-name/li/libnfc/package.nix index 1d7560d9e1c5..c6a4100f4bec 100644 --- a/pkgs/by-name/li/libnfc/package.nix +++ b/pkgs/by-name/li/libnfc/package.nix @@ -4,7 +4,7 @@ fetchFromGitHub, libusb-compat-0_1, readline, - cmake, + autoreconfHook, pkg-config, }: @@ -20,24 +20,31 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ - cmake + # Note: Use autotools instead of cmake to build for darwin. + # When built with cmake, the following error occurs on real device like PN532: + # ``` + # $ LIBNFC_DEVICE=pn532_uart:/dev/tty.usbserial-110 nfc-list + # nfc-list uses libnfc 1.8.0 + # error libnfc.bus.uart Unable to set serial port speed to 115200 baud. Speed value must be one of those defined in termios(3). + # error libnfc.driver.pn532_uart pn53x_check_communication error + # nfc-list: ERROR: Unable to open NFC device: pn532_uart:/dev/tty.usbserial-110 + # ``` + autoreconfHook pkg-config ]; buildInputs = [ - libusb-compat-0_1 readline ]; + propagatedBuildInputs = [ + libusb-compat-0_1 + ]; + configureFlags = [ "sysconfdir=/etc" ]; - cmakeFlags = lib.optionals stdenv.hostPlatform.isDarwin [ - "-DLIBNFC_DRIVER_PN532_I2C=OFF" - "-DLIBNFC_DRIVER_PN532_SPI=OFF" - ]; - meta = with lib; { description = "Library for Near Field Communication (NFC)"; homepage = "https://github.com/nfc-tools/libnfc";