about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/misc/yubico-piv-tool/default.nix
blob: 61d76205a6d683714bf2bc767544fdb2ddc8a531 (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
{ lib
, stdenv
, fetchFromGitHub
, pkg-config
, openssl
, check
, pcsclite
, PCSC
, gengetopt
, help2man
, cmake
, zlib
, withApplePCSC ? stdenv.isDarwin
, nix-update-script
, testers
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "yubico-piv-tool";
  version = "2.4.1";

  outputs = [ "out" "dev" "man" ];

  src = fetchFromGitHub {
    owner = "Yubico";
    repo = "yubico-piv-tool";
    rev = "refs/tags/yubico-piv-tool-${finalAttrs.version}";
    hash = "sha256-KprY5BX7Fi/qWRT1pda9g8fqnmDB1Bh7oFM7sCwViuw=";
  };

  postPatch = ''
    substituteInPlace CMakeLists.txt --replace "-Werror" ""
  '';

  nativeBuildInputs = [
    pkg-config
    cmake
    gengetopt
    help2man
  ];

  buildInputs = [
    openssl
    check
    zlib.dev
  ]
  ++ (if withApplePCSC then [ PCSC ] else [ pcsclite ]);

  cmakeFlags = [
    "-DGENERATE_MAN_PAGES=ON"
    "-DCMAKE_INSTALL_BINDIR=bin"
    "-DCMAKE_INSTALL_INCLUDEDIR=include"
    "-DCMAKE_INSTALL_MANDIR=share/man"
    "-DCMAKE_INSTALL_LIBDIR=lib"
  ];

  configureFlags = [ "--with-backend=${if withApplePCSC then "macscard" else "pcsc"}" ];

  passthru = {
    updateScript = nix-update-script {
      extraArgs = [ "--version-regex" "yubico-piv-tool-([0-9.]+)$" ];
    };
    tests.version = testers.testVersion {
      package = finalAttrs.finalPackage;
      command = "yubico-piv-tool --version";
    };
  };

  meta = with lib; {
    homepage = "https://developers.yubico.com/yubico-piv-tool/";
    changelog = "https://developers.yubico.com/yubico-piv-tool/Release_Notes.html";
    description = ''
      Used for interacting with the Privilege and Identification Card (PIV)
      application on a YubiKey
    '';
    longDescription = ''
      The Yubico PIV tool is used for interacting with the Privilege and
      Identification Card (PIV) application on a YubiKey.
      With it you may generate keys on the device, importing keys and
      certificates, and create certificate requests, and other operations.
      A shared library and a command-line tool is included.
    '';
    license = licenses.bsd2;
    platforms = platforms.all;
    maintainers = with maintainers; [ viraptor anthonyroussel ];
    mainProgram = "yubico-piv-tool";
  };
})