summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/p1/p11-kit/package.nix
blob: e730e02496d3132acfb73fa5ae472bdfe0eb56bb (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
{
  lib,
  stdenv,
  fetchFromGitHub,
  meson,
  ninja,
  pkg-config,
  libtasn1,
  libxslt,
  docbook-xsl-nons,
  docbook_xml_dtd_43,
  gettext,
  libffi,
  libintl,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "p11-kit";
  version = "0.26.2";

  src = fetchFromGitHub {
    owner = "p11-glue";
    repo = "p11-kit";
    tag = finalAttrs.version;
    hash = "sha256-qFanbp0KPc6+CN4s5mMQNduzcxt/SrMcYWvIMZ0XnGY=";
    fetchSubmodules = true;
  };

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

  strictDeps = true;

  nativeBuildInputs = [
    meson
    ninja
    pkg-config
    libtasn1 # asn1Parser
    libxslt # xsltproc
    docbook-xsl-nons
    docbook_xml_dtd_43
    gettext
  ];

  buildInputs = [
    libffi
    libtasn1
    libintl
  ];

  mesonFlags = [
    "--sysconfdir=/etc"
    (lib.mesonBool "man" true)
    (lib.mesonEnable "systemd" false)
    (lib.mesonOption "bashcompdir" "${placeholder "bin"}/share/bash-completion/completions")
    (lib.mesonOption "trust_paths" (
      lib.concatStringsSep ":" [
        "/etc/ssl/trust-source" # p11-kit trust source
        "/etc/ssl/certs/ca-certificates.crt" # NixOS + Debian/Ubuntu/Arch/Gentoo...
        "/etc/pki/tls/certs/ca-bundle.crt" # Fedora/CentOS
        "/var/lib/ca-certificates/ca-bundle.pem" # openSUSE
        "/etc/ssl/cert.pem" # Darwin/macOS
      ]
    ))
  ];

  doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;

  postPatch = ''
    # Install sample config files to $out/etc even though they will be loaded from /etc.
    substituteInPlace p11-kit/meson.build \
      --replace-fail 'install_dir: prefix / p11_system_config' "install_dir: '$out/etc/pkcs11'"
  '';

  preCheck = ''
    # Tests run in fakeroot for non-root users (with Nix single-user install)
    if [ "$(id -u)" != "0" ]; then
      export FAKED_MODE=1
    fi
  '';

  __structuredAttrs = true;

  meta = {
    description = "Library for loading and sharing PKCS#11 modules";
    longDescription = ''
      Provides a way to load and enumerate PKCS#11 modules.
      Provides a standard configuration setup for installing
      PKCS#11 modules in such a way that they're discoverable.
    '';
    homepage = "https://p11-glue.github.io/p11-glue/p11-kit.html";
    changelog = [
      "https://github.com/p11-glue/p11-kit/raw/${finalAttrs.version}/NEWS"
      "https://github.com/p11-glue/p11-kit/releases/tag/${finalAttrs.version}"
    ];
    platforms = lib.platforms.all;
    badPlatforms = [
      # https://github.com/p11-glue/p11-kit/issues/355#issuecomment-778777141
      lib.systems.inspect.platformPatterns.isStatic
    ];
    license = lib.licenses.bsd3;
    mainProgram = "p11-kit";
    identifiers.cpeParts = lib.meta.cpeFullVersionWithVendor "p11-kit_project" finalAttrs.version;
  };
})