about summary refs log tree commit diff
path: root/pkgs/tools/security/pcsc-tools/default.nix
blob: c479caa0a61379d77f07d2f06e3dc4e2e520b145 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{ stdenv
, lib
, fetchFromGitHub
, autoconf-archive
, autoreconfHook
, gobject-introspection
, makeWrapper
, pkg-config
, wrapGAppsHook
, systemd
, dbus
, pcsclite
, PCSC
, wget
, coreutils
, perlPackages
, testers
, nix-update-script
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "pcsc-tools";
  version = "1.7.1";

  src = fetchFromGitHub {
    owner = "LudovicRousseau";
    repo = "pcsc-tools";
    rev = "refs/tags/${finalAttrs.version}";
    hash = "sha256-+cvgSNlSYSJ2Zr2iWk96AacyQ38ru9/RK8yeK3ceqCo=";
  };

  configureFlags = [
    "--datarootdir=${placeholder "out"}/share"
  ];

  buildInputs = [ dbus perlPackages.perl pcsclite ]
    ++ lib.optional stdenv.isDarwin PCSC
    ++ lib.optional stdenv.isLinux systemd;

  nativeBuildInputs = [
    autoconf-archive
    autoreconfHook
    gobject-introspection
    makeWrapper
    pkg-config
    wrapGAppsHook
  ];

  preFixup = ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
  '';

  postInstall = ''
    wrapProgram $out/bin/scriptor \
      --set PERL5LIB "${with perlPackages; makePerlPath [ ChipcardPCSC libintl-perl ]}"

    wrapProgram $out/bin/gscriptor \
      ''${makeWrapperArgs[@]} \
      --set PERL5LIB "${with perlPackages; makePerlPath [
          ChipcardPCSC
          libintl-perl
          GlibObjectIntrospection
          Glib
          Gtk3
          Pango
          Cairo
          CairoGObject
      ]}"

    wrapProgram $out/bin/ATR_analysis \
      --set PERL5LIB "${with perlPackages; makePerlPath [ ChipcardPCSC libintl-perl ]}"

    wrapProgram $out/bin/pcsc_scan \
      --prefix PATH : "$out/bin:${lib.makeBinPath [ coreutils wget ]}"

    install -Dm444 -t $out/share/pcsc smartcard_list.txt
  '';

  passthru = {
    tests.version = testers.testVersion {
      package = finalAttrs.finalPackage;
      command = "pcsc_scan -V";
    };
    updateScript = nix-update-script { };
  };

  meta = with lib; {
    description = "Tools used to test a PC/SC driver, card or reader";
    homepage = "https://pcsc-tools.apdu.fr/";
    changelog = "https://github.com/LudovicRousseau/pcsc-tools/releases/tag/${finalAttrs.version}";
    license = licenses.gpl2Plus;
    mainProgram = "pcsc_scan";
    maintainers = with maintainers; [ peterhoeg anthonyroussel ];
    platforms = platforms.unix;
  };
})