Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 383 lines 11 kB view raw
1# Use `gimp-with-plugins` package for GIMP with all plug-ins. 2# If you just want a subset of plug-ins, you can specify them explicitly: 3# `gimp-with-plugins.override { plugins = with gimpPlugins; [ gap ]; }`. 4 5{ 6 lib, 7 pkgs, 8 gimp, 9}: 10 11let 12 inherit (pkgs) 13 stdenv 14 fetchurl 15 fetchpatch 16 fetchpatch2 17 pkg-config 18 intltool 19 glib 20 fetchFromGitHub 21 fetchFromGitLab 22 ; 23 24 # We cannot use gimp from the arguments directly, or it would be shadowed by the one 25 # from scope when initializing the scope with it, leading to infinite recursion. 26 gimpArg = gimp; 27in 28 29lib.makeScope pkgs.newScope ( 30 self: 31 32 let 33 # Use GIMP from the scope. 34 inherit (self) gimp; 35 36 pluginDerivation = 37 attrs: 38 let 39 name = attrs.name or "${attrs.pname}-${attrs.version}"; 40 pkgConfigMajorVersion = lib.versions.major gimp.version; 41 in 42 stdenv.mkDerivation ( 43 { 44 prePhases = [ "extraLib" ]; 45 extraLib = '' 46 installScripts(){ 47 mkdir -p $out/${gimp.targetScriptDir}/${name}; 48 for p in "$@"; do cp "$p" -r $out/${gimp.targetScriptDir}/${name}; done 49 } 50 installPlugin() { 51 # The base name of the first argument is the plug-in name and the main executable. 52 # GIMP only allows a single plug-in per directory: 53 # https://gitlab.gnome.org/GNOME/gimp/-/commit/efae55a73e98389e38fa0e59ebebcda0abe3ee96 54 pluginDir=$out/${gimp.targetPluginDir}/$(basename "$1") 55 install -Dt "$pluginDir" "$@" 56 } 57 ''; 58 } 59 // attrs 60 // { 61 name = "${gimp.pname}-plugin-${name}"; 62 buildInputs = [ 63 gimp 64 gimp.gtk 65 glib 66 ] 67 ++ (attrs.buildInputs or [ ]); 68 69 nativeBuildInputs = [ 70 pkg-config 71 intltool 72 ] 73 ++ (attrs.nativeBuildInputs or [ ]); 74 75 # Override installation paths. 76 env = { 77 "PKG_CONFIG_GIMP_${pkgConfigMajorVersion}_0_GIMPLIBDIR" = 78 "${placeholder "out"}/${gimp.targetLibDir}"; 79 "PKG_CONFIG_GIMP_${pkgConfigMajorVersion}_0_GIMPDATADIR" = 80 "${placeholder "out"}/${gimp.targetDataDir}"; 81 } 82 // attrs.env or { }; 83 } 84 ); 85 86 scriptDerivation = 87 { src, ... }@attrs: 88 pluginDerivation ( 89 { 90 prePhases = [ "extraLib" ]; 91 dontUnpack = true; 92 installPhase = '' 93 runHook preInstall 94 installScripts ${src} 95 runHook postInstall 96 ''; 97 } 98 // attrs 99 ); 100 in 101 { 102 # Allow overriding GIMP package in the scope. 103 gimp = gimpArg; 104 105 bimp = pluginDerivation rec { 106 /* 107 menu: 108 File/Batch Image Manipulation... 109 */ 110 pname = "bimp"; 111 version = "2.6"; 112 113 src = fetchFromGitHub { 114 owner = "alessandrofrancesconi"; 115 repo = "gimp-plugin-bimp"; 116 rev = "v${version}"; 117 hash = "sha256-IJ3+/9UwxJTRo0hUdzlOndOHwso1wGv7Q4UuhbsFkco="; 118 }; 119 120 patches = [ 121 # Allow overriding installation path 122 # https://github.com/alessandrofrancesconi/gimp-plugin-bimp/pull/311 123 (fetchpatch { 124 url = "https://github.com/alessandrofrancesconi/gimp-plugin-bimp/commit/098edb5f70a151a3f377478fd6e0d08ed56b8ef7.patch"; 125 sha256 = "2Afx9fmdn6ztbsll2f2j7mfffMWYWyr4BuBy9ySV6vM="; 126 }) 127 ]; 128 129 postPatch = '' 130 substituteInPlace Makefile \ 131 --replace-fail "gcc" "${stdenv.cc.targetPrefix}cc" 132 ''; 133 134 nativeBuildInputs = with pkgs; [ which ]; 135 136 # workaround for issue: 137 # https://github.com/alessandrofrancesconi/gimp-plugin-bimp/issues/411 138 env.NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types"; 139 140 installFlags = [ 141 "SYSTEM_INSTALL_DIR=${placeholder "out"}/${gimp.targetPluginDir}/bimp" 142 ]; 143 144 installTargets = [ "install-admin" ]; 145 146 meta = with lib; { 147 broken = gimp.majorVersion != "2.0"; 148 description = "Batch Image Manipulation Plugin for GIMP"; 149 homepage = "https://github.com/alessandrofrancesconi/gimp-plugin-bimp"; 150 license = licenses.gpl2Plus; 151 maintainers = [ ]; 152 }; 153 }; 154 155 farbfeld = pluginDerivation { 156 pname = "farbfeld"; 157 version = "unstable-2019-08-12"; 158 159 src = fetchFromGitHub { 160 owner = "ids1024"; 161 repo = "gimp-farbfeld"; 162 rev = "5feacebf61448bd3c550dda03cd08130fddc5af4"; 163 sha256 = "1vmw7k773vrndmfffj0m503digdjmkpcqy2r3p3i5x0qw9vkkkc6"; 164 }; 165 166 installPhase = '' 167 installPlugin farbfeld 168 ''; 169 170 meta = { 171 broken = gimp.majorVersion != "2.0"; 172 description = "Gimp plug-in for the farbfeld image format"; 173 homepage = "https://github.com/ids1024/gimp-farbfeld"; 174 license = lib.licenses.mit; 175 maintainers = with lib.maintainers; [ sikmir ]; 176 }; 177 }; 178 179 fourier = pluginDerivation rec { 180 /* 181 menu: 182 Filters/Generic/FFT Forward 183 Filters/Generic/FFT Inverse 184 */ 185 pname = "fourier"; 186 version = "0.4.3"; 187 188 src = fetchurl { 189 url = "https://www.lprp.fr/files/old-web/soft/gimp/${pname}-${version}.tar.gz"; 190 sha256 = "0mf7f8vaqs2madx832x3kcxw3hv3w3wampvzvaps1mkf2kvrjbsn"; 191 }; 192 193 buildInputs = with pkgs; [ fftw ]; 194 195 postPatch = '' 196 substituteInPlace Makefile --replace '$(GCC)' '$(CC)' 197 198 # The tarball contains a prebuilt binary. 199 make clean 200 ''; 201 202 installPhase = '' 203 runHook preInstall 204 205 installPlugin fourier 206 207 runHook postInstall 208 ''; 209 210 meta = with lib; { 211 broken = gimp.majorVersion != "2.0"; 212 description = "GIMP plug-in to do the fourier transform"; 213 homepage = "https://people.via.ecp.fr/~remi/soft/gimp/gimp_plugin_en.php3#fourier"; 214 license = with licenses; [ gpl3Plus ]; 215 }; 216 }; 217 218 resynthesizer = pluginDerivation rec { 219 /* 220 menu: 221 Edit/Fill with pattern seamless... 222 Filters/Enhance/Heal selection... 223 Filters/Enhance/Heal transparency... 224 Filters/Enhance/Sharpen by synthesis... 225 Filters/Enhance/Uncrop... 226 Filters/Map/Style... 227 Filters/Render/Texture... 228 */ 229 pname = "resynthesizer"; 230 version = "2.0.3"; 231 buildInputs = with pkgs; [ fftw ]; 232 nativeBuildInputs = with pkgs; [ autoreconfHook ]; 233 makeFlags = [ "GIMP_LIBDIR=${placeholder "out"}/${gimp.targetLibDir}" ]; 234 src = fetchFromGitHub { 235 owner = "bootchk"; 236 repo = "resynthesizer"; 237 rev = "v${version}"; 238 sha256 = "1jwc8bhhm21xhrgw56nzbma6fwg59gc8anlmyns7jdiw83y0zx3j"; 239 }; 240 241 meta = { 242 broken = gimp.majorVersion != "2.0"; 243 }; 244 }; 245 246 texturize = pluginDerivation { 247 pname = "texturize"; 248 version = "2.2+unstable=2021-12-03"; 249 src = fetchFromGitHub { 250 owner = "lmanul"; 251 repo = "gimp-texturize"; 252 rev = "9ceff0d411cda018108e5477320669b8d00d811e"; 253 sha256 = "haYS0K3oAPlHtHB8phOCX5/gtWq9uiVQhG5ZhAFX0t0="; 254 }; 255 nativeBuildInputs = with pkgs; [ 256 meson 257 ninja 258 gettext 259 ]; 260 261 meta = { 262 broken = gimp.majorVersion != "2.0"; 263 }; 264 }; 265 266 waveletSharpen = pluginDerivation { 267 /* 268 menu: 269 Filters/Enhance/Wavelet sharpen 270 */ 271 pname = "wavelet-sharpen"; 272 version = "0.1.2"; 273 274 src = fetchurl { 275 url = "https://github.com/pixlsus/registry.gimp.org_static/raw/master/registry.gimp.org/files/wavelet-sharpen-0.1.2.tar.gz"; 276 sha256 = "0vql1k67i21g5ivaa1jh56rg427m0icrkpryrhg75nscpirfxxqw"; 277 }; 278 279 env = { 280 # Workaround build failure on -fno-common toolchains like upstream 281 # gcc-10. Otherwise build fails as: 282 # ld: interface.o:(.bss+0xe0): multiple definition of `fimg'; plugin.o:(.bss+0x40): first defined here 283 NIX_CFLAGS_COMPILE = "-fcommon"; 284 NIX_LDFLAGS = "-lm"; 285 }; 286 287 installPhase = "installPlugin src/wavelet-sharpen"; # TODO translations are not copied .. How to do this on nix? 288 289 meta = { 290 broken = gimp.majorVersion != "2.0"; 291 }; 292 }; 293 294 lqrPlugin = pluginDerivation rec { 295 /* 296 menu: 297 Layer/Liquid Rescale 298 */ 299 pname = "lqr-plugin"; 300 version = "0.7.2"; 301 buildInputs = with pkgs; [ liblqr1 ]; 302 src = fetchFromGitHub { 303 owner = "carlobaldassi"; 304 repo = "gimp-lqr-plugin"; 305 rev = "v${version}"; 306 sha256 = "81ajdZ2zQi/THxnBlSeT36tVTEzrS1YqLGpHMhFTKAo="; 307 }; 308 patches = [ 309 # Pull upstream fix for -fno-common toolchain support: 310 # https://github.com/carlobaldassi/gimp-lqr-plugin/pull/6 311 (fetchpatch { 312 name = "fno-common.patch"; 313 url = "https://github.com/carlobaldassi/gimp-lqr-plugin/commit/ae3464a82e1395fc577cc94999bdc7c4a7bb35f1.patch"; 314 sha256 = "EdjZWM6U1bhUmsOnLA8iJ4SFKuAXHIfNPzxZqel+JrY="; 315 }) 316 ]; 317 318 meta = { 319 broken = gimp.majorVersion != "2.0"; 320 }; 321 }; 322 323 gmic = pkgs.gmic-qt.override { 324 variant = "gimp"; 325 inherit (self) gimp; 326 }; 327 328 gimplensfun = pluginDerivation { 329 version = "unstable-2018-10-21"; 330 pname = "gimplensfun"; 331 332 src = fetchFromGitHub { 333 owner = "seebk"; 334 repo = "GIMP-Lensfun"; 335 rev = "1c5a5c1534b5faf098b7441f8840d22835592f17"; 336 sha256 = "1jj3n7spkjc63aipwdqsvq9gi07w13bb1v8iqzvxwzld2kxa3c8w"; 337 }; 338 339 buildInputs = ( 340 with pkgs; 341 [ 342 lensfun 343 gexiv2 344 ] 345 ++ lib.optional stdenv.cc.isClang llvmPackages.openmp 346 ); 347 348 installPhase = " 349 installPlugin gimp-lensfun 350 "; 351 352 meta = { 353 broken = gimp.majorVersion != "2.0"; 354 description = "GIMP plugin to correct lens distortion using the lensfun library and database"; 355 356 homepage = "http://lensfun.sebastiankraft.net/"; 357 358 license = lib.licenses.gpl3Plus; 359 maintainers = [ ]; 360 }; 361 }; 362 363 # =============== simple script files ==================== 364 365 # also have a look at enblend-enfuse in all-packages.nix 366 exposureBlend = scriptDerivation { 367 name = "exposure-blend"; 368 src = fetchurl { 369 url = "http://tir.astro.utoledo.edu/jdsmith/code/eb/exposure-blend.scm"; 370 sha256 = "1b6c9wzpklqras4wwsyw3y3jp6fjmhnnskqiwm5sabs8djknfxla"; 371 }; 372 meta.broken = true; 373 }; 374 375 lightning = scriptDerivation { 376 name = "Lightning"; 377 src = fetchurl { 378 url = "https://github.com/pixlsus/registry.gimp.org_static/raw/master/registry.gimp.org/files/Lightning.scm"; 379 sha256 = "c14a8f4f709695ede3f77348728a25b3f3ded420da60f3f8de3944b7eae98a49"; 380 }; 381 }; 382 } 383)