btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / li / libdigidocpp / package.nix
blob81a129587dd706af4893a36a68d46746398364ff
1 { lib
2 , stdenv
3 , fetchurl
4 , cmake
5 , libtool
6 , libxml2
7 , minizip
8 , pcsclite
9 , opensc
10 , openssl
11 , xercesc
12 , pkg-config
13 , xsd
14 , zlib
15 , xmlsec
16 , xxd
19 stdenv.mkDerivation rec {
20   version = "4.0.0";
21   pname = "libdigidocpp";
23   src = fetchurl {
24     url = "https://github.com/open-eid/libdigidocpp/releases/download/v${version}/libdigidocpp-${version}.tar.gz";
25     hash = "sha256-0G7cjJEgLJ24SwHRznKJ18cRY0m50lr6HXstfbYq9f8=";
26   };
28   nativeBuildInputs = [ cmake pkg-config xxd ];
30   buildInputs = [
31     libxml2
32     minizip
33     pcsclite
34     opensc
35     openssl
36     xercesc
37     xsd
38     zlib
39     xmlsec
40   ];
42   outputs = [ "out" "lib" "dev" "bin" ];
44   # This wants to link to ${CMAKE_DL_LIBS} (ltdl), and there doesn't seem to be
45   # a way to tell CMake where this should be pulled from.
46   # A cleaner fix would probably be to patch cmake to use
47   # `-L${libtool.lib}/lib -ltdl` for `CMAKE_DL_LIBS`, but that's a world rebuild.
48   env.NIX_LDFLAGS = "-L${libtool.lib}/lib";
50   # libdigidocpp.so's `PKCS11Signer::PKCS11Signer()` dlopen()s "opensc-pkcs11.so"
51   # itself, so add OpenSC to its DT_RUNPATH after the fixupPhase shrinked it.
52   # https://github.com/open-eid/cmake/pull/35 might be an alternative.
53   postFixup = ''
54     patchelf --add-rpath ${opensc}/lib/pkcs11 $lib/lib/libdigidocpp.so
55   '';
57   meta = with lib; {
58     description = "Library for creating DigiDoc signature files";
59     mainProgram = "digidoc-tool";
60     homepage = "https://www.id.ee/";
61     license = licenses.lgpl21Plus;
62     platforms = platforms.linux;
63     maintainers = [ maintainers.jagajaga ];
64   };