~andir/nixpkgs-dev

[v2] pcsclite, pcsc{-d,tools}: fix cross, {systemd,udev,dbus}Support flags v1 PROPOSED

Adam Joseph: 6
 pcsclite: remove isLinux condition from --enable-ipcdir configureFlag
 pcsclite: make systemdSupport optional
 pcsclite: make dbusSupport optional
 pcsclite: make udevSupport optional
 perlPackages.ChipcardPCSC: fix cross
 pcsc-tools: make gui, dbus, and systemd each (independently) optional

 6 files changed, 37 insertions(+), 11 deletions(-)
Quoting Florian Klink (2024-04-19 01:23:23)
Next
Yes of course; sorry about the slow reply.
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~andir/nixpkgs-dev/patches/51041/mbox | git am -3
Learn more about email & git

[PATCH 1/6] pcsclite: remove isLinux condition from --enable-ipcdir configureFlag Export this patch

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 956bf451c7bf..ed5e8163eebc 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"
  ];

-- 
2.42.0

[PATCH 2/6] pcsclite: make systemdSupport optional Export this patch

---
 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 ed5e8163eebc..28a19aefa0d9 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 ];

-- 
2.42.0

[PATCH 3/6] pcsclite: make dbusSupport optional Export this patch

---
 pkgs/tools/security/pcsclite/default.nix | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix
index 28a19aefa0d9..d0160388ca65 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.0.3";
@@ -73,7 +77,9 @@ 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.version = testers.testVersion {
-- 
2.42.0

[PATCH 4/6] pcsclite: make udevSupport optional Export this patch

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 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix
index d0160388ca65..93b191c675e0 100644
--- a/pkgs/tools/security/pcsclite/default.nix
+++ b/pkgs/tools/security/pcsclite/default.nix
@@ -12,6 +12,7 @@
, systemdLibs
, dbusSupport ? stdenv.isLinux
, systemdSupport ? stdenv.isLinux
, udevSupport ? dbusSupport, libusb
, IOKit
, testers
, nix-update-script
@@ -19,6 +20,7 @@
, polkitSupport ? false
}:

assert dbusSupport -> udevSupport;
assert polkitSupport -> dbusSupport;
assert systemdSupport -> dbusSupport;

@@ -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 = [
@@ -79,6 +83,7 @@ stdenv.mkDerivation (finalAttrs: {
    ++ lib.optionals stdenv.isDarwin [ IOKit ]
    ++ lib.optionals dbusSupport [ dbus ]
    ++ lib.optionals polkitSupport [ polkit ]
    ++ lib.optionals (!udevSupport) [ libusb ]
  ;

  passthru = {
-- 
2.42.0

[PATCH 5/6] perlPackages.ChipcardPCSC: fix cross Export this patch

---
 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;
-- 
2.42.0

[PATCH 6/6] pcsc-tools: make gui, dbus, and systemd each (independently) optional Export this patch

---
 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 ]}"
-- 
2.42.0