nixpkgs/pkgs/by-name/ca/castxml/package.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

69 lines
1.5 KiB
Nix

{
lib,
cmake,
fetchFromGitHub,
libffi,
libxml2,
llvmPackages,
python3,
stdenv,
testers,
zlib,
# Boolean flags
withHTML ? true,
withManual ? true,
}:
let
inherit (llvmPackages) libclang llvm;
inherit (python3.pkgs) sphinx;
in
stdenv.mkDerivation (finalAttrs: {
pname = "castxml";
version = "0.6.8";
src = fetchFromGitHub {
owner = "CastXML";
repo = "CastXML";
rev = "v${finalAttrs.version}";
hash = "sha256-J4Z/NjCVOq4QS7ncCi87P5YPgqRwFyDAc14uS5T7s6M=";
};
nativeBuildInputs = [ cmake ] ++ lib.optionals (withManual || withHTML) [ sphinx ];
buildInputs = [
libffi
libxml2
llvm
zlib
] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ libclang ];
cmakeFlags =
[
(lib.cmakeOptionType "path" "CLANG_RESOURCE_DIR"
"${lib.getLib libclang}/lib/clang/${lib.versions.major libclang.version}"
)
(lib.cmakeBool "SPHINX_HTML" withHTML)
(lib.cmakeBool "SPHINX_MAN" withManual)
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
(lib.cmakeOptionType "path" "Clang_DIR" "${lib.getDev libclang}/lib/cmake/clang")
];
doCheck = true;
strictDeps = true;
passthru.tests = testers.testVersion { package = finalAttrs.finalPackage; };
meta = {
homepage = "https://github.com/CastXML/CastXML";
description = "C-family Abstract Syntax Tree XML Output";
license = lib.licenses.asl20;
mainProgram = "castxml";
maintainers = [ ];
platforms = lib.platforms.unix;
};
})