nixpkgs/pkgs/development/ada-modules/gnatcoll/bindings.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

89 lines
1.9 KiB
Nix

{ stdenv
, lib
, fetchFromGitHub
, gnat
, gprbuild
, gnatcoll-core
, component
# component dependencies
, gmp
, libiconv
, xz
, readline
, zlib
, python3
, ncurses
, darwin
}:
let
# omit python (2.7), no need to introduce a
# dependency on an EOL package for no reason
libsFor = {
iconv = [ libiconv ];
gmp = [ gmp ];
lzma = [ xz ];
readline = [ readline ];
python3 = [ python3 ncurses ];
syslog = [ ];
zlib = [ zlib ];
};
in
stdenv.mkDerivation rec {
pname = "gnatcoll-${component}";
version = "24.0.0";
src = fetchFromGitHub {
owner = "AdaCore";
repo = "gnatcoll-bindings";
rev = "v${version}";
sha256 = "00aakpmr67r72l1h3jpkaw83p1a2mjjvfk635yy5c1nss3ji1qjm";
};
nativeBuildInputs = [
gprbuild
gnat
python3
];
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.CoreFoundation
];
# propagate since gprbuild needs to find referenced .gpr files
# and all dependency C libraries when statically linking a
# downstream executable.
propagatedBuildInputs = [
gnatcoll-core
] ++ libsFor."${component}" or [];
# explicit flag for GPL acceptance because upstreams
# allows a gcc runtime exception for all bindings
# except for readline (since it is GPL w/o exceptions)
buildFlags = lib.optionals (component == "readline") [
"--accept-gpl"
];
buildPhase = ''
runHook preBuild
${python3.interpreter} ${component}/setup.py build --prefix $out $buildFlags
runHook postBuild
'';
installPhase = ''
runHook preInstall
${python3.interpreter} ${component}/setup.py install --prefix $out
runHook postInstall
'';
meta = with lib; {
description = "GNAT Components Collection - Bindings to C libraries";
homepage = "https://github.com/AdaCore/gnatcoll-bindings";
license = licenses.gpl3Plus;
platforms = platforms.all;
maintainers = [ maintainers.sternenseemann ];
};
}