~andir/nixpkgs-dev

pcsclite: remove isLinux condition from --enable-ipcdir configureFlag 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, 36 insertions(+), 10 deletions(-)
Quoting Florian Klink (2024-04-15 08:21:20)
Ah, thanks for noticing this!

The `] ++ lib.optionals stdenv.isLinux [` gets added back in by the next patch
in the series -- this whole series was originally one big patch and I clearly
made a mistake here when splitting it up into separate commits.

I will send an updated series shortly that allows applying the first patch
without the other five.

  - a
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/51019/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 | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix
index 956bf451c7bf..44a045f1fa49 100644
--- a/pkgs/tools/security/pcsclite/default.nix
+++ b/pkgs/tools/security/pcsclite/default.nix
@@ -37,7 +37,6 @@ 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"
    "--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 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix
index 44a045f1fa49..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,9 +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 systemdSupport [
    "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
  ];

@@ -69,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..6c2673f83c63 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 polkitSupport [ polkit ]
    ++ lib.optionals dbusSupport [ dbus ]
  ;

  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 6c2673f83c63..33f2d7447473 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 polkitSupport [ polkit ]
    ++ lib.optionals dbusSupport [ dbus ]
    ++ 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