1{ lib
2, stdenv
3, fetchFromGitHub
4, meson
5, ninja
6, pkg-config
7, libtasn1
8, libxslt
9, docbook-xsl-nons
10, docbook_xml_dtd_43
11, gettext
12, mesonEmulatorHook
13, libffi
14, libintl
15}:
16
17stdenv.mkDerivation rec {
18 pname = "p11-kit";
19 version = "0.25.0";
20
21 src = fetchFromGitHub {
22 owner = "p11-glue";
23 repo = pname;
24 rev = version;
25 hash = "sha256-paLiRYgYshuedgDgW2nEsv4/Loq6qFyQMjfBJwqtHzw=";
26 };
27
28 outputs = [ "out" "bin" "dev" ];
29
30 strictDeps = true;
31
32 nativeBuildInputs = [
33 meson
34 ninja
35 pkg-config
36 libtasn1 # asn1Parser
37 libxslt # xsltproc
38 docbook-xsl-nons
39 docbook_xml_dtd_43
40 gettext
41 ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
42 mesonEmulatorHook
43 ];
44
45 buildInputs = [
46 libffi
47 libtasn1
48 libintl
49 ];
50
51 mesonFlags = [
52 "--sysconfdir=/etc"
53 (lib.mesonBool "man" true)
54 (lib.mesonEnable "systemd" false)
55 (lib.mesonOption "bashcompdir" "${placeholder "bin"}/share/bash-completion/completions")
56 (lib.mesonOption "trust_paths" (lib.concatStringsSep ":" [
57 "/etc/ssl/trust-source" # p11-kit trust source
58 "/etc/ssl/certs/ca-certificates.crt" # NixOS + Debian/Ubuntu/Arch/Gentoo...
59 "/etc/pki/tls/certs/ca-bundle.crt" # Fedora/CentOS
60 "/var/lib/ca-certificates/ca-bundle.pem" # openSUSE
61 "/etc/ssl/cert.pem" # Darwin/macOS
62 ]))
63 ];
64
65 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
66
67 postPatch = ''
68 # Install sample config files to $out/etc even though they will be loaded from /etc.
69 substituteInPlace p11-kit/meson.build \
70 --replace 'install_dir: prefix / p11_system_config' "install_dir: '$out/etc/pkcs11'"
71 '';
72
73 meta = with lib; {
74 description = "Library for loading and sharing PKCS#11 modules";
75 longDescription = ''
76 Provides a way to load and enumerate PKCS#11 modules.
77 Provides a standard configuration setup for installing
78 PKCS#11 modules in such a way that they're discoverable.
79 '';
80 homepage = "https://p11-glue.github.io/p11-glue/p11-kit.html";
81 changelog = [
82 "https://github.com/p11-glue/p11-kit/raw/${version}/NEWS"
83 "https://github.com/p11-glue/p11-kit/releases/tag/${version}"
84 ];
85 platforms = platforms.all;
86 license = licenses.bsd3;
87 };
88}