gmic: cosmetic changes

- reorder input set
- include cimg to passthru.tests
- use rec-less, finalAttrs-style attributes
- remove nested `with` from meta attributes
This commit is contained in:
Anderson Torres 2023-05-02 22:11:57 -03:00
parent 1a898558c8
commit 3765b2a1ee

View file

@ -1,30 +1,30 @@
{ stdenv { lib
, lib , stdenv
, fetchFromGitHub , fetchFromGitHub
, fetchurl , fetchurl
, cmake
, ninja
, pkg-config
, opencv
, openexr
, graphicsmagick
, cimg , cimg
, fftw , cmake
, zlib
, libjpeg
, libtiff
, libpng
, writeShellScript
, common-updater-scripts , common-updater-scripts
, coreutils
, curl , curl
, fftw
, gmic-qt
, gnugrep , gnugrep
, gnused , gnused
, coreutils , graphicsmagick
, jq , jq
, gmic-qt , libjpeg
, libpng
, libtiff
, ninja
, opencv
, openexr
, pkg-config
, writeShellScript
, zlib
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "gmic"; pname = "gmic";
version = "3.2.4"; version = "3.2.4";
@ -33,15 +33,15 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "GreycLab"; owner = "GreycLab";
repo = "gmic"; repo = "gmic";
rev = "v.${version}"; rev = "v.${finalAttrs.version}";
hash = "sha256-ITKsPhfDfkHmE7a04cxrpIKsSVlrPN944ySu2DCnyEU="; hash = "sha256-ITKsPhfDfkHmE7a04cxrpIKsSVlrPN944ySu2DCnyEU=";
}; };
# TODO: build this from source # TODO: build this from source
# https://github.com/dtschump/gmic/blob/b36b2428db5926af5eea5454f822f369c2d9907e/src/Makefile#L675-L729 # Reference: src/Makefile, directive gmic_stdlib.h
gmic_stdlib = fetchurl { gmic_stdlib = fetchurl {
name = "gmic_stdlib.h"; name = "gmic_stdlib.h";
url = "http://gmic.eu/gmic_stdlib${lib.replaceStrings ["."] [""] version}.h"; url = "http://gmic.eu/gmic_stdlib${lib.replaceStrings ["."] [""] finalAttrs.version}.h";
hash = "sha256-ExMCxFkkctqrdSy5M/TXD5GBRmRA9YEdsYW8nWiTEYY="; hash = "sha256-ExMCxFkkctqrdSy5M/TXD5GBRmRA9YEdsYW8nWiTEYY=";
}; };
@ -54,13 +54,13 @@ stdenv.mkDerivation rec {
buildInputs = [ buildInputs = [
cimg cimg
fftw fftw
zlib graphicsmagick
libjpeg libjpeg
libtiff
libpng libpng
libtiff
opencv opencv
openexr openexr
graphicsmagick zlib
]; ];
cmakeFlags = [ cmakeFlags = [
@ -71,47 +71,51 @@ stdenv.mkDerivation rec {
]; ];
postPatch = '' postPatch = ''
# TODO: build from source cp -r ${finalAttrs.gmic_stdlib} src/gmic_stdlib.h
cp -r ${gmic_stdlib} src/gmic_stdlib.h
# CMake build files were moved to subdirectory. # CMake build files were moved to subdirectory.
mv resources/CMakeLists.txt resources/cmake . mv resources/CMakeLists.txt resources/cmake .
'' + lib.optionalString stdenv.isDarwin '' ''
+ lib.optionalString stdenv.isDarwin ''
substituteInPlace CMakeLists.txt \ substituteInPlace CMakeLists.txt \
--replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH" --replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH"
''; '';
passthru = { passthru = {
tests = { tests = {
# Needs to update in lockstep. # Needs to update them all in lockstep.
inherit gmic-qt; inherit cimg gmic-qt;
}; };
updateScript = writeShellScript "${pname}-update-script" '' updateScript = writeShellScript "gmic-update-script" ''
set -o errexit set -o errexit
PATH=${lib.makeBinPath [ common-updater-scripts curl gnugrep gnused coreutils jq ]} 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) 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 [[ "${version}" = "$latestVersion" ]]; then if [[ "${finalAttrs.version}" = "$latestVersion" ]]; then
echo "The new version same as the old version." echo "The new version same as the old version."
exit 0 exit 0
fi fi
for component in src gmic_stdlib; do for component in src gmic_stdlib; do
# The script will not perform an update when the version attribute is up to date from previous platform run # The script will not perform an update when the version attribute is
# We need to clear it before each run # up to date from previous platform run; we need to clear it before
# each run
update-source-version "--source-key=$component" "gmic" 0 "${lib.fakeHash}" update-source-version "--source-key=$component" "gmic" 0 "${lib.fakeHash}"
update-source-version "--source-key=$component" "gmic" $latestVersion update-source-version "--source-key=$component" "gmic" $latestVersion
done done
''; '';
}; };
meta = with lib; { meta = {
description = "Open and full-featured framework for image processing";
homepage = "https://gmic.eu/"; homepage = "https://gmic.eu/";
license = licenses.cecill21; description = "Open and full-featured framework for image processing";
maintainers = [ maintainers.lilyinstarlight ]; license = lib.licenses.cecill21;
platforms = platforms.unix; maintainers = [ lib.maintainers.lilyinstarlight ];
platforms = lib.platforms.unix;
}; };
} })