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";
|
2023-02-16 17:41:37 +00:00
|
|
|
version = "unstable-2023-01-29"; # Musl fix hasn't been released yet.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "PJK";
|
2023-02-16 17:41:37 +00:00
|
|
|
repo = "libcbor";
|
|
|
|
rev = "cb4162f40d94751141b4d43b07c4add83e738a68";
|
|
|
|
sha256 = "sha256-ZTa+wG1g9KsVoqJG/yqxo2fJ7OhPnaI9QcfOmpOT3pg=";
|
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
|
|
|
|
];
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
cmakeFlags = lib.optional finalAttrs.doCheck "-DWITH_TESTS=ON"
|
|
|
|
++ 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
|
|
|
})
|