Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, openssl
6, libusb1
7, libedit
8, curl
9, gengetopt
10, pkg-config
11, pcsclite
12, help2man
13, darwin
14, libiconv
15}:
16
17stdenv.mkDerivation rec {
18 pname = "yubihsm-shell";
19 version = "2.4.0";
20
21 src = fetchFromGitHub {
22 owner = "Yubico";
23 repo = "yubihsm-shell";
24 rev = version;
25 hash = "sha256-zWhvECPdZnrbSAVPDVZk54SWHVkd/HEQxS3FgXoqXHY=";
26 };
27
28 postPatch = ''
29 # Can't find libyubihsm at runtime because of dlopen() in C code
30 substituteInPlace lib/yubihsm.c \
31 --replace "libyubihsm_usb.so" "$out/lib/libyubihsm_usb.so" \
32 --replace "libyubihsm_http.so" "$out/lib/libyubihsm_http.so"
33 # ld: unknown option: -z
34 substituteInPlace CMakeLists.txt cmake/SecurityFlags.cmake \
35 --replace "AppleClang" "Clang"
36 '';
37
38 nativeBuildInputs = [
39 pkg-config
40 cmake
41 help2man
42 gengetopt
43 ];
44
45 buildInputs = [
46 libusb1
47 libedit
48 curl
49 openssl
50 ] ++ lib.optionals stdenv.isLinux [
51 pcsclite
52 ] ++ lib.optionals stdenv.isDarwin [
53 darwin.apple_sdk.frameworks.PCSC
54 libiconv
55 ];
56
57 cmakeFlags = lib.optionals stdenv.isDarwin [
58 "-DDISABLE_LTO=ON"
59 ];
60
61 meta = with lib; {
62 description = "yubihsm-shell and libyubihsm";
63 homepage = "https://github.com/Yubico/yubihsm-shell";
64 maintainers = with maintainers; [ matthewcroughan ];
65 license = licenses.asl20;
66 };
67}