nixpkgs/pkgs/by-name/gm/gmic/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

118 lines
2.6 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, fetchurl
, cimg
, cmake
, common-updater-scripts
, coreutils
, curl
, fftw
, gmic-qt
, gnugrep
, gnused
, graphicsmagick
, jq
, libjpeg
, libpng
, libtiff
, ninja
, opencv
, openexr
, pkg-config
, writeShellScript
, zlib
}:
stdenv.mkDerivation (finalAttrs: {
pname = "gmic";
version = "3.4.2";
outputs = [ "out" "lib" "dev" "man" ];
src = fetchFromGitHub {
owner = "GreycLab";
repo = "gmic";
rev = "v.${finalAttrs.version}";
hash = "sha256-oyhwdX/eWbb5i7j/Aw7ocJk3KrGdxfKJx+P4Hzemlw8=";
};
# TODO: build this from source
# Reference: src/Makefile, directive gmic_stdlib_community.h
gmic_stdlib = fetchurl {
name = "gmic_stdlib_community.h";
url = "https://gmic.eu/gmic_stdlib_community${lib.replaceStrings ["."] [""] finalAttrs.version}.h";
hash = "sha256-quzQ0g6kmbJFygUOlKdTn9Fe9J7jhlLOiNal1kX3iHY=";
};
nativeBuildInputs = [
cmake
ninja
pkg-config
];
buildInputs = [
cimg
fftw
graphicsmagick
libjpeg
libpng
libtiff
opencv
openexr
zlib
];
cmakeFlags = [
(lib.cmakeBool "BUILD_LIB_STATIC" false)
(lib.cmakeBool "ENABLE_CURL" false)
(lib.cmakeBool "ENABLE_DYNAMIC_LINKING" true)
(lib.cmakeBool "USE_SYSTEM_CIMG" true)
];
postPatch = ''
cp -r ${finalAttrs.gmic_stdlib} src/gmic_stdlib_community.h
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace CMakeLists.txt \
--replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH"
'';
passthru = {
tests = {
# Needs to update them all in lockstep.
inherit cimg gmic-qt;
};
updateScript = writeShellScript "gmic-update-script" ''
set -o errexit
PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep gnused jq ]}
latestVersion=$(curl 'https://gmic.eu/files/source/' \
| grep -E 'gmic_[^"]+\.tar\.gz' \
| sed -E 's/.+<a href="gmic_([^"]+)\.tar\.gz".+/\1/g' \
| sort --numeric-sort --reverse | head -n1)
if [[ "${finalAttrs.version}" = "$latestVersion" ]]; then
echo "The new version same as the old version."
exit 0
fi
for component in src gmic_stdlib; do
update-source-version "--source-key=$component" "gmic" $latestVersion --ignore-same-version
done
'';
};
meta = {
homepage = "https://gmic.eu/";
description = "Open and full-featured framework for image processing";
mainProgram = "gmic";
license = lib.licenses.cecill21;
maintainers = [
lib.maintainers.AndersonTorres
];
platforms = lib.platforms.unix;
};
})