From 71f5f45c33ac4c59e316c9d41ca8837b7d7f9e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Thu, 13 Jul 2023 19:25:44 +0000 Subject: [PATCH] libnfc: Support static builds nixpkgs upstreaming PR: https://github.com/NixOS/nixpkgs/pull/243328 --- pkgs/development/libraries/libnfc/default.nix | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/libnfc/default.nix b/pkgs/development/libraries/libnfc/default.nix index 88bc909ea0e6f..475b5e9354bed 100644 --- a/pkgs/development/libraries/libnfc/default.nix +++ b/pkgs/development/libraries/libnfc/default.nix @@ -1,10 +1,12 @@ { lib , stdenv , fetchFromGitHub +, fetchpatch , libusb-compat-0_1 , readline , cmake , pkg-config +, static ? false }: stdenv.mkDerivation rec { @@ -18,6 +20,15 @@ stdenv.mkDerivation rec { sha256 = "5gMv/HajPrUL/vkegEqHgN2d6Yzf01dTMrx4l34KMrQ="; }; + patches = [ + # From: https://github.com/nfc-tools/libnfc/pull/595 + (fetchpatch { + name = "libnfc-Enable-selection-of-static-vs-shared-builds.patch"; + url = "https://github.com/kino-dome/libnfc/commit/992f1c56ca7663357911c24843834a88ef98d8dc.patch"; + hash = "sha256:1q74nylxpmbw3iqxdi24kra4bfx7gjx1v0i0nzb1jkpp15580hp1"; + }) + ]; + nativeBuildInputs = [ cmake pkg-config @@ -32,9 +43,12 @@ stdenv.mkDerivation rec { "sysconfdir=/etc" ]; - cmakeFlags = lib.optionals stdenv.isDarwin [ - "-DLIBNFC_DRIVER_PN532_I2C=OFF" - "-DLIBNFC_DRIVER_PN532_SPI=OFF" + cmakeFlags = lib.concatLists [ + (lib.optionals stdenv.isDarwin [ + "-DLIBNFC_DRIVER_PN532_I2C=OFF" + "-DLIBNFC_DRIVER_PN532_SPI=OFF" + ]) + (lib.optional (!static) "-DBUILD_SHARED_LIBS:BOOL=ON") ]; meta = with lib; {