2023-02-02 18:25:31 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2023-11-16 04:20:00 +00:00
|
|
|
, fetchpatch
|
2023-02-02 18:25:31 +00:00
|
|
|
, cmake
|
|
|
|
, cmocka
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
# for passthru.tests
|
|
|
|
, libfido2
|
|
|
|
, mysql80
|
|
|
|
, openssh
|
|
|
|
, systemd
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "libcbor";
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "0.10.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "PJK";
|
2023-02-16 17:41:37 +00:00
|
|
|
repo = "libcbor";
|
2024-02-29 20:09:43 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
|
|
|
hash = "sha256-eE11hYPsOKqfoX8fx/oYfOAichhUe4mMpNQNVZ6vAUI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Pull fix pending upstream inclusion to support
|
|
|
|
# `CMAKE_INSTALL_INCLUDEDIR`:
|
|
|
|
# https://github.com/PJK/libcbor/pull/297
|
|
|
|
(fetchpatch {
|
|
|
|
name = "includedir.patch";
|
|
|
|
url = "https://github.com/PJK/libcbor/commit/d00a63e6d6858a2ed6be9b431b42799ed2c99ad8.patch";
|
|
|
|
hash = "sha256-kBCSbAHOCGOs/4Yu6Vh0jcmzA/jYPkkPXPGPrptRfyk=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
strictDeps = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
buildInputs = [
|
|
|
|
cmocka # cmake expects cmocka module
|
|
|
|
];
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
cmakeFlags = lib.optional finalAttrs.finalPackage.doCheck "-DWITH_TESTS=ON"
|
2023-02-16 17:41:37 +00:00
|
|
|
++ lib.optional (!stdenv.hostPlatform.isStatic) "-DBUILD_SHARED_LIBS=ON";
|
2023-02-02 18:25:31 +00:00
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
# Tests are restricted while pkgsStatic.cmocka is broken. Tracked at:
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/213623
|
|
|
|
doCheck = !stdenv.hostPlatform.isStatic
|
2023-02-02 18:25:31 +00:00
|
|
|
&& stdenv.hostPlatform == stdenv.buildPlatform;
|
2023-02-16 17:41:37 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ cmocka ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit libfido2 mysql80;
|
|
|
|
openssh = (openssh.override { withFIDO = true; });
|
|
|
|
systemd = (systemd.override {
|
|
|
|
withFido2 = true;
|
|
|
|
withCryptsetup = true;
|
|
|
|
});
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "CBOR protocol implementation for C and others";
|
|
|
|
homepage = "https://github.com/PJK/libcbor";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ dtzWill ];
|
|
|
|
};
|
2023-02-02 18:25:31 +00:00
|
|
|
})
|