nixpkgs/pkgs/development/libraries/botan/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

131 lines
2.9 KiB
Nix

{
lib,
stdenv,
fetchurl,
python3,
docutils,
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 = [
"bin"
"out"
"dev"
"doc"
"man"
];
src = fetchurl {
url = "http://botan.randombit.net/releases/Botan-${finalAttrs.version}.tar.xz";
inherit hash;
};
inherit patches;
nativeBuildInputs = [
python3
docutils
];
buildInputs =
[
bzip2
zlib
]
++ lib.optionals stdenv.hostPlatform.isDarwin (
with darwin.apple_sdk.frameworks;
[
CoreServices
Security
]
);
buildTargets =
[ "cli" ]
++ lib.optionals finalAttrs.doCheck [ "tests" ]
++ lib.optionals static [ "static" ]
++ lib.optionals (!static) [ "shared" ];
botanConfigureFlags =
[
"--prefix=${placeholder "out"}"
"--bindir=${placeholder "bin"}/bin"
"--docdir=${placeholder "doc"}/share/doc"
"--mandir=${placeholder "man"}/share/man"
"--no-install-python-module"
"--build-targets=${lib.concatStringsSep "," finalAttrs.buildTargets}"
"--with-bzip2"
"--with-zlib"
"--with-rst2man"
]
++ lib.optionals stdenv.cc.isClang [
"--cc=clang"
]
++ lib.optionals stdenv.hostPlatform.isAarch64 [
"--cpu=aarch64"
];
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=";
};
}