emacsPackages.lsp-bridge: 0-unstable-2025-01-11 -> 0-unstable-2025-01-22 (#376531)
[NixPkgs.git] / pkgs / development / libraries / botan / default.nix
blob3de632e7b2be2f3570e565e829881b9f77b03c01
2   lib,
3   stdenv,
4   fetchurl,
5   python3,
6   docutils,
7   bzip2,
8   zlib,
9   jitterentropy,
10   darwin,
11   static ? stdenv.hostPlatform.isStatic, # generates static libraries *only*
14 let
15   common =
16     {
17       version,
18       hash,
19       patches ? [ ],
20     }:
21     stdenv.mkDerivation (finalAttrs: {
22       pname = "botan";
23       inherit version;
25       __structuredAttrs = true;
26       enableParallelBuilding = true;
27       strictDeps = true;
29       outputs = [
30         "bin"
31         "out"
32         "dev"
33         "doc"
34         "man"
35       ];
37       src = fetchurl {
38         url = "http://botan.randombit.net/releases/Botan-${finalAttrs.version}.tar.xz";
39         inherit hash;
40       };
42       inherit patches;
44       nativeBuildInputs = [
45         python3
46         docutils
47       ];
49       buildInputs =
50         [
51           bzip2
52           zlib
53         ]
54         ++ lib.optionals stdenv.hostPlatform.isDarwin (
55           with darwin.apple_sdk.frameworks;
56           [
57             CoreServices
58             Security
59           ]
60         )
61         ++ lib.optionals (lib.versionAtLeast version "3.6.0") [
62           jitterentropy
63         ];
65       buildTargets =
66         [ "cli" ]
67         ++ lib.optionals finalAttrs.doCheck [ "tests" ]
68         ++ lib.optionals static [ "static" ]
69         ++ lib.optionals (!static) [ "shared" ];
71       botanConfigureFlags =
72         [
73           "--prefix=${placeholder "out"}"
74           "--bindir=${placeholder "bin"}/bin"
75           "--docdir=${placeholder "doc"}/share/doc"
76           "--mandir=${placeholder "man"}/share/man"
77           "--no-install-python-module"
78           "--build-targets=${lib.concatStringsSep "," finalAttrs.buildTargets}"
79           "--with-bzip2"
80           "--with-zlib"
81           "--with-rst2man"
82           "--cpu=${stdenv.hostPlatform.parsed.cpu.name}"
83         ]
84         ++ lib.optionals stdenv.cc.isClang [
85           "--cc=clang"
86         ]
87         ++ lib.optionals (lib.versionAtLeast version "3.6.0") [
88           "--enable-modules=jitter_rng"
89         ];
91       configurePhase = ''
92         runHook preConfigure
93         python configure.py ''${botanConfigureFlags[@]}
94         runHook postConfigure
95       '';
97       preInstall = ''
98         if [ -d src/scripts ]; then
99           patchShebangs src/scripts
100         fi
101       '';
103       postInstall = ''
104         cd "$out"/lib/pkgconfig
105         ln -s botan-*.pc botan.pc || true
106       '';
108       doCheck = true;
110       meta = with lib; {
111         description = "Cryptographic algorithms library";
112         homepage = "https://botan.randombit.net";
113         mainProgram = "botan";
114         maintainers = with maintainers; [
115           raskin
116           thillux
117         ];
118         platforms = platforms.unix;
119         license = licenses.bsd2;
120       };
121     });
124   botan3 = common {
125     version = "3.6.1";
126     hash = "sha256-fLhXXYjSMsdxdHadf54ku0REQWBYWYbuvWbnScuakIk=";
127   };
129   botan2 = common {
130     version = "2.19.5";
131     hash = "sha256-3+6g4KbybWckxK8B2pp7iEh62y2Bunxy/K9S21IsmtQ=";
132   };