1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 03:30:45 +00:00

botan: refactor

Improve overridability and make it more idiomatic.
This commit is contained in:
nikstur 2024-09-04 14:20:24 +02:00
parent bb204cf8b8
commit 981d819d46
5 changed files with 118 additions and 106 deletions

View file

@ -1,7 +0,0 @@
{ callPackage, ... } @ args:
callPackage ./generic.nix (args // {
baseVersion = "2.19";
revision = "5";
hash = "sha256-3+6g4KbybWckxK8B2pp7iEh62y2Bunxy/K9S21IsmtQ=";
})

View file

@ -1,9 +0,0 @@
{ callPackage, stdenv, lib, ... } @ args:
callPackage ./generic.nix (args // {
baseVersion = "3.5";
revision = "0";
hash = "sha256-Z+ja4cokaNkN5OYByH1fMf9JKzjoq4vL0C3fcQTtip8=";
# this patch fixes build errors on MacOS with SDK 10.12, recheck to remove this again
extraPatches = lib.optionals stdenv.hostPlatform.isDarwin [ ./botan3-macos.patch ];
})

View file

@ -0,0 +1,114 @@
{
lib,
stdenv,
fetchurl,
python3,
bzip2,
zlib,
darwin,
static ? stdenv.hostPlatform.isStatic, # generates static libraries *only*
}:
let
common =
{
version,
hash,
patches ? [ ],
}:
stdenv.mkDerivation (finalAttrs: {
pname = "botan";
inherit version;
__structuredAttrs = true;
enableParallelBuilding = true;
strictDeps = true;
outputs = [
"out"
"dev"
];
src = fetchurl {
url = "http://botan.randombit.net/releases/Botan-${finalAttrs.version}.tar.xz";
inherit hash;
};
inherit patches;
nativeBuildInputs = [ python3 ];
buildInputs =
[
bzip2
zlib
]
++ lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
CoreServices
Security
]
);
botanConfigureFlags =
[
"--prefix=${placeholder "out"}"
"--with-bzip2"
"--with-zlib"
]
++ lib.optionals stdenv.cc.isClang [
"--cc=clang"
]
++ lib.optionals stdenv.hostPlatform.isAarch64 [
"--cpu=aarch64"
]
++ lib.optionals static [
"--enable-static-library"
"--disable-shared-library"
];
configurePhase = ''
runHook preConfigure
python configure.py ''${botanConfigureFlags[@]}
runHook postConfigure
'';
preInstall = ''
if [ -d src/scripts ]; then
patchShebangs src/scripts
fi
'';
postInstall = ''
cd "$out"/lib/pkgconfig
ln -s botan-*.pc botan.pc || true
'';
doCheck = true;
meta = with lib; {
description = "Cryptographic algorithms library";
homepage = "https://botan.randombit.net";
mainProgram = "botan";
maintainers = with maintainers; [
raskin
thillux
];
platforms = platforms.unix;
license = licenses.bsd2;
};
});
in
{
botan3 = common {
version = "3.5.0";
hash = "sha256-Z+ja4cokaNkN5OYByH1fMf9JKzjoq4vL0C3fcQTtip8=";
# this patch fixes build errors on MacOS with SDK 10.12, recheck to remove this again
patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./botan3-macos.patch ];
};
botan2 = common {
version = "2.19.5";
hash = "sha256-3+6g4KbybWckxK8B2pp7iEh62y2Bunxy/K9S21IsmtQ=";
};
}

View file

@ -1,83 +0,0 @@
{ lib, stdenv, fetchurl, python3, bzip2, zlib
# Passed by version specific builders
, baseVersion, revision, hash
, sourceExtension ? "tar.xz"
, extraConfigureFlags ? ""
, extraPatches ? [ ]
, badPlatforms ? [ ]
, postPatch ? null
, knownVulnerabilities ? [ ]
, CoreServices ? null
, Security ? null
, static ? stdenv.hostPlatform.isStatic # generates static libraries *only*
, ...
}:
stdenv.mkDerivation (finalAttrs: {
pname = "botan";
version = "${baseVersion}.${revision}";
__structuredAttrs = true;
outputs = [ "out" "dev" ];
src = fetchurl {
name = "Botan-${finalAttrs.version}.${sourceExtension}";
urls = [
"http://files.randombit.net/botan/v${baseVersion}/Botan-${finalAttrs.version}.${sourceExtension}"
"http://botan.randombit.net/releases/Botan-${finalAttrs.version}.${sourceExtension}"
];
inherit hash;
};
patches = extraPatches;
inherit postPatch;
nativeBuildInputs = [ python3 ];
buildInputs = [ bzip2 zlib ]
++ lib.optionals stdenv.isDarwin [ CoreServices Security ];
botanConfigureFlags = [
"--prefix=${placeholder "out"}"
"--with-bzip2"
"--with-zlib"
] ++ lib.optionals stdenv.cc.isClang [
"--cc=clang"
] ++ lib.optionals stdenv.hostPlatform.isAarch64 [
"--cpu=aarch64"
] ++ lib.optionals static [
"--enable-static-library"
"--disable-shared-library"
];
configurePhase = ''
runHook preConfigure
python configure.py ''${botanConfigureFlags[@]} ${extraConfigureFlags}
runHook postConfigure
'';
enableParallelBuilding = true;
preInstall = ''
if [ -d src/scripts ]; then
patchShebangs src/scripts
fi
'';
postInstall = ''
cd "$out"/lib/pkgconfig
ln -s botan-*.pc botan.pc || true
'';
doCheck = true;
meta = with lib; {
description = "Cryptographic algorithms library";
mainProgram = "botan";
maintainers = with maintainers; [ raskin thillux ];
platforms = platforms.unix;
license = licenses.bsd2;
inherit badPlatforms;
inherit knownVulnerabilities;
};
passthru.updateInfo.downloadPage = "http://files.randombit.net/botan/";
})

View file

@ -19489,13 +19489,10 @@ with pkgs;
bosh-cli = callPackage ../applications/networking/cluster/bosh-cli { }; bosh-cli = callPackage ../applications/networking/cluster/bosh-cli { };
botan2 = callPackage ../development/libraries/botan/2.0.nix { inherit (callPackages ../development/libraries/botan { })
inherit (darwin.apple_sdk.frameworks) CoreServices Security; botan2
}; botan3
;
botan3 = callPackage ../development/libraries/botan/3.0.nix {
inherit (darwin.apple_sdk.frameworks) CoreServices Security;
};
box2d = callPackage ../development/libraries/box2d { box2d = callPackage ../development/libraries/box2d {
inherit (darwin.apple_sdk.frameworks) Carbon Cocoa Kernel OpenGL; inherit (darwin.apple_sdk.frameworks) Carbon Cocoa Kernel OpenGL;