From 13270e7feb05976dbde5e94e6b155f35592436e3 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 15 Apr 2024 13:09:11 -0700 Subject: [PATCH 1/8] pcsclite: remove isLinux condition from --enable-ipcdir configureFlag The `--enable-ipcdir=/run/pcscd` flag was added by commit 2b93e96d0bdf5 "pcsclite: add policy kit support". However the pcscd IPC mechanism is completely independent from polkit, systemd, and dbus. There is no reason to disable the IPC mechanism on all non-Linux platforms. --- pkgs/tools/security/pcsclite/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix index 1a5d9badf3c7..2e383cd393bd 100644 --- a/pkgs/tools/security/pcsclite/default.nix +++ b/pkgs/tools/security/pcsclite/default.nix @@ -37,8 +37,8 @@ stdenv.mkDerivation (finalAttrs: { "--enable-usbdropdir=/var/lib/pcsc/drivers" (lib.enableFeature stdenv.isLinux "libsystemd") (lib.enableFeature polkitSupport "polkit") - ] ++ lib.optionals stdenv.isLinux [ "--enable-ipcdir=/run/pcscd" + ] ++ lib.optionals stdenv.isLinux [ "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system" ]; From dec7ebf0cd4176770cbf3f17dba913f8c3f8e373 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 15 Apr 2024 13:09:12 -0700 Subject: [PATCH 2/8] pcsclite: make systemdSupport optional --- pkgs/tools/security/pcsclite/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix index 2e383cd393bd..eb85cb79bc79 100644 --- a/pkgs/tools/security/pcsclite/default.nix +++ b/pkgs/tools/security/pcsclite/default.nix @@ -10,6 +10,7 @@ , dbus , polkit , systemdLibs +, systemdSupport ? stdenv.isLinux , IOKit , testers , nix-update-script @@ -35,10 +36,10 @@ stdenv.mkDerivation (finalAttrs: { "--enable-confdir=/etc" # The OS should care on preparing the drivers into this location "--enable-usbdropdir=/var/lib/pcsc/drivers" - (lib.enableFeature stdenv.isLinux "libsystemd") + (lib.enableFeature systemdSupport "libsystemd") (lib.enableFeature polkitSupport "polkit") "--enable-ipcdir=/run/pcscd" - ] ++ lib.optionals stdenv.isLinux [ + ] ++ lib.optionals systemdSupport [ "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system" ]; @@ -70,7 +71,7 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ python3 ] - ++ lib.optionals stdenv.isLinux [ systemdLibs ] + ++ lib.optionals systemdSupport [ systemdLibs ] ++ lib.optionals stdenv.isDarwin [ IOKit ] ++ lib.optionals polkitSupport [ dbus polkit ]; From a87a075306b505030823ff051342c99351e4cd84 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 15 Apr 2024 13:09:13 -0700 Subject: [PATCH 3/8] pcsclite: make dbusSupport optional --- pkgs/tools/security/pcsclite/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix index eb85cb79bc79..bc0caffe4ff1 100644 --- a/pkgs/tools/security/pcsclite/default.nix +++ b/pkgs/tools/security/pcsclite/default.nix @@ -10,6 +10,7 @@ , dbus , polkit , systemdLibs +, dbusSupport ? stdenv.isLinux , systemdSupport ? stdenv.isLinux , IOKit , testers @@ -18,6 +19,9 @@ , polkitSupport ? false }: +assert polkitSupport -> dbusSupport; +assert systemdSupport -> dbusSupport; + stdenv.mkDerivation (finalAttrs: { inherit pname; version = "2.1.0"; @@ -73,7 +77,8 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ python3 ] ++ lib.optionals systemdSupport [ systemdLibs ] ++ lib.optionals stdenv.isDarwin [ IOKit ] - ++ lib.optionals polkitSupport [ dbus polkit ]; + ++ lib.optionals dbusSupport [ dbus ] + ++ lib.optionals polkitSupport [ polkit ]; passthru = { tests = { From 2c387ccce11e0723b94f99cec4901c3543eb149a Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 15 Apr 2024 13:09:14 -0700 Subject: [PATCH 4/8] pcsclite: make udevSupport optional This commit allows the use of pcscd on platforms which use mdevd and libudev-zero instead of systemd-udevd. When udevd is not running, pcscd needs to link against libusb so that it can scan the USB busses itself, rather than relying on udevd to do that. --- pkgs/tools/security/pcsclite/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix index bc0caffe4ff1..f0e61ac6f9c3 100644 --- a/pkgs/tools/security/pcsclite/default.nix +++ b/pkgs/tools/security/pcsclite/default.nix @@ -12,6 +12,8 @@ , systemdLibs , dbusSupport ? stdenv.isLinux , systemdSupport ? stdenv.isLinux +, udevSupport ? dbusSupport +, libusb1 , IOKit , testers , nix-update-script @@ -45,6 +47,8 @@ stdenv.mkDerivation (finalAttrs: { "--enable-ipcdir=/run/pcscd" ] ++ lib.optionals systemdSupport [ "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system" + ] ++ lib.optionals (!udevSupport) [ + "--disable-libudev" ]; makeFlags = [ @@ -78,7 +82,8 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optionals systemdSupport [ systemdLibs ] ++ lib.optionals stdenv.isDarwin [ IOKit ] ++ lib.optionals dbusSupport [ dbus ] - ++ lib.optionals polkitSupport [ polkit ]; + ++ lib.optionals polkitSupport [ polkit ] + ++ lib.optionals (!udevSupport) [ libusb1 ]; passthru = { tests = { From b9fe1f4e3b9efc7e6b636a380a87f056d9a19907 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 15 Apr 2024 13:09:15 -0700 Subject: [PATCH 5/8] perlPackages.ChipcardPCSC: fix cross --- pkgs/top-level/perl-packages.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix index bf073f4b7bcf..38b9aabb6cb8 100644 --- a/pkgs/top-level/perl-packages.nix +++ b/pkgs/top-level/perl-packages.nix @@ -3312,6 +3312,9 @@ with self; { "-Wno-error=implicit-int" "-Wno-error=int-conversion" ]); + postPatch = '' + substituteInPlace Makefile.PL --replace pkg-config $PKG_CONFIG + ''; NIX_CFLAGS_LINK = "-L${lib.getLib pkgs.pcsclite}/lib -lpcsclite"; # tests fail; look unfinished doCheck = false; From 12cf912670a45f3adb0e1eee97be5b9a8dfcc4ae Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 15 Apr 2024 13:09:16 -0700 Subject: [PATCH 6/8] pcsc-tools: make gui, dbus, and systemd each (independently) optional --- pkgs/tools/security/pcsc-tools/default.nix | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/pkgs/tools/security/pcsc-tools/default.nix b/pkgs/tools/security/pcsc-tools/default.nix index c479caa0a613..29d4562d47c5 100644 --- a/pkgs/tools/security/pcsc-tools/default.nix +++ b/pkgs/tools/security/pcsc-tools/default.nix @@ -7,8 +7,8 @@ , makeWrapper , pkg-config , wrapGAppsHook -, systemd -, dbus +, systemdSupport ? stdenv.isLinux, systemd +, dbusSupport ? stdenv.isLinux, dbus , pcsclite , PCSC , wget @@ -16,8 +16,13 @@ , perlPackages , testers , nix-update-script + +# gui does not cross compile properly +, withGui ? stdenv.buildPlatform.canExecute stdenv.hostPlatform }: +assert systemdSupport -> dbusSupport; + stdenv.mkDerivation (finalAttrs: { pname = "pcsc-tools"; version = "1.7.1"; @@ -33,16 +38,20 @@ stdenv.mkDerivation (finalAttrs: { "--datarootdir=${placeholder "out"}/share" ]; - buildInputs = [ dbus perlPackages.perl pcsclite ] - ++ lib.optional stdenv.isDarwin PCSC - ++ lib.optional stdenv.isLinux systemd; + buildInputs = lib.optionals dbusSupport [ + dbus + ] ++ [ + perlPackages.perl pcsclite + ] ++ lib.optional stdenv.isDarwin PCSC + ++ lib.optional systemdSupport systemd; nativeBuildInputs = [ autoconf-archive autoreconfHook - gobject-introspection makeWrapper pkg-config + ] ++ lib.optionals withGui [ + gobject-introspection wrapGAppsHook ]; @@ -54,6 +63,7 @@ stdenv.mkDerivation (finalAttrs: { wrapProgram $out/bin/scriptor \ --set PERL5LIB "${with perlPackages; makePerlPath [ ChipcardPCSC libintl-perl ]}" + '' + lib.optionalString withGui '' wrapProgram $out/bin/gscriptor \ ''${makeWrapperArgs[@]} \ --set PERL5LIB "${with perlPackages; makePerlPath [ @@ -66,6 +76,7 @@ stdenv.mkDerivation (finalAttrs: { Cairo CairoGObject ]}" + '' + '' wrapProgram $out/bin/ATR_analysis \ --set PERL5LIB "${with perlPackages; makePerlPath [ ChipcardPCSC libintl-perl ]}" From 132f097b479e132f6d8127c6acc9998676e5d1f9 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 19 Apr 2024 17:06:26 +0300 Subject: [PATCH 7/8] pcsc-tools: use lib.meta.availableOn for systemdSupport --- pkgs/tools/security/pcsc-tools/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/security/pcsc-tools/default.nix b/pkgs/tools/security/pcsc-tools/default.nix index 29d4562d47c5..d2cb57bd485f 100644 --- a/pkgs/tools/security/pcsc-tools/default.nix +++ b/pkgs/tools/security/pcsc-tools/default.nix @@ -7,7 +7,7 @@ , makeWrapper , pkg-config , wrapGAppsHook -, systemdSupport ? stdenv.isLinux, systemd +, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd , dbusSupport ? stdenv.isLinux, dbus , pcsclite , PCSC From 4b0a16aad30dfc8a3f9d7847c0d0ef91fa3abf34 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 19 Apr 2024 23:28:10 +0300 Subject: [PATCH 8/8] pcsclite: use lib.meta.availableOn for systemdSupport --- pkgs/tools/security/pcsclite/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix index f0e61ac6f9c3..b078ee737bd9 100644 --- a/pkgs/tools/security/pcsclite/default.nix +++ b/pkgs/tools/security/pcsclite/default.nix @@ -11,7 +11,7 @@ , polkit , systemdLibs , dbusSupport ? stdenv.isLinux -, systemdSupport ? stdenv.isLinux +, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdLibs , udevSupport ? dbusSupport , libusb1 , IOKit