1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, cmocka
6
7# for passthru.tests
8, libfido2
9, mysql80
10, openssh
11, systemd
12}:
13
14stdenv.mkDerivation (finalAttrs: {
15 pname = "libcbor";
16 version = "unstable-2023-01-29"; # Musl fix hasn't been released yet.
17
18 src = fetchFromGitHub {
19 owner = "PJK";
20 repo = "libcbor";
21 rev = "cb4162f40d94751141b4d43b07c4add83e738a68";
22 sha256 = "sha256-ZTa+wG1g9KsVoqJG/yqxo2fJ7OhPnaI9QcfOmpOT3pg=";
23 };
24
25 strictDeps = true;
26 nativeBuildInputs = [ cmake ];
27
28 buildInputs = [
29 cmocka # cmake expects cmocka module
30 ];
31
32 cmakeFlags = lib.optional finalAttrs.doCheck "-DWITH_TESTS=ON"
33 ++ lib.optional (!stdenv.hostPlatform.isStatic) "-DBUILD_SHARED_LIBS=ON";
34
35 # Tests are restricted while pkgsStatic.cmocka is broken. Tracked at:
36 # https://github.com/NixOS/nixpkgs/issues/213623
37 doCheck = !stdenv.hostPlatform.isStatic
38 && stdenv.hostPlatform == stdenv.buildPlatform;
39
40 nativeCheckInputs = [ cmocka ];
41
42 passthru.tests = {
43 inherit libfido2 mysql80;
44 openssh = (openssh.override { withFIDO = true; });
45 systemd = (systemd.override {
46 withFido2 = true;
47 withCryptsetup = true;
48 });
49 };
50
51 meta = with lib; {
52 description = "CBOR protocol implementation for C and others";
53 homepage = "https://github.com/PJK/libcbor";
54 license = licenses.mit;
55 maintainers = with maintainers; [ dtzWill ];
56 };
57})