about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/graphics')
-rw-r--r--nixpkgs/pkgs/applications/graphics/ImageMagick/7.0.nix89
-rw-r--r--nixpkgs/pkgs/applications/graphics/ImageMagick/default.nix105
-rw-r--r--nixpkgs/pkgs/applications/graphics/PythonMagick/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/graphics/ahoviewer/default.nix55
-rw-r--r--nixpkgs/pkgs/applications/graphics/alchemy/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/graphics/animbar/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/graphics/antimony/default.nix52
-rw-r--r--nixpkgs/pkgs/applications/graphics/antimony/paths-fix.patch21
-rw-r--r--nixpkgs/pkgs/applications/graphics/apitrace/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/graphics/autopanosiftc/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/graphics/autotrace/autofig.nix10
-rw-r--r--nixpkgs/pkgs/applications/graphics/autotrace/default.nix125
-rw-r--r--nixpkgs/pkgs/applications/graphics/avocode/default.nix102
-rw-r--r--nixpkgs/pkgs/applications/graphics/awesomebump/default.nix62
-rw-r--r--nixpkgs/pkgs/applications/graphics/awesomebump/qtnproperty-parallel-building.patch9
-rw-r--r--nixpkgs/pkgs/applications/graphics/azpainter/default.nix38
-rwxr-xr-xnixpkgs/pkgs/applications/graphics/batik/builder.sh7
-rw-r--r--nixpkgs/pkgs/applications/graphics/batik/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/graphics/c3d/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/graphics/cinepaint/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/graphics/cinepaint/install.patch24
-rw-r--r--nixpkgs/pkgs/applications/graphics/comical/default.nix23
-rw-r--r--nixpkgs/pkgs/applications/graphics/comical/wxgtk-2.8.patch36
-rw-r--r--nixpkgs/pkgs/applications/graphics/darktable/default.nix57
-rw-r--r--nixpkgs/pkgs/applications/graphics/deskew/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/graphics/dia/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/graphics/digikam/default.nix132
-rw-r--r--nixpkgs/pkgs/applications/graphics/displaycal/default.nix59
-rw-r--r--nixpkgs/pkgs/applications/graphics/djview/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/graphics/dosage/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/graphics/draftsight/default.nix88
-rw-r--r--nixpkgs/pkgs/applications/graphics/drawio/default.nix94
-rw-r--r--nixpkgs/pkgs/applications/graphics/drawpile/default.nix96
-rw-r--r--nixpkgs/pkgs/applications/graphics/epeg/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/graphics/exrdisplay/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/graphics/exrtools/default.nix23
-rw-r--r--nixpkgs/pkgs/applications/graphics/fbida/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/graphics/feh/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/graphics/fig2dev/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/graphics/fondo/default.nix72
-rw-r--r--nixpkgs/pkgs/applications/graphics/fontmatrix/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/graphics/freecad/default.nix75
-rw-r--r--nixpkgs/pkgs/applications/graphics/freepv/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/graphics/fstl/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/graphics/gcolor2/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/graphics/gcolor2/gcolor2-amd64.patch46
-rw-r--r--nixpkgs/pkgs/applications/graphics/gcolor3/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/graphics/geeqie/default.nix69
-rw-r--r--nixpkgs/pkgs/applications/graphics/gimp/default.nix86
-rw-r--r--nixpkgs/pkgs/applications/graphics/gimp/plugins/default.nix236
-rw-r--r--nixpkgs/pkgs/applications/graphics/gimp/plugins/patches/focusblur-glib.patch200
-rw-r--r--nixpkgs/pkgs/applications/graphics/gimp/remove-cc-reference.patch13
-rw-r--r--nixpkgs/pkgs/applications/graphics/gimp/wrapper.nix28
-rw-r--r--nixpkgs/pkgs/applications/graphics/glabels/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/graphics/gnome-photos/default.nix125
-rw-r--r--nixpkgs/pkgs/applications/graphics/gnome-photos/installed-tests-path.patch23
-rw-r--r--nixpkgs/pkgs/applications/graphics/gnuclad/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/graphics/gocr/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/graphics/goxel/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/graphics/goxel/disable-imgui_ini.patch13
-rw-r--r--nixpkgs/pkgs/applications/graphics/gpicview/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/graphics/gqview/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/graphics/grafx2/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/graphics/graphicsmagick/1.3.32-darwin-png-strlcat-fix.patch42
-rw-r--r--nixpkgs/pkgs/applications/graphics/graphicsmagick/compat.nix37
-rw-r--r--nixpkgs/pkgs/applications/graphics/graphicsmagick/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/graphics/graphicsmagick/disable-popen.patch12
-rw-r--r--nixpkgs/pkgs/applications/graphics/gscan2pdf/default.nix107
-rw-r--r--nixpkgs/pkgs/applications/graphics/gthumb/default.nix108
-rw-r--r--nixpkgs/pkgs/applications/graphics/guetzli/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/graphics/hugin/default.nix55
-rw-r--r--nixpkgs/pkgs/applications/graphics/ideogram/default.nix70
-rw-r--r--nixpkgs/pkgs/applications/graphics/image_optim/Gemfile2
-rw-r--r--nixpkgs/pkgs/applications/graphics/image_optim/Gemfile.lock23
-rw-r--r--nixpkgs/pkgs/applications/graphics/image_optim/default.nix66
-rw-r--r--nixpkgs/pkgs/applications/graphics/image_optim/gemset.nix51
-rw-r--r--nixpkgs/pkgs/applications/graphics/imagej/default.nix48
-rw-r--r--nixpkgs/pkgs/applications/graphics/imgcat/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/graphics/imlibsetroot/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/graphics/imv/default.nix60
-rw-r--r--nixpkgs/pkgs/applications/graphics/inkscape/default.nix80
-rw-r--r--nixpkgs/pkgs/applications/graphics/ipe/default.nix47
-rw-r--r--nixpkgs/pkgs/applications/graphics/jbrout/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/graphics/jpeg-archive/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/graphics/jpeginfo/default.nix21
-rw-r--r--nixpkgs/pkgs/applications/graphics/jpegoptim/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/graphics/jpegrescan/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/graphics/k3d/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/graphics/kcc/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/graphics/kgraphviewer/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/graphics/kodelife/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/graphics/krita/default.nix52
-rw-r--r--nixpkgs/pkgs/applications/graphics/krop/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/graphics/ktikz/default.nix54
-rw-r--r--nixpkgs/pkgs/applications/graphics/leocad/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/graphics/luminance-hdr/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/graphics/mcomix/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/graphics/meh/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/graphics/meme/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/graphics/meshlab/default.nix69
-rw-r--r--nixpkgs/pkgs/applications/graphics/meshlab/fix-20180627-beta.patch25
-rw-r--r--nixpkgs/pkgs/applications/graphics/minidjvu/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/graphics/mirage/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/graphics/mozjpeg/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/graphics/mtpaint/default.nix41
-rw-r--r--nixpkgs/pkgs/applications/graphics/mypaint/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/graphics/nomacs/default.nix66
-rw-r--r--nixpkgs/pkgs/applications/graphics/nomacs/nomacs-iostream.patch26
-rw-r--r--nixpkgs/pkgs/applications/graphics/ocrad/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/graphics/openimageio/2.x.nix58
-rw-r--r--nixpkgs/pkgs/applications/graphics/openimageio/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/graphics/openscad/default.nix86
-rw-r--r--nixpkgs/pkgs/applications/graphics/panotools/default.nix23
-rw-r--r--nixpkgs/pkgs/applications/graphics/paraview/default.nix71
-rw-r--r--nixpkgs/pkgs/applications/graphics/pbrt/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/graphics/pbrt/openexr-cmake-3.12.patch26
-rw-r--r--nixpkgs/pkgs/applications/graphics/pdfcpu/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/graphics/pencil/default.nix104
-rw-r--r--nixpkgs/pkgs/applications/graphics/photivo/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/graphics/photivo/gcc6.patch13
-rw-r--r--nixpkgs/pkgs/applications/graphics/photoflow/default.nix56
-rw-r--r--nixpkgs/pkgs/applications/graphics/photoqt/default.nix48
-rw-r--r--nixpkgs/pkgs/applications/graphics/phototonic/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/graphics/pinta/default.nix83
-rw-r--r--nixpkgs/pkgs/applications/graphics/potrace/default.nix23
-rw-r--r--nixpkgs/pkgs/applications/graphics/pqiv/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/graphics/processing/default.nix63
-rw-r--r--nixpkgs/pkgs/applications/graphics/qcomicbook/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/graphics/qiv/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/graphics/qiv/default.upstream3
-rw-r--r--nixpkgs/pkgs/applications/graphics/qscreenshot/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/graphics/qview/default.nix22
-rw-r--r--nixpkgs/pkgs/applications/graphics/rapcad/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/graphics/rapid-photo-downloader/default.nix86
-rw-r--r--nixpkgs/pkgs/applications/graphics/rawtherapee/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/graphics/renderdoc/default.nix73
-rw-r--r--nixpkgs/pkgs/applications/graphics/runwayml/default.nix45
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/default.nix94
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/preload.c170
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix55
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/backends/default.nix11
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/backends/dsseries/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/backends/generic.nix77
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/backends/git.nix10
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/config.nix38
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/frontends.nix29
-rw-r--r--nixpkgs/pkgs/applications/graphics/sane/xsane.nix33
-rw-r--r--nixpkgs/pkgs/applications/graphics/scantailor/advanced.nix26
-rw-r--r--nixpkgs/pkgs/applications/graphics/scantailor/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/graphics/screencloud/default.nix77
-rw-r--r--nixpkgs/pkgs/applications/graphics/seg3d/cstdio.patch81
-rw-r--r--nixpkgs/pkgs/applications/graphics/seg3d/default.nix54
-rw-r--r--nixpkgs/pkgs/applications/graphics/shotwell/default.nix108
-rw-r--r--nixpkgs/pkgs/applications/graphics/shutter/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/graphics/smartdeblur/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/graphics/solvespace/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/graphics/swingsane/default.nix61
-rw-r--r--nixpkgs/pkgs/applications/graphics/sxiv/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/graphics/synfigstudio/default.nix127
-rw-r--r--nixpkgs/pkgs/applications/graphics/tesseract/default.nix18
-rwxr-xr-xnixpkgs/pkgs/applications/graphics/tesseract/fetch-language-hashes35
-rw-r--r--nixpkgs/pkgs/applications/graphics/tesseract/languages.nix289
-rw-r--r--nixpkgs/pkgs/applications/graphics/tesseract/tesseract3.nix29
-rw-r--r--nixpkgs/pkgs/applications/graphics/tesseract/tesseract4.nix27
-rw-r--r--nixpkgs/pkgs/applications/graphics/tesseract/wrapper.nix58
-rw-r--r--nixpkgs/pkgs/applications/graphics/timelapse-deflicker/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/graphics/ufraw/default.nix86
-rw-r--r--nixpkgs/pkgs/applications/graphics/unigine-valley/default.nix115
-rw-r--r--nixpkgs/pkgs/applications/graphics/viewnior/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/graphics/vimiv/default.nix73
-rw-r--r--nixpkgs/pkgs/applications/graphics/wings/default.nix45
-rw-r--r--nixpkgs/pkgs/applications/graphics/write_stylus/default.nix65
-rw-r--r--nixpkgs/pkgs/applications/graphics/xaos/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/graphics/xara/debian-patches.nix30
-rw-r--r--nixpkgs/pkgs/applications/graphics/xara/debian-patches.txt7
-rw-r--r--nixpkgs/pkgs/applications/graphics/xara/default.nix22
-rw-r--r--nixpkgs/pkgs/applications/graphics/xfig/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/graphics/xfractint/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/graphics/xournal/default.nix65
-rw-r--r--nixpkgs/pkgs/applications/graphics/xournalpp/default.nix63
-rw-r--r--nixpkgs/pkgs/applications/graphics/xzgv/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/graphics/yacreader/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/graphics/yed/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/graphics/zgrviewer/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/graphics/zgv/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/graphics/zgv/switch.patch14
186 files changed, 9150 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/graphics/ImageMagick/7.0.nix b/nixpkgs/pkgs/applications/graphics/ImageMagick/7.0.nix
new file mode 100644
index 000000000000..654363d36f24
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/ImageMagick/7.0.nix
@@ -0,0 +1,89 @@
+{ lib, stdenv, fetchFromGitHub, pkgconfig, libtool
+, bzip2, zlib, libX11, libXext, libXt, fontconfig, freetype, ghostscript, libjpeg, djvulibre
+, lcms2, openexr, libpng, librsvg, libtiff, libxml2, openjpeg, libwebp, libheif
+, ApplicationServices
+}:
+
+let
+  arch =
+    if stdenv.hostPlatform.system == "i686-linux" then "i686"
+    else if stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" then "x86-64"
+    else if stdenv.hostPlatform.system == "armv7l-linux" then "armv7l"
+    else if stdenv.hostPlatform.system == "aarch64-linux" then "aarch64"
+    else throw "ImageMagick is not supported on this platform.";
+
+  cfg = {
+    version = "7.0.8-58";
+    sha256 = "0yfw32nydwy7ag7ina1zc6yssa146x4v35hjv6v59bci9mmj9fb1";
+    patches = [];
+  };
+in
+
+stdenv.mkDerivation {
+  pname = "imagemagick";
+  inherit (cfg) version;
+
+  src = fetchFromGitHub {
+    owner = "ImageMagick";
+    repo = "ImageMagick";
+    rev = cfg.version;
+    inherit (cfg) sha256;
+  };
+
+  patches = cfg.patches;
+
+  outputs = [ "out" "dev" "doc" ]; # bin/ isn't really big
+  outputMan = "out"; # it's tiny
+
+  enableParallelBuilding = true;
+
+  configureFlags =
+    [ "--with-frozenpaths" ]
+    ++ [ "--with-gcc-arch=${arch}" ]
+    ++ lib.optional (librsvg != null) "--with-rsvg"
+    ++ lib.optionals (ghostscript != null)
+      [ "--with-gs-font-dir=${ghostscript}/share/ghostscript/fonts"
+        "--with-gslib"
+      ]
+    ++ lib.optionals stdenv.hostPlatform.isMinGW
+      [ "--enable-static" "--disable-shared" ] # due to libxml2 being without DLLs ATM
+    ;
+
+  nativeBuildInputs = [ pkgconfig libtool ];
+
+  buildInputs =
+    [ zlib fontconfig freetype ghostscript
+      libpng libtiff libxml2 libheif djvulibre
+    ]
+    ++ lib.optionals (!stdenv.hostPlatform.isMinGW)
+      [ openexr librsvg openjpeg ]
+    ++ lib.optional stdenv.isDarwin ApplicationServices;
+
+  propagatedBuildInputs =
+    [ bzip2 freetype libjpeg lcms2 ]
+    ++ lib.optionals (!stdenv.hostPlatform.isMinGW)
+      [ libX11 libXext libXt libwebp ]
+    ;
+
+  postInstall = ''
+    (cd "$dev/include" && ln -s ImageMagick* ImageMagick)
+    moveToOutput "bin/*-config" "$dev"
+    moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params
+    for file in "$dev"/bin/*-config; do
+      substituteInPlace "$file" --replace pkg-config \
+        "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '${pkgconfig}/bin/pkg-config'"
+    done
+  '' + lib.optionalString (ghostscript != null) ''
+    for la in $out/lib/*.la; do
+      sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.imagemagick.org/;
+    description = "A software suite to create, edit, compose, or convert bitmap images";
+    platforms = platforms.linux ++ platforms.darwin;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ the-kenny ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/ImageMagick/default.nix b/nixpkgs/pkgs/applications/graphics/ImageMagick/default.nix
new file mode 100644
index 000000000000..993d4ba7ecdb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/ImageMagick/default.nix
@@ -0,0 +1,105 @@
+{ lib, stdenv, fetchFromGitHub, fetchpatch, pkgconfig, libtool
+, bzip2, zlib, libX11, libXext, libXt, fontconfig, freetype, ghostscript, libjpeg, djvulibre
+, lcms2, openexr, libpng, librsvg, libtiff, libxml2, openjpeg, libwebp, fftw, libheif, libde265
+, ApplicationServices
+}:
+
+let
+  arch =
+    if stdenv.hostPlatform.system == "i686-linux" then "i686"
+    else if stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" then "x86-64"
+    else if stdenv.hostPlatform.system == "armv7l-linux" then "armv7l"
+    else if stdenv.hostPlatform.system == "aarch64-linux" then "aarch64"
+    else throw "ImageMagick is not supported on this platform.";
+
+  cfg = {
+    version = "6.9.9-34";
+    sha256 = "0sqrgyfi7i7x1akna95c1qhk9sxxswzm3pkssfi4w6v7bn24g25g";
+    patches = [];
+  }
+    # Freeze version on mingw so we don't need to port the patch too often.
+    # FIXME: This version has multiple security vulnerabilities
+    // lib.optionalAttrs (stdenv.hostPlatform.isMinGW) {
+        version = "6.9.2-0";
+        sha256 = "17ir8bw1j7g7srqmsz3rx780sgnc21zfn0kwyj78iazrywldx8h7";
+        patches = [(fetchpatch {
+          name = "mingw-build.patch";
+          url = "https://raw.githubusercontent.com/Alexpux/MINGW-packages/"
+            + "01ca03b2a4ef/mingw-w64-imagemagick/002-build-fixes.patch";
+          sha256 = "1pypszlcx2sf7wfi4p37w1y58ck2r8cd5b2wrrwr9rh87p7fy1c0";
+        })];
+      };
+in
+
+stdenv.mkDerivation {
+  pname = "imagemagick";
+  inherit (cfg) version;
+
+  src = fetchFromGitHub {
+    owner = "ImageMagick";
+    repo = "ImageMagick6";
+    rev = cfg.version;
+    inherit (cfg) sha256;
+  };
+
+  patches = cfg.patches;
+
+  outputs = [ "out" "dev" "doc" ]; # bin/ isn't really big
+  outputMan = "out"; # it's tiny
+
+  enableParallelBuilding = true;
+
+  configureFlags =
+    [ "--with-frozenpaths" ]
+    ++ [ "--with-gcc-arch=${arch}" ]
+    ++ lib.optional (librsvg != null) "--with-rsvg"
+    ++ lib.optionals (ghostscript != null)
+      [ "--with-gs-font-dir=${ghostscript}/share/ghostscript/fonts"
+        "--with-gslib"
+      ]
+    ++ lib.optionals (stdenv.hostPlatform.isMinGW)
+      [ "--enable-static" "--disable-shared" ] # due to libxml2 being without DLLs ATM
+    ;
+
+  nativeBuildInputs = [ pkgconfig libtool ];
+
+  buildInputs =
+    [ zlib fontconfig freetype ghostscript
+      libpng libtiff libxml2 libheif libde265 djvulibre
+    ]
+    ++ lib.optionals (!stdenv.hostPlatform.isMinGW)
+      [ openexr librsvg openjpeg ]
+    ++ lib.optional stdenv.isDarwin ApplicationServices;
+
+  propagatedBuildInputs =
+    [ bzip2 freetype libjpeg lcms2 fftw ]
+    ++ lib.optionals (!stdenv.hostPlatform.isMinGW)
+      [ libX11 libXext libXt libwebp ]
+    ;
+
+  doCheck = false; # fails 6 out of 76 tests
+
+  postInstall = ''
+    (cd "$dev/include" && ln -s ImageMagick* ImageMagick)
+    moveToOutput "bin/*-config" "$dev"
+    moveToOutput "lib/ImageMagick-*/config-Q16" "$dev" # includes configure params
+    for file in "$dev"/bin/*-config; do
+      substituteInPlace "$file" --replace "${pkgconfig}/bin/pkg-config -config" \
+        ${pkgconfig}/bin/pkg-config
+      substituteInPlace "$file" --replace ${pkgconfig}/bin/pkg-config \
+        "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '${pkgconfig}/bin/pkg-config'"
+    done
+  '' + lib.optionalString (ghostscript != null) ''
+    for la in $out/lib/*.la; do
+      sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.imagemagick.org/;
+    description = "A software suite to create, edit, compose, or convert bitmap images";
+    platforms = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ the-kenny ];
+    license = licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/PythonMagick/default.nix b/nixpkgs/pkgs/applications/graphics/PythonMagick/default.nix
new file mode 100644
index 000000000000..e35a0190d8bc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/PythonMagick/default.nix
@@ -0,0 +1,28 @@
+# This expression provides Python bindings to ImageMagick. Python libraries are supposed to be called via `python-packages.nix`.
+
+{ stdenv, fetchurl, python, pkgconfig, imagemagick, autoreconfHook }:
+
+stdenv.mkDerivation rec {
+  pname = "pythonmagick";
+  version = "0.9.16";
+
+  src = fetchurl {
+    url = "mirror://imagemagick/python/releases/PythonMagick-${version}.tar.xz";
+    sha256 = "137278mfb5079lns2mmw73x8dhpzgwha53dyl00mmhj2z25varpn";
+  };
+
+  postPatch = ''
+    rm configure
+  '';
+
+  configureFlags = [ "--with-boost=${python.pkgs.boost}" ];
+
+  nativeBuildInputs = [ pkgconfig autoreconfHook ];
+  buildInputs = [ python python.pkgs.boost imagemagick ];
+
+  meta = with stdenv.lib; {
+    homepage = http://www.imagemagick.org/script/api.php;
+    license = licenses.imagemagick;
+    description = "PythonMagick provides object oriented bindings for the ImageMagick Library.";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/ahoviewer/default.nix b/nixpkgs/pkgs/applications/graphics/ahoviewer/default.nix
new file mode 100644
index 000000000000..fb06266cdc59
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/ahoviewer/default.nix
@@ -0,0 +1,55 @@
+{ config, stdenv, fetchFromGitHub, pkgconfig, libconfig
+, gtkmm2, glibmm, libxml2, libsecret, curl, libzip
+, librsvg, gst_all_1, autoreconfHook, makeWrapper
+, useUnrar ? config.ahoviewer.useUnrar or false, unrar
+}:
+
+assert useUnrar -> unrar != null;
+
+stdenv.mkDerivation rec {
+  pname = "ahoviewer";
+  version = "1.6.5";
+
+  src = fetchFromGitHub {
+    owner = "ahodesuka";
+    repo = "ahoviewer";
+    rev = version;
+    sha256 = "1avdl4qcpznvf3s2id5qi1vnzy4wgh6vxpnrz777a1s4iydxpcd8";
+  };
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig makeWrapper ];
+  buildInputs = [
+    glibmm libconfig gtkmm2 glibmm libxml2
+    libsecret curl libzip librsvg
+    gst_all_1.gstreamer
+    gst_all_1.gst-plugins-good
+    gst_all_1.gst-libav
+    gst_all_1.gst-plugins-base
+  ] ++ stdenv.lib.optional useUnrar unrar;
+
+  NIX_LDFLAGS = [
+    "-lpthread"
+  ];
+
+  postPatch = ''patchShebangs version.sh'';
+
+  postInstall = ''
+    wrapProgram $out/bin/ahoviewer \
+    --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0" \
+    --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/ahodesuka/ahoviewer;
+    description = "A GTK2 image viewer, manga reader, and booru browser";
+    maintainers = with maintainers; [ skrzyp xzfc ];
+    license = licenses.mit;
+    # Unintentionally not working on Darwin:
+    # https://github.com/ahodesuka/ahoviewer/issues/62
+    platforms = platforms.linux;
+  };
+}
+
+
diff --git a/nixpkgs/pkgs/applications/graphics/alchemy/default.nix b/nixpkgs/pkgs/applications/graphics/alchemy/default.nix
new file mode 100644
index 000000000000..5132d5950aab
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/alchemy/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, jre, runtimeShell }:
+
+stdenv.mkDerivation rec {
+  pname = "alchemy";
+  version = "008";
+
+  enableParallelBuilding = true;
+
+  src = fetchurl {
+    url = "http://al.chemy.org/files/Alchemy-${version}.tar.gz";
+    sha256 = "0449bvdccgx1jqnws1bckzs4nv2d230523qs0jx015gi81s1q7li";
+  };
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share
+    cp -a . $out/share/alchemy
+    cat >> $out/bin/alchemy << EOF
+    #!${runtimeShell}
+    cd $out/share/alchemy
+    ${jre}/bin/java -jar Alchemy.jar "$@"
+    EOF
+    chmod +x $out/bin/alchemy
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Drawing application";
+    longDescription = ''
+      Alchemy is an open drawing project aimed at exploring how we can sketch,
+      draw, and create on computers in new ways. Alchemy isn’t software for
+      creating finished artwork, but rather a sketching environment that
+      focuses on the absolute initial stage of the creation process.
+      Experimental in nature, Alchemy lets you brainstorm visually to explore
+      an expanded range of ideas and possibilities in a serendipitous way.
+    '';
+    homepage = http://al.chemy.org/;
+    license = licenses.gpl3Plus;
+    maintainers = [ maintainers.marcweber ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/animbar/default.nix b/nixpkgs/pkgs/applications/graphics/animbar/default.nix
new file mode 100644
index 000000000000..c4f1b4218d07
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/animbar/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, lib, fetchurl, cmake, qt4, file }:
+
+stdenv.mkDerivation rec {
+  pname = "animbar";
+  version = "1.2";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/${pname}-${version}.tar.bz2";
+    sha256 = "0836nwcpyfdrapyj3hbg3wh149ihc26pc78h01adpc7c0r7d9pr9";
+  };
+
+  nativeBuildInputs = [ cmake  ];
+
+  buildInputs = [ qt4 file ];
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/pixmaps
+    cp src/animbar $out/bin
+    cp ../icon/* $out/share/pixmaps
+  '';
+
+  meta = with lib; {
+    description = "Create your own animation on paper and transparancy";
+    longDescription = ''
+	Animbar lets you easily create your own animation on paper and
+	transparancy. From a set of input images two output images are
+	computed, that are printed one on paper and one on
+	transparency. By moving the transparency over the paper you
+	create a fascinating animation effect. This kind of animation
+	technique is hundreds of years old and known under several
+	names: picket fence animation, barrier grid animation, Moiré
+	animation, to name a few.
+    '';
+    homepage = http://animbar.mnim.org;
+    maintainers = with maintainers; [ leenaars ];
+    platforms = platforms.linux;
+    license = licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/antimony/default.nix b/nixpkgs/pkgs/applications/graphics/antimony/default.nix
new file mode 100644
index 000000000000..3c39aadda98e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/antimony/default.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchFromGitHub, libpng, python3
+, libGLU_combined, qtbase, ncurses
+, cmake, flex, lemon
+}:
+
+let
+  gitRev    = "c0038e3ea82fec6119de364bcbc3370955ed46a2";
+  gitBranch = "develop";
+  gitTag    = "0.9.3";
+in
+  stdenv.mkDerivation {
+    pname = "antimony";
+    version = "2018-10-20";
+
+    src = fetchFromGitHub {
+      owner  = "mkeeter";
+      repo   = "antimony";
+      rev    = gitRev;
+      sha256 = "01cjcjppbb0gvh6npcsaidzpfcfzrqhhi07z4v0jkfyi0fl125v4";
+    };
+
+    patches = [ ./paths-fix.patch ];
+
+    postPatch = ''
+       sed -i "s,/usr/local,$out,g" \
+       app/CMakeLists.txt app/app/app.cpp app/app/main.cpp
+       sed -i "s,python3,${python3.executable}," CMakeLists.txt
+    '';
+
+    buildInputs = [
+      libpng python3 python3.pkgs.boost
+      libGLU_combined qtbase ncurses
+    ];
+
+    nativeBuildInputs = [ cmake flex lemon ];
+
+    cmakeFlags= [
+      "-DGITREV=${gitRev}"
+      "-DGITTAG=${gitTag}"
+      "-DGITBRANCH=${gitBranch}"
+    ];
+
+    enableParallelBuilding = true;
+
+    meta = with stdenv.lib; {
+      description = "A computer-aided design (CAD) tool from a parallel universe";
+      homepage    = "https://github.com/mkeeter/antimony";
+      license     = licenses.mit;
+      maintainers = with maintainers; [ rnhmjoj ];
+      platforms   = platforms.linux;
+    };
+  }
diff --git a/nixpkgs/pkgs/applications/graphics/antimony/paths-fix.patch b/nixpkgs/pkgs/applications/graphics/antimony/paths-fix.patch
new file mode 100644
index 000000000000..9235dd6cdce1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/antimony/paths-fix.patch
@@ -0,0 +1,21 @@
+diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
+index ddc5c9b..d80728a 100644
+--- a/app/CMakeLists.txt
++++ b/app/CMakeLists.txt
+@@ -158,16 +158,6 @@ target_link_libraries(${ANTIMONY_APP}
+ 
+ ################################################################################
+ 
+-execute_process(COMMAND git log --pretty=format:'%h' -n 1
+-                OUTPUT_VARIABLE GITREV)
+-execute_process(COMMAND bash -c "git diff --quiet --exit-code || echo +"
+-                OUTPUT_VARIABLE GITDIFF)
+-execute_process(COMMAND git describe --exact-match --tags
+-                OUTPUT_VARIABLE GITTAG
+-                ERROR_QUIET)
+-execute_process(COMMAND git rev-parse --abbrev-ref HEAD
+-                OUTPUT_VARIABLE GITBRANCH)
+-
+ add_definitions(-D'GITREV="${GITREV}${GITDIFF}"'
+                 -D'GITTAG="${GITTAG}"'
+                 -D'GITBRANCH="${GITBRANCH}"')
diff --git a/nixpkgs/pkgs/applications/graphics/apitrace/default.nix b/nixpkgs/pkgs/applications/graphics/apitrace/default.nix
new file mode 100644
index 000000000000..5ce36f4f10e9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/apitrace/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, cmake, libX11, procps, python2, libdwarf, qtbase, qtwebkit }:
+
+stdenv.mkDerivation rec {
+  pname = "apitrace";
+  version = "7.1-572-g${builtins.substring 0 8 src.rev}";
+
+  src = fetchFromGitHub {
+    sha256 = "11bwb0l8cr1bf9bj1s6cbmi77d5fy4qrphj9cgmcd8jpa862anp5";
+    rev = "26966134f15d28f6b4a9a0a560017b3ba36d60bf";
+    repo = "apitrace";
+    owner = "apitrace";
+  };
+
+  # LD_PRELOAD wrappers need to be statically linked to work against all kinds
+  # of games -- so it's fine to use e.g. bundled snappy.
+  buildInputs = [ libX11 procps python2 libdwarf qtbase qtwebkit ];
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with stdenv.lib; {
+    homepage = https://apitrace.github.io;
+    description = "Tools to trace OpenGL, OpenGL ES, Direct3D, and DirectDraw APIs";
+    license = licenses.mit;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/autopanosiftc/default.nix b/nixpkgs/pkgs/applications/graphics/autopanosiftc/default.nix
new file mode 100644
index 000000000000..c64604975ab0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/autopanosiftc/default.nix
@@ -0,0 +1,26 @@
+{stdenv, fetchurl, cmake, libpng, libtiff, libjpeg, panotools, libxml2 }:
+
+stdenv.mkDerivation {
+  name = "autopano-sift-C-2.5.1";
+
+  src = fetchurl {
+    url = mirror://sourceforge/hugin/autopano-sift-C-2.5.1.tar.gz;
+    sha256 = "0dqk8ff82gmy4v5ns5nr9gpzkc1p7c2y8c8fkid102r47wsjk44s";
+  };
+
+  buildInputs = [ cmake libpng libtiff libjpeg panotools libxml2 ];
+
+  patches = [
+    (fetchurl {
+      url = https://gitweb.gentoo.org/repo/gentoo.git/plain/media-gfx/autopano-sift-C/files/autopano-sift-C-2.5.1-lm.patch;
+      sha256 = "1bfcr5sps0ip9gl4jprji5jgf9wkczz6d2clsjjlbsy8r3ixi3lv";
+    })
+  ];
+
+  meta = {
+    homepage = http://hugin.sourceforge.net/;
+    description = "Implementation in C of the autopano-sift algorithm for automatically stitching panoramas";
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/autotrace/autofig.nix b/nixpkgs/pkgs/applications/graphics/autotrace/autofig.nix
new file mode 100644
index 000000000000..0f53965786b9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/autotrace/autofig.nix
@@ -0,0 +1,10 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation {
+  name = "autofig-0.1";
+
+  src = fetchurl {
+    url = "http://autotrace.sourceforge.net/tools/autofig.tar.gz";
+    sha256 = "11cs9hdbgcl3aamcs3149i8kvyyldmnjf6yq81kbcf8fdmfk2zdq";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/autotrace/default.nix b/nixpkgs/pkgs/applications/graphics/autotrace/default.nix
new file mode 100644
index 000000000000..57e95dfef106
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/autotrace/default.nix
@@ -0,0 +1,125 @@
+{ stdenv, fetchurl, callPackage, libpng12, imagemagick
+, autoreconfHook, glib, pstoedit, pkgconfig, gettext, gd, darwin
+, runtimeShell }:
+
+# TODO: Figure out why the resultant binary is somehow linked against
+# libpng16.so.16 rather than libpng12.
+
+stdenv.mkDerivation rec {
+  pname = "autotrace";
+  version = "0.31.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/autotrace/AutoTrace/0.31.1/${pname}-${version}.tar.gz";
+    sha256 = "1xmgja5fv48mdbsa51inf7ksz36nqd6bsaybrk5xgprm6cy946js";
+  };
+
+  # The below commented out part is for an identically-named project
+  # on GitHub which appears to derive somehow from the Sourceforge
+  # version, but I have no idea what the lineage is of this project.
+  # It will build, but it segfaults when I attempt to run -centerline.
+  # Someone may need this for some reason, so I've left it here.
+  #
+  #src = fetchFromGitHub {
+  #  owner = "autotrace";
+  #  repo = "autotrace";
+  #  rev = "b3ac8818d86943102cb4f13734e0b527c42dc45a";
+  #  sha256 = "0z5h2mvxwckk2msi361zk1nc9fdcvxyimyc2hlyqd6h8k3p7zdi4";
+  #};
+  #postConfigure = ''
+  #  sed -i -e "s/at_string/gchar */g" *.c
+  #  sed -i -e "s/at_address/gpointer/g" *.c
+  #  sed -i -e "s/at_bitmap_type/struct _at_bitmap/g" *.c
+  #  sed -i -e "s/AT_BITMAP_BITS(bitmap)/AT_BITMAP_BITS(\&bitmap)/g" input-magick.c
+  #'';
+
+  autofig = callPackage ./autofig.nix {};
+  nativeBuildInputs = [ autoreconfHook glib autofig pkgconfig gettext ];
+  buildInputs = [ libpng12 imagemagick pstoedit ]
+    ++ stdenv.lib.optionals stdenv.isDarwin
+       (with darwin.apple_sdk.frameworks; [ gd ApplicationServices ]);
+
+  postUnpack = ''
+    pushd $sourceRoot
+    autofig autotrace-config.af
+    popd
+  '';
+
+  # This complains about various m4 files, but it appears to not be an
+  # actual error.
+  preConfigure = ''
+    glib-gettextize --copy --force
+    # pstoedit-config no longer exists, it was replaced with pkg-config
+    mkdir wrappers
+    cat >wrappers/pstoedit-config <<'EOF'
+    #!${runtimeShell}
+    # replace --version with --modversion for pkg-config
+    args=''${@/--version/--modversion}
+    exec pkg-config pstoedit "''${args[@]}"
+    EOF
+    chmod +x wrappers/pstoedit-config
+    export PATH="$PATH:$PWD/wrappers"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://autotrace.sourceforge.net/;
+    description = "Utility for converting bitmap into vector graphics";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ hodapp ];
+    license = licenses.gpl2;
+    knownVulnerabilities = [
+      "CVE-2013-1953"
+      "CVE-2016-7392"
+      "CVE-2017-9151"
+      "CVE-2017-9152"
+      "CVE-2017-9153"
+      "CVE-2017-9154"
+      "CVE-2017-9155"
+      "CVE-2017-9156"
+      "CVE-2017-9157"
+      "CVE-2017-9158"
+      "CVE-2017-9159"
+      "CVE-2017-9160"
+      "CVE-2017-9161"
+      "CVE-2017-9162"
+      "CVE-2017-9163"
+      "CVE-2017-9164"
+      "CVE-2017-9165"
+      "CVE-2017-9166"
+      "CVE-2017-9167"
+      "CVE-2017-9168"
+      "CVE-2017-9169"
+      "CVE-2017-9170"
+      "CVE-2017-9171"
+      "CVE-2017-9172"
+      "CVE-2017-9173"
+      "CVE-2017-9174"
+      "CVE-2017-9175"
+      "CVE-2017-9176"
+      "CVE-2017-9177"
+      "CVE-2017-9178"
+      "CVE-2017-9179"
+      "CVE-2017-9180"
+      "CVE-2017-9181"
+      "CVE-2017-9182"
+      "CVE-2017-9183"
+      "CVE-2017-9184"
+      "CVE-2017-9185"
+      "CVE-2017-9186"
+      "CVE-2017-9187"
+      "CVE-2017-9188"
+      "CVE-2017-9189"
+      "CVE-2017-9190"
+      "CVE-2017-9191"
+      "CVE-2017-9192"
+      "CVE-2017-9193"
+      "CVE-2017-9194"
+      "CVE-2017-9195"
+      "CVE-2017-9196"
+      "CVE-2017-9197"
+      "CVE-2017-9198"
+      "CVE-2017-9199"
+      "CVE-2017-9200"
+    ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/avocode/default.nix b/nixpkgs/pkgs/applications/graphics/avocode/default.nix
new file mode 100644
index 000000000000..5e1cba31b7ec
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/avocode/default.nix
@@ -0,0 +1,102 @@
+{ stdenv, makeDesktopItem, fetchurl, unzip
+, gdk-pixbuf, glib, gtk3, atk, at-spi2-atk, pango, cairo, freetype, fontconfig, dbus, nss, nspr, alsaLib, cups, expat, udev, gnome3
+, xorg, mozjpeg, makeWrapper, wrapGAppsHook, hicolor-icon-theme, libuuid, at-spi2-core
+}:
+
+stdenv.mkDerivation rec {
+  pname = "avocode";
+  version = "3.9.2";
+
+  src = fetchurl {
+    url = "https://media.avocode.com/download/avocode-app/${version}/avocode-${version}-linux.zip";
+    sha256 = "18yzw7bss1dkmmd8lxr9x8s46qmpnqci202g16zrp6j9jdj094d3";
+  };
+
+  libPath = stdenv.lib.makeLibraryPath (with xorg; [
+    stdenv.cc.cc.lib
+    at-spi2-core.out
+    gdk-pixbuf
+    glib
+    gtk3
+    atk
+    at-spi2-atk
+    pango
+    cairo
+    freetype
+    fontconfig
+    dbus
+    nss
+    nspr
+    alsaLib
+    cups
+    expat
+    udev
+    libX11
+    libxcb
+    libXi
+    libXcursor
+    libXdamage
+    libXrandr
+    libXcomposite
+    libXext
+    libXfixes
+    libXrender
+    libXtst
+    libXScrnSaver
+    libuuid
+  ]);
+
+  desktopItem = makeDesktopItem {
+    name = "Avocode";
+    exec = "avocode";
+    icon = "avocode";
+    desktopName = "Avocode";
+    genericName = "Design Inspector";
+    categories = "Application;Development;";
+    comment = "The bridge between designers and developers";
+  };
+
+  nativeBuildInputs = [makeWrapper wrapGAppsHook];
+  buildInputs = [ unzip gtk3 gnome3.adwaita-icon-theme hicolor-icon-theme ];
+
+  # src is producing multiple folder on unzip so we must
+  # override unpackCmd to extract it into newly created folder
+  unpackCmd = ''
+    mkdir out
+    unzip $curSrc -d out
+  '';
+
+  installPhase = ''
+    substituteInPlace avocode.desktop.in \
+      --replace /path/to/avocode-dir/Avocode $out/bin/avocode \
+      --replace /path/to/avocode-dir/avocode.png avocode
+
+    mkdir -p share/applications share/pixmaps
+    mv avocode.desktop.in share/applications/avocode.desktop
+    mv avocode.png share/pixmaps/
+
+    rm resources/cjpeg
+    cp -av . $out
+
+    mkdir $out/bin
+    ln -s $out/avocode $out/bin/avocode
+    ln -s ${mozjpeg}/bin/cjpeg $out/resources/cjpeg
+  '';
+
+  postFixup = ''
+    patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/avocode
+    for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
+      patchelf --set-rpath ${libPath}:$out/ $file || true
+    done
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://avocode.com/;
+    description = "The bridge between designers and developers";
+    license = licenses.unfree;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ megheaiulian ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/awesomebump/default.nix b/nixpkgs/pkgs/applications/graphics/awesomebump/default.nix
new file mode 100644
index 000000000000..b827a12f81c8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/awesomebump/default.nix
@@ -0,0 +1,62 @@
+{ lib, stdenv, fetchgit, qtbase, qmake, makeWrapper, qtscript, flex, bison, qtdeclarative }:
+
+
+let
+  version = "5.1";
+
+  src = fetchgit {
+    url = "https://github.com/kmkolasinski/AwesomeBump.git";
+    rev = "Winx32v${version}";
+    sha256 = "1c8b9jki0v8kzkvsvyv7q1w3s7j40br6ph15hh2xi0a1mpwckq56";
+    fetchSubmodules = true;
+  };
+
+  qtnproperty = stdenv.mkDerivation {
+    name = "qtnproperty";
+    inherit src;
+    sourceRoot = "AwesomeBump/Sources/utils/QtnProperty";
+    patches = [ ./qtnproperty-parallel-building.patch ];
+    buildInputs = [ qtscript qtbase qtdeclarative ];
+    nativeBuildInputs = [ qmake flex bison ];
+    postInstall = ''
+      install -D bin-linux/QtnPEG $out/bin/QtnPEG
+    '';
+  };
+in stdenv.mkDerivation {
+  pname = "awesomebump";
+  inherit version;
+
+  inherit src;
+
+  buildInputs = [ qtbase qtscript qtdeclarative ];
+
+  nativeBuildInputs = [ qmake makeWrapper ];
+
+  preBuild = ''
+    ln -sf ${qtnproperty}/bin/QtnPEG Sources/utils/QtnProperty/bin-linux/QtnPEG
+  '';
+
+  postInstall = ''
+    d=$out/libexec/AwesomeBump
+
+    mkdir -p $d
+    cp -vr workdir/`cat workdir/current`/bin/AwesomeBump $d/
+    cp -prd Bin/Configs Bin/Core $d/
+
+    # AwesomeBump expects to find Core and Configs in its current directory.
+    makeWrapper $d/AwesomeBump $out/bin/AwesomeBump \
+        --run "cd $d"
+  '';
+
+  # $ cd Sources; qmake; make ../workdir/linux-g++-dgb-gl4/obj/glwidget.o
+  # fatal error: properties/ImageProperties.peg.h: No such file or directory
+  enableParallelBuilding = false;
+
+  meta = {
+    homepage = https://github.com/kmkolasinski/AwesomeBump;
+    description = "A program to generate normal, height, specular or ambient occlusion textures from a single image";
+    license = lib.licenses.gpl3Plus;
+    maintainers = [ lib.maintainers.eelco ];
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/awesomebump/qtnproperty-parallel-building.patch b/nixpkgs/pkgs/applications/graphics/awesomebump/qtnproperty-parallel-building.patch
new file mode 100644
index 000000000000..b3f8e68dd1ad
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/awesomebump/qtnproperty-parallel-building.patch
@@ -0,0 +1,9 @@
+--- a/PEG/Flex.pri
++++ b/PEG/Flex.pri
+@@ -1,5 +1,6 @@
+ flex.name = Flex ${QMAKE_FILE_IN}
+ flex.input = FLEX_SOURCES
++flex.depends = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.parser.cpp
+ flex.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp
+ 
+ win32:flex.commands = win_flex --wincompat -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp ${QMAKE_FILE_IN}
diff --git a/nixpkgs/pkgs/applications/graphics/azpainter/default.nix b/nixpkgs/pkgs/applications/graphics/azpainter/default.nix
new file mode 100644
index 000000000000..b2060f5db31e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/azpainter/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, autoreconfHook
+, libX11, libXext, libXi
+, freetype, fontconfig
+, libpng, libjpeg
+, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "azpainter";
+  version = "2.1.4";
+
+  src = fetchFromGitHub {
+    owner = "Symbian9";
+    repo = pname;
+    rev = "refs/tags/v${version}";
+    sha256 = "1hrr9lhsbjyzar3nxvli6cazr7zhyzh0p8hwpg4g9ga6njs8vi8m";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+
+  buildInputs = [
+    libX11 libXext libXi
+    freetype fontconfig
+    libpng libjpeg
+    zlib
+  ];
+
+  configureFlags = [
+    "--with-freetype-dir=${stdenv.lib.getDev freetype}/include/freetype2"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Full color painting software for illustration drawing";
+    homepage = "https://osdn.net/projects/azpainter";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ dtzWill ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/batik/builder.sh b/nixpkgs/pkgs/applications/graphics/batik/builder.sh
new file mode 100755
index 000000000000..c6cf64bf3700
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/batik/builder.sh
@@ -0,0 +1,7 @@
+set -e
+
+source $stdenv/setup
+
+unzip $src
+mkdir $out
+mv batik-* $out/batik
diff --git a/nixpkgs/pkgs/applications/graphics/batik/default.nix b/nixpkgs/pkgs/applications/graphics/batik/default.nix
new file mode 100644
index 000000000000..51156dea4a17
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/batik/default.nix
@@ -0,0 +1,25 @@
+{stdenv, fetchurl, unzip}:
+
+stdenv.mkDerivation {
+  name = "batik-1.6";
+  builder = ./builder.sh;
+  src = fetchurl {
+    url = http://tarballs.nixos.org/batik-1.6.zip;
+    sha256 = "0cf15dspmzcnfda8w5lbsdx28m4v2rpq1dv5zx0r0n99ihqd1sh6";
+  };
+
+  buildInputs = [unzip];
+
+  meta = with stdenv.lib; {
+    description = "Java based toolkit for handling SVG";
+    homepage = https://xmlgraphics.apache.org/batik;
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    knownVulnerabilities = [
+      # vulnerabilities as of 16th October 2018 from https://xmlgraphics.apache.org/security.html:
+      "CVE-2018-8013"
+      "CVE-2017-5662"
+      "CVE-2015-0250"
+    ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/c3d/default.nix b/nixpkgs/pkgs/applications/graphics/c3d/default.nix
new file mode 100644
index 000000000000..ad86e66204b2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/c3d/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchgit, cmake, itk, Cocoa }:
+
+stdenv.mkDerivation {
+  pname   = "c3d";
+  version = "2018-10-04";
+
+  src = fetchgit {
+    url = "https://git.code.sf.net/p/c3d/git";
+    rev = "351929a582b2ef68fb9902df0b11d38f44a0ccd0";
+    sha256 = "0mpv4yl6hdnxgvnwrmd182h64n3ppp30ldzm0jz6jglk0nvpzq9w";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ itk ]
+    ++ stdenv.lib.optional stdenv.isDarwin Cocoa;
+
+  meta = with stdenv.lib; {
+    homepage = http://www.itksnap.org/c3d;
+    description = "Medical imaging processing tool";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license = licenses.gpl2;
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/cinepaint/default.nix b/nixpkgs/pkgs/applications/graphics/cinepaint/default.nix
new file mode 100644
index 000000000000..57cf6c3f13f4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/cinepaint/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchurl, cmake, pkgconfig, gtk2, freetype, fontconfig, lcms,
+  flex, libtiff, libjpeg, libpng, libexif, zlib, perlPackages, libX11,
+  pythonPackages, gettext, intltool, babl, gegl,
+  glib, makedepend, xorgproto, libXmu, openexr,
+  libGLU_combined, libXext, libXpm, libXau, libXxf86vm, pixman, libpthreadstubs, fltk } :
+
+let
+  inherit (pythonPackages) python pygtk;
+in stdenv.mkDerivation rec {
+  name = "cinepaint-1.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/cinepaint/${name}.tgz";
+    sha256 = "0b5g4bkq62yiz1cnb2vfij0a8fw5w5z202v5dm4dh89k7cj0yq4w";
+  };
+
+  buildInputs = [ libpng gtk2 freetype fontconfig lcms flex libtiff libjpeg
+    libexif zlib libX11 python pygtk gettext intltool babl
+    gegl glib makedepend xorgproto libXmu openexr libGLU_combined
+    libXext libXpm libXau libXxf86vm pixman libpthreadstubs fltk
+  ] ++ (with perlPackages; [ perl XMLParser ]);
+
+  hardeningDisable = [ "format" ];
+
+  patches = [ ./install.patch ];
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  NIX_LDFLAGS = "-lm -llcms -ljpeg -lpng -lX11";
+
+  meta = {
+    homepage = http://www.cinepaint.org/;
+    license = stdenv.lib.licenses.free;
+    description = "Image editor which supports images over 8bpp and ICC profiles";
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/cinepaint/install.patch b/nixpkgs/pkgs/applications/graphics/cinepaint/install.patch
new file mode 100644
index 000000000000..f15ff1c4414d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/cinepaint/install.patch
@@ -0,0 +1,24 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index dfb182f..5adaaa5 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -138,7 +138,7 @@ STRING(REPLACE "/" "\\/" ESCAPEDPREFIX ${PREFIX})
+ # Note that for MacOS this needs to be revised 
+ # for the @OSX_ICC...@ variables
+ ADD_CUSTOM_COMMAND(
+-   OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/gimprc
++   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gimprc
+    COMMAND  sed -e s/\@platform\@//g
+ 		-e s/\@prefix\@/${ESCAPEDPREFIX}/g 
+ 	        -e s/\@exec_prefix\@/\${prefix}/g
+@@ -155,8 +155,8 @@ ADD_CUSTOM_COMMAND(
+ 
+ ADD_CUSTOM_TARGET(RCFile ALL echo
+       ""
+-      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/user_install 
+-              ${CMAKE_CURRENT_SOURCE_DIR}/gimprc
++      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/user_install 
++              ${CMAKE_CURRENT_BINARY_DIR}/gimprc
+    )
+ 
+ 
diff --git a/nixpkgs/pkgs/applications/graphics/comical/default.nix b/nixpkgs/pkgs/applications/graphics/comical/default.nix
new file mode 100644
index 000000000000..2796a5535a03
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/comical/default.nix
@@ -0,0 +1,23 @@
+{stdenv, fetchurl, wxGTK, utillinux, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "comical-0.8";
+  src = fetchurl {
+    url = "mirror://sourceforge/comical/${name}.tar.gz";
+    sha256 = "0b6527cc06b25a937041f1eb248d0fd881cf055362097036b939817f785ab85e";
+  };
+  buildInputs = [ wxGTK utillinux zlib ];
+  preBuild="makeFlags=\"prefix=$out\"";
+
+  patches = [ ./wxgtk-2.8.patch ];
+
+  preInstall = "mkdir -pv $out/bin";
+
+  meta = {
+    description = "Viewer of CBR and CBZ files, often used to store scanned comics";
+    homepage = http://comical.sourceforge.net/;
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/comical/wxgtk-2.8.patch b/nixpkgs/pkgs/applications/graphics/comical/wxgtk-2.8.patch
new file mode 100644
index 000000000000..db7626074a0f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/comical/wxgtk-2.8.patch
@@ -0,0 +1,36 @@
+diff --git a/Makefile b/Makefile
+index a648e72..181c47f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,5 +1,5 @@
+ CC = `wx-config --cxx`
+-LDFLAGS = `wx-config --libs` -Lunrar -lunrar -Lunzip -lminiunzip
++LDFLAGS = `wx-config --libs` -Lunrar -lunrar -Lunzip -lminiunzip -lz
+ INSTALL = install
+ INSTALL_PROGRAM = $(INSTALL)
+ prefix = /usr/local
+diff --git a/src/ComicalApp.cpp b/src/ComicalApp.cpp
+index 0c004cd..667e75e 100644
+--- a/src/ComicalApp.cpp
++++ b/src/ComicalApp.cpp
+@@ -28,6 +28,7 @@
+ #include "ComicalApp.h"
+ #include "ComicalFrame.h"
+ #include <wx/log.h>
++#include <wx/icon.h>
+ 
+ #if !defined(__WXMAC__) && !defined(__WXCOCOA__) && !defined(__WXMSW__) && !defined(__WXPM__)
+ #include "../Comical Icons/comical.xpm"
+diff --git a/unzip/unzip.h b/unzip/unzip.h
+index b247937..5bb6a69 100644
+--- a/unzip/unzip.h
++++ b/unzip/unzip.h
+@@ -50,7 +50,7 @@ extern "C" {
+ #endif
+ 
+ #ifndef _ZLIB_H
+-#include "zlib.h"
++#include <zlib.h>
+ #endif
+ 
+ #ifndef _ZLIBIOAPI_H
diff --git a/nixpkgs/pkgs/applications/graphics/darktable/default.nix b/nixpkgs/pkgs/applications/graphics/darktable/default.nix
new file mode 100644
index 000000000000..d3c7691ccff9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/darktable/default.nix
@@ -0,0 +1,57 @@
+{ stdenv, fetchurl, libsoup, graphicsmagick, json-glib, wrapGAppsHook
+, cairo, cmake, ninja, curl, perl, llvm, desktop-file-utils, exiv2, glib
+, ilmbase, gtk3, intltool, lcms2, lensfun, libX11, libexif, libgphoto2, libjpeg
+, libpng, librsvg, libtiff, openexr, osm-gps-map, pkgconfig, sqlite, libxslt
+, openjpeg, lua, pugixml, colord, colord-gtk, libwebp, libsecret, gnome3
+, ocl-icd, pcre, gtk-mac-integration, isocodes
+}:
+
+stdenv.mkDerivation rec {
+  version = "2.6.2";
+  pname = "darktable";
+
+  src = fetchurl {
+    url = "https://github.com/darktable-org/darktable/releases/download/release-${version}/darktable-${version}.tar.xz";
+    sha256 = "0igvgyd042j7hm4y8fcm6dc1qqjs4d1r7y6f0pzpa0x416xyzfcw";
+  };
+
+  nativeBuildInputs = [ cmake ninja llvm pkgconfig intltool perl desktop-file-utils wrapGAppsHook ];
+
+  buildInputs = [
+    cairo curl exiv2 glib gtk3 ilmbase lcms2 lensfun libexif
+    libgphoto2 libjpeg libpng librsvg libtiff openexr sqlite libxslt
+    libsoup graphicsmagick json-glib openjpeg lua pugixml
+    libwebp libsecret gnome3.adwaita-icon-theme osm-gps-map pcre isocodes
+  ] ++ stdenv.lib.optionals stdenv.isLinux [
+    colord colord-gtk libX11 ocl-icd
+  ] ++ stdenv.lib.optional stdenv.isDarwin gtk-mac-integration;
+
+  cmakeFlags = [
+    "-DBUILD_USERMANUAL=False"
+  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+    "-DUSE_COLORD=OFF"
+    "-DUSE_KWALLET=OFF"
+  ];
+
+
+  # darktable changed its rpath handling in commit
+  # 83c70b876af6484506901e6b381304ae0d073d3c and as a result the
+  # binaries can't find libdarktable.so, so change LD_LIBRARY_PATH in
+  # the wrappers:
+  preFixup = let
+    libPathEnvVar = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
+    libPathPrefix = "$out/lib/darktable" + stdenv.lib.optionalString stdenv.isLinux ":${ocl-icd}/lib";
+  in ''
+    gappsWrapperArgs+=(
+      --prefix ${libPathEnvVar} ":" "${libPathPrefix}"
+    )
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Virtual lighttable and darkroom for photographers";
+    homepage = https://www.darktable.org;
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ goibhniu flosse mrVanDalo ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/deskew/default.nix b/nixpkgs/pkgs/applications/graphics/deskew/default.nix
new file mode 100644
index 000000000000..c35aaa044aef
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/deskew/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchFromBitbucket, libtiff, fpc }:
+
+stdenv.mkDerivation rec {
+
+  pname = "deskew";
+  version = "1.25";
+
+  src = fetchFromBitbucket {
+    owner = "galfar";
+    repo = "app-deskew";
+    rev = "v${version}";
+    sha256 = "0zjjj66qhgqkmfxl3q7p78dv4xl4ci918pgl4d5259pqdj1bfgc8";
+  };
+
+  nativeBuildInputs = [ fpc ];
+  buildInputs = [ libtiff ];
+
+  buildPhase = ''
+    rm -r Bin # Remove pre-compiled binary
+    mkdir Bin
+    chmod +x compile.sh
+    ./compile.sh
+  '';
+
+  installPhase = ''
+    install -Dt $out/bin Bin/*
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A command line tool for deskewing scanned text documents";
+    homepage = https://bitbucket.org/galfar/app-deskew/overview;
+    license = licenses.mit;
+    maintainers = with maintainers; [ryantm];
+    platforms = platforms.all;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/graphics/dia/default.nix b/nixpkgs/pkgs/applications/graphics/dia/default.nix
new file mode 100644
index 000000000000..a1f96337d743
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/dia/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchgit, autoconf, automake, libtool, gtk2, pkgconfig, perlPackages,
+libxml2, gettext, python, libxml2Python, docbook5, docbook_xsl,
+libxslt, intltool, libart_lgpl, withGNOME ? false, libgnomeui, hicolor-icon-theme,
+gtk-mac-integration-gtk2 }:
+
+stdenv.mkDerivation {
+  pname = "dia";
+  version = "0.97.3.20170622";
+
+  src = fetchgit {
+    url = https://gitlab.gnome.org/GNOME/dia.git;
+    rev = "b86085dfe2b048a2d37d587adf8ceba6fb8bc43c";
+    sha256 = "1fyxfrzdcs6blxhkw3bcgkksaf3byrsj4cbyrqgb4869k3ynap96";
+  };
+
+  buildInputs =
+    [ gtk2 libxml2 gettext python libxml2Python docbook5
+      libxslt docbook_xsl libart_lgpl hicolor-icon-theme ]
+      ++ stdenv.lib.optional withGNOME libgnomeui
+      ++ stdenv.lib.optional stdenv.isDarwin gtk-mac-integration-gtk2;
+
+  nativeBuildInputs = [ autoconf automake libtool pkgconfig intltool ]
+    ++ (with perlPackages; [ perl XMLParser ]);
+
+  preConfigure = ''
+    NOCONFIGURE=1 ./autogen.sh # autoreconfHook is not enough
+  '';
+  configureFlags = stdenv.lib.optional withGNOME "--enable-gnome";
+
+  hardeningDisable = [ "format" ];
+
+  meta = with stdenv.lib; {
+    description = "Gnome Diagram drawing software";
+    homepage = http://live.gnome.org/Dia;
+    maintainers = with maintainers; [ raskin ];
+    license = licenses.gpl2;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/digikam/default.nix b/nixpkgs/pkgs/applications/graphics/digikam/default.nix
new file mode 100644
index 000000000000..1fc15af72441
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/digikam/default.nix
@@ -0,0 +1,132 @@
+{ mkDerivation, lib, fetchFromGitHub, cmake, doxygen, extra-cmake-modules, wrapGAppsHook
+
+# For `digitaglinktree`
+, perl, sqlite
+
+, qtbase
+, qtxmlpatterns
+, qtsvg
+, qtwebengine
+
+, akonadi-contacts
+, kcalcore
+, kconfigwidgets
+, kcoreaddons
+, kdoctools
+, kfilemetadata
+, knotifications
+, knotifyconfig
+, ktextwidgets
+, kwidgetsaddons
+, kxmlgui
+
+, bison
+, boost
+, eigen
+, exiv2
+, ffmpeg
+, flex
+, jasper
+, lcms2
+, lensfun
+, libgphoto2
+, libkipi
+, libksane
+, liblqr1
+, libqtav
+, libusb1
+, marble
+, libGL
+, libGLU
+, opencv3
+, pcre
+, threadweaver
+
+# For panorama and focus stacking
+, enblend-enfuse
+, hugin
+, gnumake
+
+, oxygen
+}:
+
+mkDerivation rec {
+  pname   = "digikam";
+  version = "6.2.0";
+
+  src = fetchFromGitHub {
+    owner  = "KDE";
+    repo   = "digikam";
+    rev    = "v${version}";
+    sha256 = "1l1nb1nwicmip2jxhn5gzr7h60igvns0zs3kzp36r6qf4wvg3v2z";
+  };
+
+  nativeBuildInputs = [ cmake doxygen extra-cmake-modules kdoctools wrapGAppsHook ];
+
+  buildInputs = [
+    bison
+    boost
+    eigen
+    exiv2
+    ffmpeg
+    flex
+    jasper
+    lcms2
+    lensfun
+    libgphoto2
+    libkipi
+    libksane
+    liblqr1
+    libqtav
+    libusb1
+    libGL
+    libGLU
+    opencv3
+    pcre
+
+    qtbase
+    qtxmlpatterns
+    qtsvg
+    qtwebengine
+
+    akonadi-contacts
+    kcalcore
+    kconfigwidgets
+    kcoreaddons
+    kfilemetadata
+    knotifications
+    knotifyconfig
+    ktextwidgets
+    kwidgetsaddons
+    kxmlgui
+
+    marble
+    oxygen
+    threadweaver
+  ];
+
+  enableParallelBuilding = true;
+
+  cmakeFlags = [
+    "-DENABLE_MYSQLSUPPORT=1"
+    "-DENABLE_INTERNALMYSQL=1"
+    "-DENABLE_MEDIAPLAYER=1"
+    "-DENABLE_QWEBENGINE=on"
+  ];
+
+  preFixup = ''
+    gappsWrapperArgs+=(--prefix PATH : ${lib.makeBinPath [ gnumake hugin enblend-enfuse ]})
+    gappsWrapperArgs+=(--suffix DK_PLUGIN_PATH : ${placeholder "out"}/${qtbase.qtPluginPrefix}/${pname})
+    substituteInPlace $out/bin/digitaglinktree \
+      --replace "/usr/bin/perl" "${perl}/bin/perl" \
+      --replace "/usr/bin/sqlite3" "${sqlite}/bin/sqlite3"
+  '';
+
+  meta = with lib; {
+    description = "Photo Management Program";
+    license = licenses.gpl2;
+    homepage = https://www.digikam.org;
+    maintainers = with maintainers; [ the-kenny ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/displaycal/default.nix b/nixpkgs/pkgs/applications/graphics/displaycal/default.nix
new file mode 100644
index 000000000000..821a9e8083e1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/displaycal/default.nix
@@ -0,0 +1,59 @@
+{buildPythonPackage, stdenv, fetchurl, pkgconfig
+ , libXext, libXxf86vm, libX11, libXrandr, libXinerama, libXScrnSaver
+ , argyllcms, wxPython, numpy
+ }:
+buildPythonPackage {
+  pname = "displaycal";
+  version = "3.5.0.0";
+
+  enableParallelBuilding = true;
+
+  src = fetchurl {
+    url = mirror://sourceforge/project/dispcalgui/release/3.5.0.0/DisplayCAL-3.5.0.0.tar.gz;
+    sha256 = "1j496sv8pbhby5hkkbp07k6bs3f7mb1l3dijmn2iga3kmix0fn5q";
+  };
+
+  propagatedBuildInputs = [
+    libXext
+    libXxf86vm
+    libX11
+    libXrandr
+    libXinerama
+    libXScrnSaver
+    argyllcms
+    wxPython
+    numpy
+  ];
+
+  nativeBuildInputs = [
+    pkgconfig
+  ];
+
+  preConfigure = ''
+    mkdir dist
+    cp {misc,dist}/DisplayCAL.appdata.xml
+    mkdir -p $out
+    ln -s $out/share/DisplayCAL $out/Resources
+  '';
+
+  # no idea why it looks there - symlink .json lang (everything)
+  postInstall = ''
+    for x in $out/share/DisplayCAL/*; do
+      ln -s $x $out/lib/python2.7/site-packages/DisplayCAL
+    done
+
+    for prog in "$out/bin/"*; do
+      wrapProgram "$prog" \
+        --prefix PYTHONPATH : "$PYTHONPATH" \
+        --prefix PATH : ${argyllcms}/bin
+    done
+  '';
+
+  meta = {
+    description = "Display Calibration and Characterization powered by Argyll CMS";
+    homepage = https://displaycal.net/;
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = [stdenv.lib.maintainers.marcweber];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/djview/default.nix b/nixpkgs/pkgs/applications/graphics/djview/default.nix
new file mode 100644
index 000000000000..1917640fd2e5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/djview/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, pkgconfig
+, djvulibre, qt4, xorg, libtiff
+, darwin }:
+
+stdenv.mkDerivation rec {
+  pname = "djview";
+  version = "4.10.6";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/djvu/${pname}-${version}.tar.gz";
+    sha256 = "08bwv8ppdzhryfcnifgzgdilb12jcnivl4ig6hd44f12d76z6il4";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+
+  buildInputs = [ djvulibre qt4 xorg.libXt libtiff ]
+  ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.AGL ];
+
+  passthru = {
+    mozillaPlugin = "/lib/mozilla/plugins";
+  };
+
+  meta = with stdenv.lib; {
+    homepage = http://djvu.sourceforge.net/djview4.html;
+    description = "A portable DjVu viewer and browser plugin";
+    license = licenses.gpl2;
+    platforms = platforms.unix;
+    maintainers = [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/dosage/default.nix b/nixpkgs/pkgs/applications/graphics/dosage/default.nix
new file mode 100644
index 000000000000..cf5ecfdd043f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/dosage/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, pythonPackages, fetchFromGitHub }:
+
+pythonPackages.buildPythonApplication rec {
+  pname = "dosage";
+  version = "2018.04.08";
+  PBR_VERSION = version;
+
+  src = fetchFromGitHub {
+    owner = "webcomics";
+    repo = "dosage";
+    rev = "b2fdc13feb65b93762928f7e99bac7b1b7b31591";
+    sha256 = "1p6vllqaf9s6crj47xqp97hkglch1kd4y8y4lxvzx3g2shhhk9hh";
+  };
+  checkInputs = with pythonPackages; [ pytest responses ];
+  propagatedBuildInputs = with pythonPackages; [ colorama lxml requests pbr ];
+
+  disabled = pythonPackages.pythonOlder "3.3";
+
+  checkPhase = ''
+    py.test tests/
+  '';
+
+  meta = {
+    description = "A comic strip downloader and archiver";
+    homepage = https://dosage.rocks/;
+    license = stdenv.lib.licenses.mit;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/draftsight/default.nix b/nixpkgs/pkgs/applications/graphics/draftsight/default.nix
new file mode 100644
index 000000000000..e59d14f7dd6e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/draftsight/default.nix
@@ -0,0 +1,88 @@
+{ stdenv, fetchurl, dpkg, makeWrapper, gcc, libGLU_combined, xdg_utils,
+  dbus, alsaLib, cups, fontconfig, glib, icu, libpng12,
+  xkeyboard_config, zlib, libxslt, libxml2, sqlite, orc,
+  libX11, libXcursor, libXrandr, libxcb, libXi, libSM, libICE,
+  libXrender, libXcomposite }:
+
+let version = "2018SP2"; in
+stdenv.mkDerivation {
+  pname = "draftsight";
+  inherit version;
+
+  nativeBuildInputs = [ dpkg makeWrapper ];
+
+  unpackPhase = ''
+    mkdir $out
+    mkdir $out/draftsight
+    dpkg -x $src $out/draftsight
+  '';
+
+  # Both executables and bundled libraries need patching to find their
+  # dependencies.  The makeWrapper & QT_XKB_CONFIG_ROOT is to
+  # alleviate "xkbcommon: ERROR: failed to add default include path
+  # /usr/share/X11/xkb" and "Qt: Failed to create XKB context!".
+  installPhase = ''
+    mkdir $out/bin
+    for exe in DraftSight dsHttpApiController dsHttpApiService FxCrashRptApp HelpGuide; do
+      echo "Patching $exe..."
+      patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+               --set-rpath $libPath:\$ORIGIN/../Libraries \
+               $out/draftsight/opt/dassault-systemes/DraftSight/Linux/$exe
+      makeWrapper $out/draftsight/opt/dassault-systemes/DraftSight/Linux/$exe \
+          $out/bin/$exe \
+          --prefix "QT_XKB_CONFIG_ROOT" ":" "${xkeyboard_config}/share/X11/xkb"
+    done
+    for lib in $out/draftsight/opt/dassault-systemes/DraftSight/Libraries/*.so*; do
+      # DraftSight ships with broken symlinks for some reason
+      if [ -f $(readlink -f $lib) ]
+      then
+        echo "Patching $lib..."
+        patchelf --set-rpath $libPath:\$ORIGIN/../Libraries $lib
+      else
+        echo "Ignoring broken link $lib"
+      fi
+    done
+    for lib in $out/draftsight/opt/dassault-systemes/DraftSight/APISDK/lib/cpp/*.so*; do
+      if [ -f $(readlink $lib) ]
+      then
+        echo "Patching $lib..."
+        chmod u+w $lib
+        patchelf --set-rpath $libPath:\$ORIGIN/../Libraries $lib
+      else
+        echo "Ignoring broken link $lib"
+      fi
+    done
+    # These libraries shouldn't really be here anyway:
+    find $out/draftsight/opt/dassault-systemes/DraftSight/APISDK/Samples/C++ \
+         -type d -name _lib | xargs rm -r
+  '';
+
+  # TODO: Figure out why HelpGuide segfaults at startup.
+
+  # This must be here for main window graphics to appear (without it
+  # it also gives the error: "QXcbIntegration: Cannot create platform
+  # OpenGL context, neither GLX nor EGL are enabled"). My guess is
+  # that it dlopen()'s libraries in paths removed by shrinking RPATH.
+  dontPatchELF = true;
+
+  src = fetchurl {
+    name = "draftSight.deb";
+    url = "http://dl-ak.solidworks.com/nonsecure/draftsight/${version}/draftSight.deb";
+    sha256 = "05lrvml0zkzqg0sj6sj2h8h66hxdmsw5fg9fwz923r1y8j48qxdx";
+  };
+
+  libPath = stdenv.lib.makeLibraryPath [ gcc.cc libGLU_combined xdg_utils
+    dbus alsaLib cups.lib fontconfig glib icu libpng12
+    xkeyboard_config zlib libxslt libxml2 sqlite orc libX11
+    libXcursor libXrandr libxcb libXi libSM libICE libXrender
+    libXcomposite ];
+
+  meta = with stdenv.lib; {
+    description = "2D design & drafting application, meant to be similar to AutoCAD";
+    longDescription = "Professional-grade 2D design and drafting solution from Dassault Systèmes that lets you create, edit, view and mark up any kind of 2D CAD drawing.";
+    homepage = https://www.3ds.com/products-services/draftsight-cad-software/;
+    license = stdenv.lib.licenses.unfree;
+    maintainers = with maintainers; [ hodapp ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/drawio/default.nix b/nixpkgs/pkgs/applications/graphics/drawio/default.nix
new file mode 100644
index 000000000000..3f922530e73e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/drawio/default.nix
@@ -0,0 +1,94 @@
+{ stdenv, lib, fetchurl, rpmextract, autoPatchelfHook, wrapGAppsHook
+
+# Dynamic libraries
+, alsaLib, atk, at-spi2-atk, at-spi2-core, cairo, dbus, cups, expat
+, gdk-pixbuf, glib, gtk3, libX11, libXScrnSaver, libXcomposite, libXcursor
+, libXdamage, libXext, libXfixes, libXi, libXrandr, libXrender, libXtst
+, libxcb, libuuid, nspr, nss, pango
+
+, systemd
+}:
+
+stdenv.mkDerivation rec {
+  pname = "drawio";
+  version = "11.1.4";
+
+  src = fetchurl {
+    url = "https://github.com/jgraph/drawio-desktop/releases/download/v${version}/draw.io-x86_64-${version}.rpm";
+    sha256 = "0ca8wkkdr7kbb8il84nq05qgd5ykjq15fdv9432wr5p9xmqixz1q";
+  };
+
+  nativeBuildInputs = [
+    autoPatchelfHook
+    rpmextract
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    alsaLib
+    atk
+    at-spi2-atk
+    at-spi2-core
+    cairo
+    cups
+    dbus
+    expat
+    gdk-pixbuf
+    glib
+    gtk3
+    libX11
+    libXScrnSaver
+    libXcomposite
+    libXcursor
+    libXdamage
+    libXext
+    libXfixes
+    libXi
+    libXrandr
+    libXrender
+    libXtst
+    libxcb
+    libuuid
+    nspr
+    nss
+    pango
+    systemd
+  ];
+
+  runtimeDependencies = [
+    systemd.lib
+  ];
+
+  dontBuild = true;
+  dontConfigure = true;
+
+  unpackPhase = "rpmextract ${src}";
+
+  installPhase = ''
+    mkdir -p $out/share
+    cp -r opt/draw.io $out/share/
+
+    # Application icon
+    mkdir -p $out/share/icons/hicolor
+    cp -r usr/share/icons/hicolor/* $out/share/icons/hicolor/
+
+    # XDG desktop item
+    cp -r usr/share/applications $out/share/applications
+
+    # Symlink wrapper
+    mkdir -p $out/bin
+    ln -s $out/share/draw.io/drawio $out/bin/drawio
+
+    # Update binary path
+    substituteInPlace $out/share/applications/drawio.desktop \
+      --replace /opt/draw.io/drawio $out/bin/drawio
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A desktop application for creating diagrams";
+    homepage = https://about.draw.io/;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ danieldk ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/drawpile/default.nix b/nixpkgs/pkgs/applications/graphics/drawpile/default.nix
new file mode 100644
index 000000000000..46bfe64dd030
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/drawpile/default.nix
@@ -0,0 +1,96 @@
+{ lib
+, mkDerivation
+, fetchurl
+, cmake
+, extra-cmake-modules
+
+# common deps
+, karchive
+
+# client deps
+, qtbase
+, qtmultimedia
+, qtsvg
+, qttools
+
+# optional client deps
+, giflib
+, kdnssd
+, libvpx
+, miniupnpc
+, qtx11extras # kis
+
+# optional server deps
+, libmicrohttpd
+, libsodium
+
+# options
+, buildClient ? true
+, buildServer ? true
+, buildServerGui ? true # if false builds a headless server
+, buildExtraTools ? false
+, enableKisTablet ? false # enable improved graphics tablet support
+}:
+
+with lib;
+
+let
+  commonDeps = [
+    karchive
+  ];
+  clientDeps = [
+    qtbase
+    qtmultimedia
+    qtsvg
+    qttools
+    # optional:
+    giflib # gif animation export support
+    kdnssd # local server discovery with Zeroconf
+    libvpx # WebM video export
+    miniupnpc # automatic port forwarding
+  ];
+  serverDeps = [
+    # optional:
+    libmicrohttpd # HTTP admin api
+    libsodium # ext-auth support
+  ];
+  kisDeps = [
+    qtx11extras
+  ];
+
+in mkDerivation rec {
+  pname = "drawpile";
+  version = "2.1.11";
+
+  src = fetchurl {
+    url = "https://drawpile.net/files/src/drawpile-${version}.tar.gz";
+    sha256 = "00r5vzracvjk369rri2jxzgfaa1ll4qj5gdmzgflvidz8420bcvm";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    extra-cmake-modules
+  ];
+  buildInputs =
+    commonDeps ++
+    optionals buildClient      clientDeps ++
+    optionals buildServer      serverDeps ++
+    optionals enableKisTablet  kisDeps    ;
+
+  cmakeFlags =
+    optional (!buildClient    )  "-DCLIENT=off" ++
+    optional (!buildServer    )  "-DSERVER=off" ++
+    optional (!buildServerGui )  "-DSERVERGUI=off" ++
+    optional ( buildExtraTools)  "-DTOOLS=on" ++
+    optional ( enableKisTablet)  "-DKIS_TABLET=on";
+
+  meta = {
+    description = "A collaborative drawing program that allows multiple users to sketch on the same canvas simultaneously";
+    homepage = https://drawpile.net/;
+    downloadPage = https://drawpile.net/download/;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ fgaz ];
+    platforms = platforms.unix;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/graphics/epeg/default.nix b/nixpkgs/pkgs/applications/graphics/epeg/default.nix
new file mode 100644
index 000000000000..3b7bdfb8efc2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/epeg/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, pkgconfig, libtool, autoconf, automake
+, libjpeg, libexif
+}:
+
+stdenv.mkDerivation rec {
+  pname = "epeg";
+  version = "0.9.2";
+
+  src = fetchFromGitHub {
+    owner = "mattes";
+    repo = "epeg";
+    rev = "v${version}";
+    sha256 = "14bjl9v6zzac4df25gm3bkw3n0mza5iazazsi65gg3m6661x6c5g";
+  };
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ pkgconfig libtool autoconf automake ];
+
+  propagatedBuildInputs = [ libjpeg libexif ];
+
+  preConfigure = ''
+    ./autogen.sh
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/mattes/epeg;
+    description = "Insanely fast JPEG/ JPG thumbnail scaling";
+    platforms = platforms.linux ++ platforms.darwin;
+    license = {
+      url = "https://github.com/mattes/epeg#license";
+    };
+    maintainers = with maintainers; [ nh2 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/exrdisplay/default.nix b/nixpkgs/pkgs/applications/graphics/exrdisplay/default.nix
new file mode 100644
index 000000000000..562fb8c11dc3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/exrdisplay/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, pkgconfig, fltk, openexr, libGLU_combined, ctl }:
+
+stdenv.mkDerivation {
+  name ="openexr_viewers-2.2.1";
+
+  src = fetchurl {
+    url =  "mirror://savannah/openexr/openexr_viewers-2.2.1.tar.gz";
+    sha256 = "1ixx2wbjp4rvsf7h3bkja010gl1ihjrcjzy7h20jnn47ikg12vj8";
+  };
+
+  configurePhase = ''
+    ./configure --prefix=$out --with-fltk-config=${fltk}/bin/fltk-config
+  '';
+
+  buildPhase = ''
+    make LDFLAGS="`fltk-config --ldflags` -lGL -lfltk_gl"
+  '';
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ openexr fltk libGLU_combined ctl ];
+
+  meta = {
+    description = "Application for viewing OpenEXR images on a display at various exposure settings";
+    homepage = http://openexr.com;
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/exrtools/default.nix b/nixpkgs/pkgs/applications/graphics/exrtools/default.nix
new file mode 100644
index 000000000000..c8928540bb65
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/exrtools/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, pkgconfig, openexr, libpng12, libjpeg }:
+
+stdenv.mkDerivation rec {
+  pname = "exrtools";
+  version = "0.4";
+
+  src = fetchurl {
+    url =  "http://scanline.ca/exrtools/${pname}-${version}.tar.gz";
+    sha256 = "0jpkskqs1yjiighab4s91jy0c0qxcscwadfn94xy2mm2bx2qwp4z";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ stdenv openexr libpng12 libjpeg ];
+
+  meta = with stdenv.lib; {
+    description = "Collection of utilities for manipulating OpenEXR images";
+    homepage = http://scanline.ca/exrtools;
+    platforms = platforms.linux;
+    license = licenses.mit;
+    maintainers = [ maintainers.juliendehos ];
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/graphics/fbida/default.nix b/nixpkgs/pkgs/applications/graphics/fbida/default.nix
new file mode 100644
index 000000000000..f5560a9b2032
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/fbida/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, libjpeg, libexif, libungif, libtiff, libpng, libwebp, libdrm
+, pkgconfig, freetype, fontconfig, which, imagemagick, curl, sane-backends, libXpm
+, epoxy, poppler, mesa, lirc }:
+
+stdenv.mkDerivation rec {
+  name = "fbida-2.14";
+
+  src = fetchurl {
+    url = "http://dl.bytesex.org/releases/fbida/${name}.tar.gz";
+    sha256 = "0f242mix20rgsqz1llibhsz4r2pbvx6k32rmky0zjvnbaqaw1dwm";
+  };
+
+  nativeBuildInputs = [ pkgconfig which ];
+  buildInputs = [
+    libexif libjpeg libpng libungif freetype fontconfig libtiff libwebp
+    imagemagick curl sane-backends libdrm libXpm epoxy poppler lirc
+    mesa
+  ];
+
+  makeFlags = [ "prefix=$(out)" "verbose=yes" "STRIP=" "JPEG_VER=62" ];
+
+  patchPhase = ''
+    sed -e 's@ cpp\>@ gcc -E -@' -i GNUmakefile
+    sed -e 's@$(HAVE_LINUX_FB_H)@yes@' -i GNUmakefile
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Image viewing and manipulation programs";
+    homepage = https://www.kraxel.org/blog/linux/fbida/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ pSub ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/feh/default.nix b/nixpkgs/pkgs/applications/graphics/feh/default.nix
new file mode 100644
index 000000000000..fef068eaf0ff
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/feh/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchurl, makeWrapper
+, xorg, imlib2, libjpeg, libpng
+, curl, libexif, perlPackages }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  pname = "feh";
+  version = "3.2.1";
+
+  src = fetchurl {
+    url = "https://feh.finalrewind.org/${pname}-${version}.tar.bz2";
+    sha256 = "070axq8jpibcabmjfv4fmjmpk3k349vzvh4qhsi4n62bkcwl35wg";
+  };
+
+  outputs = [ "out" "man" "doc" ];
+
+  nativeBuildInputs = [ makeWrapper xorg.libXt ];
+
+  buildInputs = [ xorg.libX11 xorg.libXinerama imlib2 libjpeg libpng curl libexif ];
+
+  makeFlags = [
+    "PREFIX=${placeholder "out"}" "exif=1"
+  ] ++ optional stdenv.isDarwin "verscmp=0";
+
+  installTargets = [ "install" ];
+  postInstall = ''
+    wrapProgram "$out/bin/feh" --prefix PATH : "${libjpeg.bin}/bin" \
+                               --add-flags '--theme=feh'
+  '';
+
+  checkInputs = [ perlPackages.perl perlPackages.TestCommand ];
+  preCheck = ''
+    export PERL5LIB="${perlPackages.TestCommand}/${perlPackages.perl.libPrefix}"
+  '';
+  postCheck = ''
+    unset PERL5LIB
+  '';
+
+  doCheck = true;
+
+  meta = {
+    description = "A light-weight image viewer";
+    homepage = "https://feh.finalrewind.org/";
+    license = licenses.mit;
+    maintainers = with maintainers; [ viric willibutz globin ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/fig2dev/default.nix b/nixpkgs/pkgs/applications/graphics/fig2dev/default.nix
new file mode 100644
index 000000000000..ae38730226a4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/fig2dev/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, ghostscript, libpng } :
+
+let
+  version = "3.2.7a";
+
+in stdenv.mkDerivation {
+  pname = "fig2dev";
+  inherit version;
+
+  src = fetchurl {
+    url = "mirror://sourceforge/mcj/fig2dev-${version}.tar.xz";
+    sha256 = "0a7vkfl38fvkhg3na5gr9c4fskas9wbs84y9djg85nzwbshik8mx";
+  };
+
+  buildInputs = [ libpng ];
+
+  GSEXE="${ghostscript}/bin/gs";
+
+  meta = with stdenv.lib; {
+    description = "Tool to convert Xfig files to other formats";
+    homepage = http://mcj.sourceforge.net/;
+    license = licenses.xfig;
+    platforms = platforms.linux;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/graphics/fondo/default.nix b/nixpkgs/pkgs/applications/graphics/fondo/default.nix
new file mode 100644
index 000000000000..920b529d61c3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/fondo/default.nix
@@ -0,0 +1,72 @@
+{ stdenv
+, fetchFromGitHub
+, fetchpatch
+, pantheon
+, pkgconfig
+, meson
+, ninja
+, python3
+, glib
+, gsettings-desktop-schemas
+, gtk3
+, libgee
+, json-glib
+, glib-networking
+, libsoup
+, libunity
+, wrapGAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "fondo";
+  version = "1.3.2";
+
+  src = fetchFromGitHub {
+    owner = "calo001";
+    repo = pname;
+    rev = version;
+    sha256 = "0w7qai261l9m7ckzxc2gj3ywa55wm6p5br1xdk7607ql44lfpgba";
+  };
+
+  nativeBuildInputs = [
+    meson
+    ninja
+    pantheon.vala
+    pkgconfig
+    python3
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    glib
+    glib-networking
+    gsettings-desktop-schemas
+    gtk3
+    json-glib
+    libgee
+    libsoup
+    libunity
+    pantheon.granite
+  ];
+
+  patches = [
+    # Fix hardcoded FHS gsettings path
+    (fetchpatch {
+      url = "https://github.com/calo001/fondo/commit/98afdd834201321a3242f0b53bfba4b2ffa04a4c.patch";
+      sha256 = "0vvgbgjja6vyrk6in3sgv8jbl4bwxkm6fhllgjzq7r65gkj4jg79";
+    })
+  ];
+
+  postPatch = ''
+    chmod +x meson/post_install.py
+    patchShebangs meson/post_install.py
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Find the most beautiful wallpapers for your desktop";
+    homepage = https://github.com/calo001/fondo;
+    license = licenses.agpl3Plus;
+    maintainers = with maintainers; [ worldofpeace ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/fontmatrix/default.nix b/nixpkgs/pkgs/applications/graphics/fontmatrix/default.nix
new file mode 100644
index 000000000000..3b8662976032
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/fontmatrix/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, cmake, qt4 }:
+
+stdenv.mkDerivation rec {
+  pname = "fontmatrix";
+  version = "0.6.0";
+
+  src = fetchFromGitHub {
+    owner = "fontmatrix";
+    repo = "fontmatrix";
+    rev = "v${version}";
+    sha256 = "0aqndj1jhm6hjpwmj1qm92z2ljh7w78a5ff5ag47qywqha1ngn05";
+  };
+
+  buildInputs = [ qt4 ];
+
+  nativeBuildInputs = [ cmake ];
+
+  hardeningDisable = [ "format" ];
+
+  meta = with stdenv.lib; {
+    description = "Fontmatrix is a free/libre font explorer for Linux, Windows and Mac";
+    homepage = https://github.com/fontmatrix/fontmatrix;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/freecad/default.nix b/nixpkgs/pkgs/applications/graphics/freecad/default.nix
new file mode 100644
index 000000000000..ee7586709dcb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/freecad/default.nix
@@ -0,0 +1,75 @@
+{ stdenv, mkDerivation, fetchurl, fetchpatch, cmake, ninja, coin3d, xercesc, ode
+, eigen, qtbase, qttools, qtwebkit, opencascade-occt, gts, hdf5, vtk, medfile
+, zlib, python3Packages, swig, gfortran, libXmu, soqt, libf2c, libGLU
+, makeWrapper, pkgconfig, mpi ? null }:
+
+assert mpi != null;
+
+let
+  pythonPackages = python3Packages;
+in mkDerivation rec {
+  pname = "freecad";
+  version = "0.18.3";
+
+  src = fetchurl {
+    url = "https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz";
+    sha256 = "07j7azgnicmd8cqnyskp15y44ykgj5qqz5y3w1jdynrv3yrvk1kz";
+  };
+
+  nativeBuildInputs = [ cmake ninja pkgconfig pythonPackages.pyside2-tools ];
+  buildInputs = [ cmake coin3d xercesc ode eigen opencascade-occt gts
+    zlib swig gfortran soqt libf2c makeWrapper mpi vtk hdf5 medfile
+    libGLU libXmu qtbase qttools qtwebkit
+  ] ++ (with pythonPackages; [
+    matplotlib pycollada shiboken2 pyside2 pyside2-tools pivy python boost
+  ]);
+
+  # Fix missing app icon on Wayland. Has been upstreamed and should be safe to
+  # remove in versions >= 0.19
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/FreeCAD/FreeCAD/commit/c4d2a358ca125d51d059dfd72dcbfba326196dfc.patch";
+      sha256 = "0yqc9zrxgi2c2xcidm8wh7a9yznkphqvjqm9742qm5fl20p8gl4h";
+    })
+  ];
+
+  cmakeFlags = [
+    "-DBUILD_QT5=ON"
+    "-DSHIBOKEN_INCLUDE_DIR=${pythonPackages.shiboken2}/include"
+    "-DSHIBOKEN_LIBRARY=Shiboken2::libshiboken"
+    ("-DPYSIDE_INCLUDE_DIR=${pythonPackages.pyside2}/include"
+      + ";${pythonPackages.pyside2}/include/PySide2/QtCore"
+      + ";${pythonPackages.pyside2}/include/PySide2/QtWidgets"
+      + ";${pythonPackages.pyside2}/include/PySide2/QtGui"
+      )
+    "-DPYSIDE_LIBRARY=PySide2::pyside2"
+  ];
+
+  # This should work on both x86_64, and i686 linux
+  preBuild = ''
+    export NIX_LDFLAGS="-L${gfortran.cc}/lib64 -L${gfortran.cc}/lib $NIX_LDFLAGS";
+  '';
+
+  # Their main() removes PYTHONPATH=, and we rely on it.
+  preConfigure = ''
+    sed '/putenv("PYTHONPATH/d' -i src/Main/MainGui.cpp
+
+    qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH")
+  '';
+
+  qtWrapperArgs = [
+    "--set COIN_GL_NO_CURRENT_CONTEXT_CHECK 1"
+  ];
+
+  postFixup = ''
+    mv $out/share/doc $out
+  '';
+
+  meta = with stdenv.lib; {
+    description = "General purpose Open Source 3D CAD/MCAD/CAx/CAE/PLM modeler";
+    homepage = "https://www.freecadweb.org/";
+    license = licenses.lgpl2Plus;
+    maintainers = with maintainers; [ viric gebner ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/freepv/default.nix b/nixpkgs/pkgs/applications/graphics/freepv/default.nix
new file mode 100644
index 000000000000..0bd3421f1b10
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/freepv/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, libjpeg, libGLU_combined, freeglut, zlib, cmake, libX11, libxml2, libpng,
+  libXxf86vm }:
+
+stdenv.mkDerivation {
+  name = "freepv-0.3.0";
+
+  src = fetchurl {
+    url = mirror://sourceforge/freepv/freepv-0.3.0.tar.gz;
+    sha256 = "1w19abqjn64w47m35alg7bcdl1p97nf11zn64cp4p0dydihmhv56";
+  };
+
+  buildInputs = [ libjpeg libGLU_combined freeglut zlib cmake libX11 libxml2 libpng
+    libXxf86vm ];
+
+  postPatch = ''
+    sed -i -e '/GECKO/d' CMakeLists.txt
+    sed -i -e '/mozilla/d' src/CMakeLists.txt
+    sed -i -e '1i \
+      #include <cstdio>' src/libfreepv/OpenGLRenderer.cpp
+    sed -i -e '1i \
+      #include <cstring>' src/libfreepv/Image.cpp
+    substituteInPlace src/libfreepv/Action.h \
+      --replace NULL nullptr
+    substituteInPlace src/libfreepv/pngReader.cpp \
+      --replace png_set_gray_1_2_4_to_8 png_set_expand_gray_1_2_4_to_8
+  '';
+
+  NIX_CFLAGS_COMPILE = "-fpermissive -Wno-narrowing";
+
+  meta = {
+    description = "Open source panorama viewer using GL";
+    homepage = http://freepv.sourceforge.net/;
+    license = [ stdenv.lib.licenses.lgpl21 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/fstl/default.nix b/nixpkgs/pkgs/applications/graphics/fstl/default.nix
new file mode 100644
index 000000000000..1d712a63fbdf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/fstl/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchFromGitHub, mkDerivation, qtbase, mesa_glu }:
+
+mkDerivation rec {
+  pname = "fstl";
+  version = "0.9.3";
+
+  buildInputs = [qtbase mesa_glu];
+
+  prePatch = ''
+    sed -i "s|/usr/bin|$out/bin|g" qt/fstl.pro
+  '';
+
+  preBuild = ''
+    qmake qt/fstl.pro
+  '';
+  
+  postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
+    mkdir -p $out/Applications
+    mv fstl.app $out/Applications
+  '';
+
+  src = fetchFromGitHub {
+    owner = "mkeeter";
+    repo = "fstl";
+    rev = "v" + version;
+    sha256 = "1j0y9xbf0ybrrnsmfzgpyyz6bi98xgzn9ivani424j01vffns892";
+  };
+
+  meta = with stdenv.lib; {
+    description = "The fastest STL file viewer";
+    homepage = "https://github.com/mkeeter/fstl";
+    license = licenses.mit;
+    platforms = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ tweber ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/gcolor2/default.nix b/nixpkgs/pkgs/applications/graphics/gcolor2/default.nix
new file mode 100644
index 000000000000..2762748bc1ad
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gcolor2/default.nix
@@ -0,0 +1,35 @@
+{stdenv, fetchurl, gtk2, perlPackages, pkgconfig } :
+
+let version = "0.4"; in
+stdenv.mkDerivation {
+  pname = "gcolor2";
+  inherit version;
+  arch = if stdenv.hostPlatform.system == "x86_64-linux" then "amd64" else "386";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/gcolor2/gcolor2/${version}/gcolor2-${version}.tar.bz2";
+    sha1 = "e410a52dcff3d5c6c3d448b68a026d04ccd744be";
+
+  };
+
+  preConfigure = ''
+    sed -i 's/\[:space:\]/[&]/g' configure
+  '';
+
+  # from https://github.com/PhantomX/slackbuilds/tree/master/gcolor2/patches
+  patches = if stdenv.hostPlatform.system == "x86_64-linux" then
+        [ ./gcolor2-amd64.patch ] else
+        [ ];
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ gtk2 ]
+    ++ (with perlPackages; [ perl XMLParser ]);
+
+  meta = {
+    description = "Simple GTK 2 color selector";
+    homepage = http://gcolor2.sourceforge.net/;
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [ notthemessiah ];
+    platforms = with stdenv.lib.platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/gcolor2/gcolor2-amd64.patch b/nixpkgs/pkgs/applications/graphics/gcolor2/gcolor2-amd64.patch
new file mode 100644
index 000000000000..cd06a8315f98
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gcolor2/gcolor2-amd64.patch
@@ -0,0 +1,46 @@
+diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN gcolor2-0.4.orig/src/callbacks.c gcolor2-0.4/src/callbacks.c
+--- gcolor2-0.4.orig/src/callbacks.c	2005-07-12 14:06:12.000000000 -0400
++++ gcolor2-0.4/src/callbacks.c	2007-02-17 19:19:38.000000000 -0500
+@@ -4,6 +4,9 @@
+ 
+ #include <gtk/gtk.h>
+ #include <stdio.h>
++#include <string.h>
++#include <glib.h>
++#include <glib/gprintf.h>
+ 
+ #include "callbacks.h"
+ #include "interface.h"
+@@ -172,6 +175,9 @@ void on_copy_color_to_clipboard_activate
+ 	gtk_clipboard_set_text (cb, hex, strlen (hex));
+ }
+ 
++void add_rgb_file (gchar *filename, gchar *type);
++gchar* get_system_file (void);
++
+ void on_show_system_colors_activate (GtkMenuItem *menuitem, gpointer user_data)
+ {
+ 	if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)))
+@@ -266,6 +272,8 @@ void on_save_button_clicked (GtkButton *
+ 	gtk_widget_destroy (savedialog);
+ }
+ 
++void add_list_color (gchar *spec, gchar *name, gchar *type, gboolean is_new_color);
++
+ void add_color_to_treeview ()
+ {
+ 	GtkTreeView      *treeview;
+diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN gcolor2-0.4.orig/src/main.c gcolor2-0.4/src/main.c
+--- gcolor2-0.4.orig/src/main.c	2005-07-11 10:55:49.000000000 -0400
++++ gcolor2-0.4/src/main.c	2007-02-17 19:18:23.000000000 -0500
+@@ -4,6 +4,10 @@
+ 
+ #include <gtk/gtk.h>
+ #include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <glib.h>
++#include <glib/gprintf.h>
+ 
+ #include "interface.h"
+ #include "support.h"
diff --git a/nixpkgs/pkgs/applications/graphics/gcolor3/default.nix b/nixpkgs/pkgs/applications/graphics/gcolor3/default.nix
new file mode 100644
index 000000000000..c7555b612f7b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gcolor3/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitLab, meson, ninja, gettext, pkgconfig, libxml2, gtk3, hicolor-icon-theme, wrapGAppsHook }:
+
+let
+  version = "2.3.1";
+in stdenv.mkDerivation {
+  pname = "gcolor3";
+  inherit version;
+
+  src = fetchFromGitLab {
+    domain = "gitlab.gnome.org";
+    owner = "World";
+    repo = "gcolor3";
+    rev = "v${version}";
+    sha256 = "10cfzlkflwkb7f51rnrxmgxpfryh1qzvqaydj6lffjq9zvnhigg7";
+  };
+
+  nativeBuildInputs = [ meson ninja gettext pkgconfig libxml2 wrapGAppsHook ];
+
+  buildInputs = [ gtk3 hicolor-icon-theme ];
+
+  postPatch = ''
+    chmod +x meson_install.sh # patchShebangs requires executable file
+    patchShebangs meson_install.sh
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A simple color chooser written in GTK3";
+    homepage = https://www.hjdskes.nl/projects/gcolor3/;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ jtojnar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/geeqie/default.nix b/nixpkgs/pkgs/applications/graphics/geeqie/default.nix
new file mode 100644
index 000000000000..4275c6f0dcfd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/geeqie/default.nix
@@ -0,0 +1,69 @@
+{ stdenv, fetchurl, pkgconfig, autoconf, automake, gettext, intltool
+, gtk3, lcms2, exiv2, libchamplain, clutter-gtk, ffmpegthumbnailer, fbida
+, wrapGAppsHook, fetchpatch
+}:
+
+stdenv.mkDerivation rec {
+  pname = "geeqie";
+  version = "1.4";
+
+  src = fetchurl {
+    url = "http://geeqie.org/${pname}-${version}.tar.xz";
+    sha256 = "0ciygvcxb78pqg59r6p061mkbpvkgv2rv3r79j3kgv3kalb3ln2w";
+  };
+
+  patches = [
+    # Do not build the changelog as this requires markdown.
+    (fetchpatch {
+      name = "geeqie-1.4-goodbye-changelog.patch";
+      url = "https://src.fedoraproject.org/rpms/geeqie/raw/132fb04a1a5e74ddb333d2474f7edb9a39dc8d27/f/geeqie-1.4-goodbye-changelog.patch";
+      sha256 = "00a35dds44kjjdqsbbfk0x9y82jspvsbpm2makcm1ivzlhjjgszn";
+    })
+    # Fixes build with exiv2 0.27.1
+    (fetchpatch {
+      name = "geeqie-exiv2-0.27.patch";
+      url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/geeqie-exiv2-0.27.patch?h=packages/geeqie&id=dee28a8b3e9039b9cd6927b5a93ef2a07cd8271d";
+      sha256 = "05skpbyp8pcq92psgijyccc8liwfy2cpwprw6m186pf454yb5y9p";
+    })
+  ];
+
+  preConfigure = "./autogen.sh";
+
+  nativeBuildInputs = [ pkgconfig autoconf automake gettext intltool
+    wrapGAppsHook
+  ];
+  buildInputs = [
+    gtk3 lcms2 exiv2 libchamplain clutter-gtk ffmpegthumbnailer fbida
+  ];
+
+  postInstall = ''
+    # Allow geeqie to find exiv2 and exiftran, necessary to
+    # losslessly rotate JPEG images.
+    sed -i $out/lib/geeqie/geeqie-rotate \
+        -e '1 a export PATH=${stdenv.lib.makeBinPath [ exiv2 fbida ]}:$PATH'
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Lightweight GTK based image viewer";
+
+    longDescription =
+      ''
+        Geeqie is a lightweight GTK based image viewer for Unix like
+        operating systems.  It features: EXIF, IPTC and XMP metadata
+        browsing and editing interoperability; easy integration with other
+        software; geeqie works on files and directories, there is no need to
+        import images; fast preview for many raw image formats; tools for
+        image comparison, sorting and managing photo collection.  Geeqie was
+        initially based on GQview.
+      '';
+
+    license = licenses.gpl2Plus;
+
+    homepage = http://geeqie.sourceforge.net;
+
+    maintainers = with maintainers; [ jfrankenau pSub ];
+    platforms = platforms.gnu ++ platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/gimp/default.nix b/nixpkgs/pkgs/applications/graphics/gimp/default.nix
new file mode 100644
index 000000000000..e3994b1b4128
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gimp/default.nix
@@ -0,0 +1,86 @@
+{ stdenv, fetchurl, substituteAll, pkgconfig, intltool, babl, gegl, gtk2, glib, gdk-pixbuf, isocodes
+, pango, cairo, freetype, fontconfig, lcms, libpng, libjpeg, poppler, poppler_data, libtiff
+, libmng, librsvg, libwmf, zlib, libzip, ghostscript, aalib, shared-mime-info
+, python2Packages, libexif, gettext, xorg, glib-networking, libmypaint, gexiv2
+, harfbuzz, mypaint-brushes, libwebp, libheif, libgudev, openexr
+, AppKit, Cocoa, gtk-mac-integration-gtk2 }:
+
+let
+  inherit (python2Packages) pygtk wrapPython python;
+in stdenv.mkDerivation rec {
+  pname = "gimp";
+  version = "2.10.12";
+
+  src = fetchurl {
+    url = "http://download.gimp.org/pub/gimp/v${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.bz2";
+    sha256 = "0wdcr8d2ink4swn5r4v13bsiya6s3xm4ya97sdbhs4l40y7bb03x";
+  };
+
+  nativeBuildInputs = [ pkgconfig intltool gettext wrapPython ];
+  propagatedBuildInputs = [ gegl ]; # needed by gimp-2.0.pc
+  buildInputs = [
+    babl gegl gtk2 glib gdk-pixbuf pango cairo gexiv2 harfbuzz isocodes
+    freetype fontconfig lcms libpng libjpeg poppler poppler_data libtiff openexr
+    libmng librsvg libwmf zlib libzip ghostscript aalib shared-mime-info libwebp libheif
+    python pygtk libexif xorg.libXpm glib-networking libmypaint mypaint-brushes
+  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+    AppKit Cocoa gtk-mac-integration-gtk2
+  ] ++ stdenv.lib.optionals stdenv.isLinux [ libgudev ];
+
+  pythonPath = [ pygtk ];
+
+  # Check if librsvg was built with --disable-pixbuf-loader.
+  PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = "${librsvg}/${gdk-pixbuf.moduleDir}";
+
+  preConfigure = ''
+    # The check runs before glib-networking is registered
+    export GIO_EXTRA_MODULES="${glib-networking}/lib/gio/modules:$GIO_EXTRA_MODULES"
+  '';
+
+  patches = [
+    # to remove compiler from the runtime closure, reference was retained via
+    # gimp --version --verbose output
+    (substituteAll {
+      src = ./remove-cc-reference.patch;
+      cc_version = stdenv.cc.cc.name;
+    })
+  ];
+
+  postFixup = ''
+    wrapPythonProgramsIn $out/lib/gimp/${passthru.majorVersion}/plug-ins/
+    wrapProgram $out/bin/gimp-${stdenv.lib.versions.majorMinor version} \
+      --prefix PYTHONPATH : "$PYTHONPATH" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE"
+  '';
+
+  passthru = rec {
+    # The declarations for `gimp-with-plugins` wrapper,
+    # used for determining plug-in installation paths
+    majorVersion = "${stdenv.lib.versions.major version}.0";
+    targetPluginDir = "lib/gimp/${majorVersion}/plug-ins";
+    targetScriptDir = "lib/gimp/${majorVersion}/scripts";
+
+    # probably its a good idea to use the same gtk in plugins ?
+    gtk = gtk2;
+  };
+
+  configureFlags = [
+    "--without-webkit" # old version is required
+    "--with-bug-report-url=https://github.com/NixOS/nixpkgs/issues/new"
+    "--with-icc-directory=/run/current-system/sw/share/color/icc"
+  ];
+
+  # on Darwin,
+  # test-eevl.c:64:36: error: initializer element is not a compile-time constant
+  doCheck = !stdenv.isDarwin;
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "The GNU Image Manipulation Program";
+    homepage = https://www.gimp.org/;
+    maintainers = with maintainers; [ jtojnar ];
+    license = licenses.gpl3Plus;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/gimp/plugins/default.nix b/nixpkgs/pkgs/applications/graphics/gimp/plugins/default.nix
new file mode 100644
index 000000000000..2c520f21f848
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gimp/plugins/default.nix
@@ -0,0 +1,236 @@
+# install these packages into your profile. Then add
+# ~/.nix-profile/gimp-version-plugins to your plugin list you can find at
+# preferences -> Folders -> Plug-ins
+# same applies for the scripts
+
+{ config, pkgs, gimp }:
+let
+  inherit (pkgs) stdenv fetchurl pkgconfig intltool glib fetchFromGitHub;
+  inherit (gimp) targetPluginDir targetScriptDir;
+
+  pluginDerivation = a: stdenv.mkDerivation ({
+    prePhases = "extraLib";
+    extraLib = ''
+      installScripts(){
+        mkdir -p $out/${targetScriptDir};
+        for p in "$@"; do cp "$p" $out/${targetScriptDir}; done
+      }
+      installPlugins(){
+        mkdir -p $out/${targetPluginDir};
+        for p in "$@"; do cp "$p" $out/${targetPluginDir}; done
+      }
+    '';
+  }
+  // a
+  // {
+      name = "gimp-plugin-${a.name or "${a.pname}-${a.version}"}";
+      buildInputs = [ gimp gimp.gtk glib ] ++ (a.buildInputs or []);
+      nativeBuildInputs = [ pkgconfig intltool ] ++ (a.nativeBuildInputs or []);
+    }
+  );
+
+  scriptDerivation = {name, src} : pluginDerivation {
+    inherit name; phases = "extraLib installPhase";
+    installPhase = "installScripts ${src}";
+  };
+
+in
+
+stdenv.lib.makeScope pkgs.newScope (self: with self; {
+  gap = pluginDerivation {
+    /* menu:
+       Video
+    */
+    name = "gap-2.6.0";
+    src = fetchurl {
+      url = https://ftp.gimp.org/pub/gimp/plug-ins/v2.6/gap/gimp-gap-2.6.0.tar.bz2;
+      sha256 = "1jic7ixcmsn4kx2cn32nc5087rk6g8xsrz022xy11yfmgvhzb0ql";
+    };
+    patchPhase = ''
+      sed -e 's,^\(GIMP_PLUGIN_DIR=\).*,\1'"$out/${gimp.name}-plugins", \
+       -e 's,^\(GIMP_DATA_DIR=\).*,\1'"$out/share/${gimp.name}", -i configure
+    '';
+    hardeningDisable = [ "format" ];
+    meta = with stdenv.lib; {
+      description = "The GIMP Animation Package";
+      homepage = https://www.gimp.org;
+      # The main code is given in GPLv3, but it has ffmpeg in it, and I think ffmpeg license
+      # falls inside "free".
+      license = with licenses; [ gpl3 free ];
+    };
+  };
+
+  fourier = pluginDerivation rec {
+    /* menu:
+       Filters/Generic/FFT Forward
+       Filters/Generic/FFT Inverse
+    */
+    name = "fourier-0.4.1";
+    buildInputs = with pkgs; [ fftw ];
+    postInstall = "fail";
+    installPhase = "installPlugins fourier";
+    src = fetchurl {
+      url = "http://registry.gimp.org/files/${name}.tar.gz";
+      sha256 = "1pr3y3zl9w8xs1circdrxpr98myz9m8wfzy022al79z4pdanwvs1";
+    };
+  };
+
+  focusblur = pluginDerivation rec {
+    /* menu:
+       Blur/Focus Blur
+    */
+    name = "focusblur-3.2.6";
+    buildInputs = with pkgs; [ fftwSinglePrec ];
+    patches = [ ./patches/focusblur-glib.patch ];
+    postInstall = "fail";
+    installPhase = "installPlugins src/focusblur";
+    src = fetchurl {
+      url = "http://registry.gimp.org/files/${name}.tar.bz2";
+      sha256 = "1gqf3hchz7n7v5kpqkhqh8kwnxbsvlb5cr2w2n7ngrvl56f5xs1h";
+    };
+    meta.broken = true;
+  };
+
+  resynthesizer = pluginDerivation rec {
+    /* menu:
+      Edit/Fill with pattern seamless...
+      Filters/Enhance/Heal selection...
+      Filters/Enhance/Heal transparency...
+      Filters/Enhance/Sharpen by synthesis...
+      Filters/Enhance/Uncrop...
+      Filters/Map/Style...
+      Filters/Render/Texture...
+    */
+    pname = "resynthesizer";
+    version = "2.0.3";
+    buildInputs = with pkgs; [ fftw ];
+    nativeBuildInputs = with pkgs; [ autoreconfHook ];
+    makeFlags = [ "GIMP_LIBDIR=${placeholder "out"}/lib/gimp/2.0" ];
+    src = fetchFromGitHub {
+      owner = "bootchk";
+      repo = "resynthesizer";
+      rev = "v${version}";
+      sha256 = "1jwc8bhhm21xhrgw56nzbma6fwg59gc8anlmyns7jdiw83y0zx3j";
+    };
+  };
+
+  texturize = pluginDerivation {
+    name = "texturize-2.2.2017-07-28";
+    src = fetchFromGitHub {
+      owner = "lmanul";
+      repo = "gimp-texturize";
+      rev = "de4367f71e40fe6d82387eaee68611a80a87e0e1";
+      sha256 = "1zzvbczly7k456c0y6s92a1i8ph4ywmbvdl8i4rcc29l4qd2z8fw";
+    };
+    installPhase = "installPlugins src/texturize";
+    meta.broken = true; # https://github.com/lmanul/gimp-texturize/issues/1
+  };
+
+  waveletSharpen = pluginDerivation {
+    /* menu:
+      Filters/Enhance/Wavelet sharpen
+    */
+    name = "wavelet-sharpen-0.1.2";
+    src = fetchurl {
+      url = http://registry.gimp.org/files/wavelet-sharpen-0.1.2.tar.gz;
+      sha256 = "0vql1k67i21g5ivaa1jh56rg427m0icrkpryrhg75nscpirfxxqw";
+    };
+    installPhase = "installPlugins src/wavelet-sharpen"; # TODO translations are not copied .. How to do this on nix?
+  };
+
+  lqrPlugin = pluginDerivation {
+    /* menu:
+       Layer/Liquid Rescale
+    */
+    name = "lqr-plugin-0.6.1";
+    buildInputs = with pkgs; [ liblqr1 ];
+    src = fetchurl {
+      url = http://registry.gimp.org/files/gimp-lqr-plugin-0.6.1.tar.bz2;
+      sha256 = "00hklkpcimcbpjly4rjhfipaw096cpy768g9wixglwrsyqhil7l9";
+    };
+    #postInstall = ''mkdir -p $out/nix-support; echo "${liblqr1}" > "$out/nix-support/propagated-user-env-packages"'';
+    installPhase = "installPlugins src/gimp-lqr-plugin";
+  };
+
+  gmic = pkgs.gmic-qt.override {
+    variant = "gimp";
+  };
+
+  ufraw = pkgs.ufraw.gimpPlugin;
+
+  gimplensfun = pluginDerivation rec {
+    version = "unstable-2018-10-21";
+    name = "gimplensfun-${version}";
+
+    src = fetchFromGitHub {
+      owner = "seebk";
+      repo = "GIMP-Lensfun";
+      rev = "1c5a5c1534b5faf098b7441f8840d22835592f17";
+      sha256 = "1jj3n7spkjc63aipwdqsvq9gi07w13bb1v8iqzvxwzld2kxa3c8w";
+    };
+
+    buildInputs = with pkgs; [ lensfun gexiv2 ];
+
+    installPhase = "
+      installPlugins gimp-lensfun
+    ";
+
+    meta = {
+      description = "GIMP plugin to correct lens distortion using the lensfun library and database";
+
+      homepage = http://lensfun.sebastiankraft.net/;
+
+      license = stdenv.lib.licenses.gpl3Plus;
+      maintainers = [ ];
+      platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;
+    };
+  };
+
+  /* =============== simple script files ==================== */
+
+  # also have a look at enblend-enfuse in all-packages.nix
+  exposureBlend = scriptDerivation {
+    name = "exposure-blend";
+    src = fetchurl {
+      url = http://tir.astro.utoledo.edu/jdsmith/code/eb/exposure-blend.scm;
+      sha256 = "1b6c9wzpklqras4wwsyw3y3jp6fjmhnnskqiwm5sabs8djknfxla";
+    };
+  };
+
+  lightning = scriptDerivation {
+    name = "Lightning";
+    src = fetchurl {
+      url = http://registry.gimp.org/files/Lightning.scm;
+      sha256 = "c14a8f4f709695ede3f77348728a25b3f3ded420da60f3f8de3944b7eae98a49";
+    };
+  };
+
+  /* space in name trouble ?
+
+  rainbowPlasma = scriptDerivation {
+    # http://registry.gimp.org/node/164
+    name = "rainbow-plasma";
+    src = fetchurl {
+      url = "http://registry.gimp.org/files/Rainbow Plasma.scm";
+      sha256 = "34308d4c9441f9e7bafa118af7ec9540f10ea0df75e812e2f3aa3fd7b5344c23";
+      name = "Rainbow-Plasma.scm"; # nix doesn't like spaces, does it?
+    };
+  };
+  */
+
+  /* doesn't seem to be working :-(
+  lightningGate = scriptDerivation {
+    # http://registry.gimp.org/node/153
+    name = "lightning-gate";
+    src = fetchurl {
+      url = http://registry.gimp.org/files/LightningGate.scm;
+      sha256 = "181w1zi9a99kn2mfxjp43wkwcgw5vbb6iqjas7a9mhm8p04csys2";
+    };
+  };
+  */
+
+} // stdenv.lib.optionalAttrs (config.allowAliases or true) {
+
+  resynthesizer2 = resynthesizer;
+
+})
diff --git a/nixpkgs/pkgs/applications/graphics/gimp/plugins/patches/focusblur-glib.patch b/nixpkgs/pkgs/applications/graphics/gimp/plugins/patches/focusblur-glib.patch
new file mode 100644
index 000000000000..b1079ab36604
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gimp/plugins/patches/focusblur-glib.patch
@@ -0,0 +1,200 @@
+ls diff --git focusblur-3.2.6/src/aaa.h focusblur-3.2.6/src/aaa.h
+index 4a6d90b..c74cab2 100644
+--- focusblur-3.2.6/src/aaa.h
++++ focusblur-3.2.6/src/aaa.h
+@@ -19,8 +19,7 @@
+ #ifndef __AAA_H__
+ #define __AAA_H__
+ 
+-#include <glib/gmacros.h>
+-#include <glib/gtypes.h>
++#include <glib.h>
+ 
+ 
+ G_BEGIN_DECLS
+diff --git focusblur-3.2.6/src/brush.h focusblur-3.2.6/src/brush.h
+index 685b253..8778fec 100644
+--- focusblur-3.2.6/src/brush.h
++++ focusblur-3.2.6/src/brush.h
+@@ -22,7 +22,7 @@
+ #ifndef __FOCUSBLUR_BRUSH_H__
+ #define __FOCUSBLUR_BRUSH_H__
+ 
+-#include <glib/gtypes.h>
++#include <glib.h>
+ #include "focusblurtypes.h"
+ 
+ G_BEGIN_DECLS
+diff --git focusblur-3.2.6/src/depthmap.h focusblur-3.2.6/src/depthmap.h
+index 78f5e99..baee540 100644
+--- focusblur-3.2.6/src/depthmap.h
++++ focusblur-3.2.6/src/depthmap.h
+@@ -22,7 +22,7 @@
+ #ifndef __FOCUSBLUR_DEPTHMAP_H__
+ #define __FOCUSBLUR_DEPTHMAP_H__
+ 
+-#include <glib/gtypes.h>
++#include <glib.h>
+ 
+ #include "focusblurtypes.h"
+ #include "focusblurenums.h"
+diff --git focusblur-3.2.6/src/diffusion.h focusblur-3.2.6/src/diffusion.h
+index 07ffe4b..3c1e4b9 100644
+--- focusblur-3.2.6/src/diffusion.h
++++ focusblur-3.2.6/src/diffusion.h
+@@ -23,7 +23,7 @@
+ #define __FOCUSBLUR_DIFFUSION_H__
+ 
+ 
+-#include <glib/gtypes.h>
++#include <glib.h>
+ 
+ #include "focusblur.h"
+ #include "focusblurtypes.h"
+diff --git focusblur-3.2.6/src/fftblur.h focusblur-3.2.6/src/fftblur.h
+index 124bcba..cd809fa 100644
+--- focusblur-3.2.6/src/fftblur.h
++++ focusblur-3.2.6/src/fftblur.h
+@@ -23,8 +23,7 @@
+ #define __FOCUSBLUR_FFTBLUR_H__
+ 
+ 
+-#include <glib/gmacros.h>
+-#include <glib/gtypes.h>
++#include <glib.h>
+ #include <libgimpwidgets/gimpwidgetstypes.h>
+ 
+ #include "focusblurparam.h"
+diff --git focusblur-3.2.6/src/fftblurbuffer.h focusblur-3.2.6/src/fftblurbuffer.h
+index b34d682..42e6380 100644
+--- focusblur-3.2.6/src/fftblurbuffer.h
++++ focusblur-3.2.6/src/fftblurbuffer.h
+@@ -28,8 +28,7 @@
+ #endif
+ #include <fftw3.h>
+ 
+-#include <glib/gmacros.h>
+-#include <glib/gtypes.h>
++#include <glib.h>
+ #include <gtk/gtkstyle.h>
+ #include <libgimp/gimptypes.h>
+ #include <libgimpwidgets/gimpwidgetstypes.h>
+diff --git focusblur-3.2.6/src/fftblurproc.h focusblur-3.2.6/src/fftblurproc.h
+index 495572d..10a34f4 100644
+--- focusblur-3.2.6/src/fftblurproc.h
++++ focusblur-3.2.6/src/fftblurproc.h
+@@ -23,8 +23,7 @@
+ #define __FOCUSBLUR_FFTBLUR_PROC_H__
+ 
+ 
+-#include <glib/gmacros.h>
+-#include <glib/gtypes.h>
++#include <glib.h>
+ 
+ #include "focusblurtypes.h"
+ 
+diff --git focusblur-3.2.6/src/focusblur.h focusblur-3.2.6/src/focusblur.h
+index 54ca40a..d7e13a6 100644
+--- focusblur-3.2.6/src/focusblur.h
++++ focusblur-3.2.6/src/focusblur.h
+@@ -22,7 +22,7 @@
+ #ifndef __FOCUSBLUR_H__
+ #define __FOCUSBLUR_H__
+ 
+-#include <glib/gmacros.h>
++#include <glib.h>
+ 
+ G_BEGIN_DECLS
+ 
+diff --git focusblur-3.2.6/src/focusblurparam.h focusblur-3.2.6/src/focusblurparam.h
+index 64c887b..32865b4 100644
+--- focusblur-3.2.6/src/focusblurparam.h
++++ focusblur-3.2.6/src/focusblurparam.h
+@@ -22,8 +22,7 @@
+ #ifndef __FOCUSBLUR_PARAM_H__
+ #define __FOCUSBLUR_PARAM_H__
+ 
+-#include <glib/gmacros.h>
+-#include <glib/gtypes.h>
++#include <glib.h>
+ #include <gtk/gtkstyle.h>
+ #include <libgimp/gimptypes.h>
+ 
+diff --git focusblur-3.2.6/src/focusblurstock.h focusblur-3.2.6/src/focusblurstock.h
+index 15f3603..cfc0567 100644
+--- focusblur-3.2.6/src/focusblurstock.h
++++ focusblur-3.2.6/src/focusblurstock.h
+@@ -22,7 +22,7 @@
+ #ifndef __FOCUSBLUR_STOCK_H__
+ #define __FOCUSBLUR_STOCK_H__
+ 
+-#include <glib/gtypes.h>
++#include <glib.h>
+ 
+ G_BEGIN_DECLS
+ 
+diff --git focusblur-3.2.6/src/focusblurtypes.h focusblur-3.2.6/src/focusblurtypes.h
+index 0954c60..1531c84 100644
+--- focusblur-3.2.6/src/focusblurtypes.h
++++ focusblur-3.2.6/src/focusblurtypes.h
+@@ -22,7 +22,7 @@
+ #ifndef __FOCUSBLUR_TYPES_H__
+ #define __FOCUSBLUR_TYPES_H__
+ 
+-#include <glib/gmacros.h>
++#include <glib.h>
+ 
+ 
+ G_BEGIN_DECLS
+diff --git focusblur-3.2.6/src/interface.h focusblur-3.2.6/src/interface.h
+index 6defd27..e819c60 100644
+--- focusblur-3.2.6/src/interface.h
++++ focusblur-3.2.6/src/interface.h
+@@ -22,7 +22,7 @@
+ #ifndef __FOCUSBLUR_INTERFACE_H__
+ #define __FOCUSBLUR_INTERFACE_H__
+ 
+-#include <glib/gtypes.h>
++#include <glib.h>
+ 
+ #include "focusblurtypes.h"
+ 
+diff --git focusblur-3.2.6/src/render.h focusblur-3.2.6/src/render.h
+index febbd24..a501f1e 100644
+--- focusblur-3.2.6/src/render.h
++++ focusblur-3.2.6/src/render.h
+@@ -24,7 +24,7 @@
+ 
+ #include "config.h"
+ 
+-#include <glib/gtypes.h>
++#include <glib.h>
+ //#include <libgimp/gimp.h>
+ #include <libgimp/gimpui.h>
+ 
+diff --git focusblur-3.2.6/src/shine.h focusblur-3.2.6/src/shine.h
+index c5a3621..86b4c09 100644
+--- focusblur-3.2.6/src/shine.h
++++ focusblur-3.2.6/src/shine.h
+@@ -22,7 +22,7 @@
+ #ifndef __FOCUSBLUR_SHINE_H__
+ #define __FOCUSBLUR_SHINE_H__
+ 
+-#include <glib/gtypes.h>
++#include <glib.h>
+ #include <libgimp/gimptypes.h>
+ 
+ #include "focusblurtypes.h"
+diff --git focusblur-3.2.6/src/source.h focusblur-3.2.6/src/source.h
+index 50d34ca..8eec35c 100644
+--- focusblur-3.2.6/src/source.h
++++ focusblur-3.2.6/src/source.h
+@@ -24,7 +24,7 @@
+ 
+ #include "config.h"
+ 
+-#include <glib/gtypes.h>
++#include <glib.h>
+ #include <libgimp/gimptypes.h>
+ 
+ #include "focusblurtypes.h"
diff --git a/nixpkgs/pkgs/applications/graphics/gimp/remove-cc-reference.patch b/nixpkgs/pkgs/applications/graphics/gimp/remove-cc-reference.patch
new file mode 100644
index 000000000000..0d6a87000ccd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gimp/remove-cc-reference.patch
@@ -0,0 +1,13 @@
+diff --git a/app/gimp-version.c b/app/gimp-version.c
+index 12605c6..a9083da 100644
+--- a/app/gimp-version.c
++++ b/app/gimp-version.c
+@@ -203,7 +203,7 @@ gimp_version (gboolean be_verbose,
+       lib_versions = gimp_library_versions (localized);
+       verbose_info = g_strdup_printf ("git-describe: %s\n"
+                                       "C compiler:\n%s\n%s",
+-                                      GIMP_GIT_VERSION, CC_VERSION,
++                                      GIMP_GIT_VERSION, "@cc_version@",
+                                       lib_versions);
+       g_free (lib_versions);
+ 
diff --git a/nixpkgs/pkgs/applications/graphics/gimp/wrapper.nix b/nixpkgs/pkgs/applications/graphics/gimp/wrapper.nix
new file mode 100644
index 000000000000..11c1e9ada931
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gimp/wrapper.nix
@@ -0,0 +1,28 @@
+{ stdenv, lib, symlinkJoin, gimp, makeWrapper, gimpPlugins, gnome3, plugins ? null}:
+
+let
+allPlugins = lib.filter (pkg: builtins.isAttrs pkg && pkg.type == "derivation" && !pkg.meta.broken or false) (lib.attrValues gimpPlugins);
+selectedPlugins = if plugins == null then allPlugins else plugins;
+extraArgs = map (x: x.wrapArgs or "") selectedPlugins;
+versionBranch = stdenv.lib.versions.majorMinor gimp.version;
+
+in symlinkJoin {
+  name = "gimp-with-plugins-${gimp.version}";
+
+  paths = [ gimp ] ++ selectedPlugins;
+
+  buildInputs = [ makeWrapper ];
+
+  postBuild = ''
+    for each in gimp-${versionBranch} gimp-console-${versionBranch}; do
+      wrapProgram $out/bin/$each \
+        --set GIMP2_PLUGINDIR "$out/lib/gimp/2.0" \
+        --prefix GTK_PATH : "${gnome3.gnome-themes-extra}/lib/gtk-2.0" \
+        ${toString extraArgs}
+    done
+    set +x
+    for each in gimp gimp-console; do
+      ln -sf "$each-${versionBranch}" $out/bin/$each
+    done
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/graphics/glabels/default.nix b/nixpkgs/pkgs/applications/graphics/glabels/default.nix
new file mode 100644
index 000000000000..6bc59cd7d02b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/glabels/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, barcode, gnome3, autoreconfHook
+, gtk3, gtk-doc, libxml2, librsvg , libtool, libe-book, gsettings-desktop-schemas
+, intltool, itstool, makeWrapper, pkgconfig, hicolor-icon-theme
+}:
+
+stdenv.mkDerivation rec {
+  pname = "glabels";
+  version = "3.4.1";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "0f2rki8i27pkd9r0gz03cdl1g4vnmvp0j49nhxqn275vi8lmgr0q";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig makeWrapper intltool ];
+  buildInputs = [
+    barcode gtk3 gtk-doc gnome3.yelp-tools
+    gnome3.gnome-common gsettings-desktop-schemas
+    itstool libxml2 librsvg libe-book libtool
+    hicolor-icon-theme
+  ];
+
+  preFixup = ''
+    wrapProgram "$out/bin/glabels-3" \
+      --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      versionPolicy = "none";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    description = "Create labels and business cards";
+    homepage = https://glabels.org/;
+    license = with licenses; [ gpl3Plus lgpl3Plus ];
+    platforms = platforms.unix;
+    maintainers = [ maintainers.nico202 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/gnome-photos/default.nix b/nixpkgs/pkgs/applications/graphics/gnome-photos/default.nix
new file mode 100644
index 000000000000..f591dd5a60dd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gnome-photos/default.nix
@@ -0,0 +1,125 @@
+{ stdenv
+, fetchurl
+, at-spi2-core
+, babl
+, dbus
+, desktop-file-utils
+, dleyna-renderer
+, gdk-pixbuf
+, gegl
+, geocode-glib
+, gettext
+, gexiv2
+, gfbgraph
+, glib
+, gnome-online-accounts
+, gnome3
+, gobject-introspection
+, grilo
+, grilo-plugins
+, gsettings-desktop-schemas
+, gtk3
+, itstool
+, libdazzle
+, libgdata
+, libxml2
+, meson
+, ninja
+, nixosTests
+, pkgconfig
+, python3
+, tracker
+, tracker-miners
+, wrapGAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "gnome-photos";
+  version = "3.32.1";
+
+  outputs = [ "out" "installedTests" ];
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "0nxa2jz1g73wypdsj19r4plf4hfkhs9mpl7gbhsiyqp1rkn84ahn";
+  };
+
+  patches = [
+    ./installed-tests-path.patch
+  ];
+
+  nativeBuildInputs = [
+    desktop-file-utils
+    gettext
+    gobject-introspection # for setup hook
+    glib # for setup hook
+    itstool
+    libxml2
+    meson
+    ninja
+    pkgconfig
+    (python3.withPackages (pkgs: with pkgs; [
+      dogtail
+      pygobject3
+      pyatspi
+    ]))
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    babl
+    dbus
+    dleyna-renderer
+    gdk-pixbuf
+    gegl
+    geocode-glib
+    gexiv2
+    gfbgraph
+    glib
+    gnome-online-accounts
+    gnome3.adwaita-icon-theme
+    grilo
+    grilo-plugins
+    gsettings-desktop-schemas
+    gtk3
+    libdazzle
+    libgdata
+    tracker
+    tracker-miners # For 'org.freedesktop.Tracker.Miner.Files' GSettings schema
+
+    at-spi2-core # for tests
+  ];
+
+  mesonFlags = [
+    "-Dinstalled_tests=true"
+    "-Dinstalled_test_prefix=${placeholder "installedTests"}"
+  ];
+
+  postPatch = ''
+    chmod +x meson_post_install.py
+    patchShebangs meson_post_install.py
+    patchShebangs tests/basic.py
+  '';
+
+  postFixup = ''
+    wrapProgram "${placeholder "installedTests"}/libexec/installed-tests/gnome-photos/basic.py" "''${gappsWrapperArgs[@]}"
+  '';
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+
+    tests = {
+      installed-tests = nixosTests.gnome-photos;
+    };
+  };
+
+  meta = with stdenv.lib; {
+    description = "Access, organize and share your photos";
+    homepage = https://wiki.gnome.org/Apps/Photos;
+    license = licenses.gpl3Plus;
+    maintainers = gnome3.maintainers;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/gnome-photos/installed-tests-path.patch b/nixpkgs/pkgs/applications/graphics/gnome-photos/installed-tests-path.patch
new file mode 100644
index 000000000000..218108328dd8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gnome-photos/installed-tests-path.patch
@@ -0,0 +1,23 @@
+diff --git a/meson.build b/meson.build
+index dee932dc..f8851913 100644
+--- a/meson.build
++++ b/meson.build
+@@ -16,8 +16,8 @@
+ photos_docdir = join_paths(photos_datadir, 'doc', meson.project_name())
+ photos_libdir = join_paths(photos_prefix, get_option('libdir'), meson.project_name())
+ 
+-photos_installed_test_metadir = join_paths(photos_datadir, 'installed-tests', meson.project_name())
+-photos_installed_test_execdir = join_paths(photos_libexecdir, 'installed-tests', meson.project_name())
++photos_installed_test_metadir = join_paths(get_option('installed_test_prefix'), 'share', 'installed-tests', meson.project_name())
++photos_installed_test_execdir = join_paths(get_option('installed_test_prefix'), 'libexec', 'installed-tests', meson.project_name())
+ 
+ photos_namespace = 'org.gnome.Photos'
+ 
+diff --git a/meson_options.txt b/meson_options.txt
+index f34b5cc0..8e09970b 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -1,2 +1,3 @@
+ option('dogtail', type: 'boolean', value: true, description: 'test using dogtail')
+ option('installed_tests', type: 'boolean', value: false, description: 'Enable installation of some test cases')
++option('installed_test_prefix', type: 'string', value: '', description: 'Prefix for installed tests')
diff --git a/nixpkgs/pkgs/applications/graphics/gnuclad/default.nix b/nixpkgs/pkgs/applications/graphics/gnuclad/default.nix
new file mode 100644
index 000000000000..2535f7514f1d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gnuclad/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, lib, fetchurl, pkgconfig
+}:
+
+stdenv.mkDerivation rec {
+  pname = "gnuclad";
+  version = "0.2.4";
+
+  src = fetchurl {
+    url = "https://launchpad.net/gnuclad/trunk/${lib.versions.majorMinor version}/+download/${pname}-${version}.tar.gz";
+    sha256 = "0ka2kscpjff7gflsargv3r9fdaxhkf3nym9mfaln3pnq6q7fwdki";
+  };
+
+  NIX_CFLAGS_COMPILE = [ "-Wno-error=catch-value" ];
+
+  nativeBuildInputs = [ pkgconfig ];
+
+  meta = with stdenv.lib; {
+    homepage = https://launchpad.net/gnuclad;
+    description = "gnuclad tries to help the environment by creating trees.  It's primary use will be generating cladogram trees for the GNU/Linux distro timeline project.";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ mog ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/gocr/default.nix b/nixpkgs/pkgs/applications/graphics/gocr/default.nix
new file mode 100644
index 000000000000..f5fa8ca9221d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gocr/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, tk }:
+
+stdenv.mkDerivation rec {
+  name = "gocr-0.52";
+
+  src = fetchurl {
+    url = "https://www-e.uni-magdeburg.de/jschulen/ocr/${name}.tar.gz";
+    sha256 = "11l6gds1lrm8lwrrsxnm5fjlwz8q1xbh896cprrl4psz21in946z";
+  };
+
+  buildFlags = [ "all" "libs" ];
+  installFlags = [ "libdir=/lib/" ]; # Specify libdir so Makefile will also install library.
+
+  preInstall = "mkdir -p $out/lib";
+
+  postInstall = ''
+    for i in pgm2asc.h gocr.h; do
+      install -D -m644 src/$i $out/include/gocr/$i
+    done
+  '';
+
+  preFixup = ''
+    sed -i -e 's|exec wish|exec ${tk}/bin/wish|' $out/bin/gocr.tcl
+  '';
+
+  meta = {
+    homepage = http://jocr.sourceforge.net/;
+    description = "GPL Optical Character Recognition";
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/goxel/default.nix b/nixpkgs/pkgs/applications/graphics/goxel/default.nix
new file mode 100644
index 000000000000..e4ab5639ba66
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/goxel/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, scons, pkgconfig, wrapGAppsHook
+, glfw3, gtk3, libpng12 }:
+
+stdenv.mkDerivation rec {
+  pname = "goxel";
+  version = "0.10.0";
+
+  src = fetchFromGitHub {
+    owner = "guillaumechereau";
+    repo = "goxel";
+    rev = "v${version}";
+    sha256 = "1mdw4bs7hvfn0yngd9ial5wzlfkcbhr3wzldb1w7s3s48agixkdr";
+  };
+
+  patches = [ ./disable-imgui_ini.patch ];
+
+  nativeBuildInputs = [ scons pkgconfig wrapGAppsHook ];
+  buildInputs = [ glfw3 gtk3 libpng12 ];
+  NIX_LDFLAGS = [
+    "-lpthread"
+  ];
+
+  buildPhase = ''
+    make release
+  '';
+
+  installPhase = ''
+    install -D ./goxel $out/bin/goxel
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Open Source 3D voxel editor";
+    homepage = https://guillaumechereau.github.io/goxel/;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ tilpner ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/goxel/disable-imgui_ini.patch b/nixpkgs/pkgs/applications/graphics/goxel/disable-imgui_ini.patch
new file mode 100644
index 000000000000..9427d45487d4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/goxel/disable-imgui_ini.patch
@@ -0,0 +1,13 @@
+diff --git a/src/gui.cpp b/src/gui.cpp
+index 9b7236c..a8a11b2 100644
+--- a/src/gui.cpp
++++ b/src/gui.cpp
+@@ -314,6 +314,8 @@ static void init_ImGui(const inputs_t *inputs)
+     ImGuiIO& io = ImGui::GetIO();
+     io.DeltaTime = 1.0f/60.0f;
+
++    io.IniFilename = NULL;
++
+     io.KeyMap[ImGuiKey_Tab]         = KEY_TAB;
+     io.KeyMap[ImGuiKey_LeftArrow]   = KEY_LEFT;
+     io.KeyMap[ImGuiKey_RightArrow]  = KEY_RIGHT;
diff --git a/nixpkgs/pkgs/applications/graphics/gpicview/default.nix b/nixpkgs/pkgs/applications/graphics/gpicview/default.nix
new file mode 100644
index 000000000000..86867cd1cca7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gpicview/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, intltool, pkgconfig, gtk2, fetchpatch }:
+
+stdenv.mkDerivation {
+  name = "gpicview-0.2.4";
+
+  src = fetchurl {
+    url    = "mirror://sourceforge/lxde/gpicview-0.2.4.tar.gz";
+    sha256 = "1svcy1c8bgk0pl12yhyv16h2fl52x5vzzcv57z6qdcv5czgvgglr";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://raw.githubusercontent.com/nonas/debian-clang/master/buildlogs/gpicview/gpicview-0.2.4/debian/patches/clang_FTBFS_Wreturn-type.patch";
+      sha256 = "02dm966bplnv10knpdx7rlpjipk884156ggd9ij05zhza0jl8xcs";
+    })
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A simple and fast image viewer for X";
+    homepage    = http://lxde.sourceforge.net/gpicview/;
+    repositories.git = git://lxde.git.sourceforge.net/gitroot/lxde/gpicview;
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ lovek323 ];
+    platforms   = platforms.unix;
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ intltool gtk2 ];
+}
diff --git a/nixpkgs/pkgs/applications/graphics/gqview/default.nix b/nixpkgs/pkgs/applications/graphics/gqview/default.nix
new file mode 100644
index 000000000000..205376b1257c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gqview/default.nix
@@ -0,0 +1,31 @@
+{stdenv, fetchurl, pkgconfig, gtk2, libpng}:
+
+assert pkgconfig != null && gtk2 != null && libpng != null;
+# Note that we cannot just copy gtk's png attribute, since gtk might
+# not be linked against png.
+# !!! assert libpng == gtk2.libpng;
+
+stdenv.mkDerivation {
+  name = "gqview-2.1.5";
+
+  src = fetchurl {
+    url = mirror://sourceforge/gqview/gqview-2.1.5.tar.gz;
+    sha256 = "0ilm5s7ps9kg4f5hzgjhg0xhn6zg0v9i7jnd67zrx9h7wsaa9zhj";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ gtk2 libpng];
+
+  hardeningDisable = [ "format" ];
+
+  NIX_LDFLAGS = [
+    "-lm"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A fast image viewer";
+    homepage = http://gqview.sourceforge.net;
+    license = licenses.gpl2;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/grafx2/default.nix b/nixpkgs/pkgs/applications/graphics/grafx2/default.nix
new file mode 100644
index 000000000000..039bb1917d37
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/grafx2/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, SDL, SDL_image, SDL_ttf, zlib, libpng, pkgconfig, lua5 }:
+
+stdenv.mkDerivation rec {
+
+  version = "2.4.2035";
+  pname = "grafx2";
+
+  src = fetchurl {
+    url = "https://grafx2.googlecode.com/files/${pname}-${version}-src.tgz";
+    sha256 = "0svsy6rqmdj11b400c242i2ixihyz0hds0dgicqz6g6dcgmcl62q";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ SDL SDL_image SDL_ttf libpng zlib lua5 ];
+
+  preBuild = "cd src";
+
+  preInstall = '' mkdir -p "$out" '';
+
+  installPhase = ''make install prefix="$out"'';
+
+  meta = {
+    description = "Bitmap paint program inspired by the Amiga programs Deluxe Paint and Brilliance";
+    homepage = http://pulkomandy.tk/projects/GrafX2;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = [ "x86_64-linux" "i686-linux" ];
+    maintainers = [ stdenv.lib.maintainers.zoomulator ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/graphicsmagick/1.3.32-darwin-png-strlcat-fix.patch b/nixpkgs/pkgs/applications/graphics/graphicsmagick/1.3.32-darwin-png-strlcat-fix.patch
new file mode 100644
index 000000000000..91eacecbf8c6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/graphicsmagick/1.3.32-darwin-png-strlcat-fix.patch
@@ -0,0 +1,42 @@
+# reduced version of commit f30492f40f78d867b43422215057dd21de4ba447
+# from upstream hg repository:
+RegisterPNGImage(): Pass correct size value to strlcat().
+
+diff -r 95c4711e8bee -r f30492f40f78 coders/png.c
+--- a/coders/png.c	Mon Jun 17 07:24:30 2019 -0500
++++ b/coders/png.c	Mon Jun 17 18:54:43 2019 -0500
+@@ -6427,26 +6427,26 @@
+ 
+       *version='\0';
+ #if defined(PNG_LIBPNG_VER_STRING)
+-      (void) strlcat(version,"libpng ",MaxTextExtent);
+-      (void) strlcat(version,PNG_LIBPNG_VER_STRING,MaxTextExtent);
++      (void) strlcat(version,"libpng ",sizeof(version));
++      (void) strlcat(version,PNG_LIBPNG_VER_STRING,sizeof(version));
+ #if (PNG_LIBPNG_VER > 10005)
+       if (LocaleCompare(PNG_LIBPNG_VER_STRING,png_get_header_ver(NULL)) != 0)
+         {
+-          (void) strlcat(version,",",MaxTextExtent);
+-          (void) strlcat(version,png_get_libpng_ver(NULL),MaxTextExtent);
++          (void) strlcat(version,",",sizeof(version));
++          (void) strlcat(version,png_get_libpng_ver(NULL),sizeof(version));
+         }
+ #endif
+ #endif
+ 
+ #if defined(ZLIB_VERSION)
+       if (*version != '\0')
+-        (void) strlcat(version,", ",MaxTextExtent);
+-      (void) strlcat(version,"zlib ",MaxTextExtent);
+-      (void) strlcat(version,ZLIB_VERSION,MaxTextExtent);
++        (void) strlcat(version,", ",sizeof(version));
++      (void) strlcat(version,"zlib ",sizeof(version));
++      (void) strlcat(version,ZLIB_VERSION,sizeof(version));
+       if (LocaleCompare(ZLIB_VERSION,zlib_version) != 0)
+         {
+-          (void) strlcat(version,",",MaxTextExtent);
+-          (void) strlcat(version,zlib_version,MaxTextExtent);
++          (void) strlcat(version,",",sizeof(version));
++          (void) strlcat(version,zlib_version,sizeof(version));
+         }
+ #endif
diff --git a/nixpkgs/pkgs/applications/graphics/graphicsmagick/compat.nix b/nixpkgs/pkgs/applications/graphics/graphicsmagick/compat.nix
new file mode 100644
index 000000000000..9517aa78ee46
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/graphicsmagick/compat.nix
@@ -0,0 +1,37 @@
+{ stdenv, graphicsmagick }:
+
+stdenv.mkDerivation {
+  pname = "graphicsmagick-imagemagick-compat";
+  inherit (graphicsmagick) version;
+
+  dontUnpack = true;
+  buildPhase = "true";
+
+  utils = [
+    "composite"
+    "conjure"
+    "convert"
+    "identify"
+    "mogrify"
+    "montage"
+    "animate"
+    "display"
+    "import"
+  ];
+
+  # TODO: symlink libraries?
+  installPhase = ''
+    mkdir -p "$out"/bin
+    mkdir -p "$out"/share/man/man1
+    for util in ''${utils[@]}; do
+      ln -s ${graphicsmagick}/bin/gm "$out/bin/$util"
+      ln -s ${graphicsmagick}/share/man/man1/gm.1.gz "$out/share/man/man1/$util.1.gz"
+    done
+  '';
+
+  meta = {
+    description = "ImageMagick interface for GraphicsMagick";
+    license = stdenv.lib.licenses.free;
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/graphicsmagick/default.nix b/nixpkgs/pkgs/applications/graphics/graphicsmagick/default.nix
new file mode 100644
index 000000000000..403a5285e150
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/graphicsmagick/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchurl, bzip2, freetype, graphviz, ghostscript
+, libjpeg, libpng, libtiff, libxml2, zlib, libtool, xz, libX11
+, libwebp, quantumdepth ? 8, fixDarwinDylibNames }:
+
+stdenv.mkDerivation rec {
+  pname = "graphicsmagick";
+  version = "1.3.32";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/graphicsmagick/GraphicsMagick-${version}.tar.xz";
+    sha256 = "1qclp9i31idpcbbqswmnq2q11lmv0a7cvdb1y72xcky8sshaahmq";
+  };
+
+  patches = [
+    ./disable-popen.patch
+    ./1.3.32-darwin-png-strlcat-fix.patch
+  ];
+
+  configureFlags = [
+    "--enable-shared"
+    "--with-quantum-depth=${toString quantumdepth}"
+    "--with-gslib=yes"
+  ];
+
+  buildInputs =
+    [ bzip2 freetype ghostscript graphviz libjpeg libpng libtiff libX11 libxml2
+      zlib libtool libwebp
+    ]
+    ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  nativeBuildInputs = [ xz ];
+
+  postInstall = ''
+    sed -i 's/-ltiff.*'\'/\'/ $out/bin/*
+  '';
+
+  meta = {
+    homepage = http://www.graphicsmagick.org;
+    description = "Swiss army knife of image processing";
+    license = stdenv.lib.licenses.mit;
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/graphicsmagick/disable-popen.patch b/nixpkgs/pkgs/applications/graphics/graphicsmagick/disable-popen.patch
new file mode 100644
index 000000000000..2cdb1f7e90f7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/graphicsmagick/disable-popen.patch
@@ -0,0 +1,12 @@
+http://permalink.gmane.org/gmane.comp.security.oss.general/19669
+
+--- a/magick/blob.c Sat Nov 07 14:49:16 2015 -0600
++++ b/magick/blob.c Sun May 29 14:12:57 2016 -0500
+@@ -68,6 +68,7 @@
+ */
+ #define DefaultBlobQuantum  65541
+ 
++#undef HAVE_POPEN
+ 
+ /*
+   Enum declarations.
diff --git a/nixpkgs/pkgs/applications/graphics/gscan2pdf/default.nix b/nixpkgs/pkgs/applications/graphics/gscan2pdf/default.nix
new file mode 100644
index 000000000000..9af1a0fc9141
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gscan2pdf/default.nix
@@ -0,0 +1,107 @@
+{ stdenv, fetchurl, perlPackages, wrapGAppsHook,
+  # libs
+  librsvg, sane-backends, sane-frontends,
+  # runtime dependencies
+  imagemagick, libtiff, djvulibre, poppler_utils, ghostscript, unpaper, pdftk,
+  # test dependencies
+  xvfb_run, liberation_ttf, file, tesseract }:
+
+with stdenv.lib;
+
+perlPackages.buildPerlPackage rec {
+  pname = "gscan2pdf";
+  version = "2.5.5";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/gscan2pdf/${version}/${pname}-${version}.tar.xz";
+    sha256 = "0gfhjmv768hx2l3jk2mjhh1snkgkaddgw70s14jq8kxhhzvhlmv8";
+  };
+
+  nativeBuildInputs = [ wrapGAppsHook ];
+
+  buildInputs =
+    [ librsvg sane-backends sane-frontends ] ++
+    (with perlPackages; [
+      Gtk3
+      Gtk3SimpleList
+      Cairo
+      CairoGObject
+      Glib
+      GlibObjectIntrospection
+      GooCanvas2
+      LocaleGettext
+      PDFAPI2
+      ImageSane
+      SetIntSpan
+      PerlMagick
+      ConfigGeneral
+      ListMoreUtils
+      HTMLParser
+      ProcProcessTable
+      Log4Perl
+      TryTiny
+      DataUUID
+      DateCalc
+      IOString
+      FilesysDf
+      SubOverride
+    ]);
+
+  postPatch = let
+    fontSubstitute = "${liberation_ttf}/share/fonts/truetype/LiberationSans-Regular.ttf";
+  in ''
+    # Required for the program to properly load its SVG assets
+    substituteInPlace bin/gscan2pdf \
+      --replace "/usr/share" "$out/share"
+
+    # Substitute the non-free Helvetica font in the tests
+    sed -i 's|-pointsize|-font ${fontSubstitute} -pointsize|g' t/*.t
+  '';
+
+  postInstall = ''
+    # Remove impurity
+    find $out -type f -name "*.pod" -delete
+
+    # Add runtime dependencies
+    wrapProgram "$out/bin/gscan2pdf" \
+      --prefix PATH : "${imagemagick}/bin" \
+      --prefix PATH : "${libtiff}/bin" \
+      --prefix PATH : "${djvulibre}/bin" \
+      --prefix PATH : "${poppler_utils}/bin" \
+      --prefix PATH : "${ghostscript}/bin" \
+      --prefix PATH : "${unpaper}/bin" \
+      --prefix PATH : "${pdftk}/bin"
+  '';
+
+  enableParallelBuilding = true;
+
+  installTargets = [ "install" ];
+
+  outputs = [ "out" "man" ];
+
+  checkInputs = [
+    imagemagick
+    libtiff
+    djvulibre
+    poppler_utils
+    ghostscript
+    unpaper
+    pdftk
+
+    xvfb_run
+    file
+    tesseract # tests are expecting tesseract 3.x precisely
+  ];
+
+  checkPhase = ''
+    xvfb-run -s '-screen 0 800x600x24' \
+      make test
+  '';
+
+  meta = {
+    description = "A GUI to produce PDFs or DjVus from scanned documents";
+    homepage = http://gscan2pdf.sourceforge.net/;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ pacien ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/gthumb/default.nix b/nixpkgs/pkgs/applications/graphics/gthumb/default.nix
new file mode 100644
index 000000000000..f24d57786ef2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/gthumb/default.nix
@@ -0,0 +1,108 @@
+{ stdenv
+, fetchurl
+, fetchpatch
+, gnome3
+, pkgconfig
+, meson
+, ninja
+, exiv2
+, libjpeg
+, libtiff
+, gst_all_1
+, libraw
+, libsoup
+, libsecret
+, glib
+, gtk3
+, gsettings-desktop-schemas
+, libchamplain
+, librsvg
+, libwebp
+, json-glib
+, webkitgtk
+, lcms2
+, bison
+, flex
+, clutter-gtk
+, wrapGAppsHook
+, shared-mime-info
+, python3
+, desktop-file-utils
+, itstool
+}:
+
+stdenv.mkDerivation rec {
+  pname = "gthumb";
+  version = "3.8.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "1l2s1facq1r6yvqjqc34aqfzlvb3nhkhn79xisxbbdlgrrxdq52f";
+  };
+
+  nativeBuildInputs = [
+    bison
+    desktop-file-utils
+    flex
+    itstool
+    meson
+    ninja
+    pkgconfig
+    python3
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    clutter-gtk
+    exiv2
+    glib
+    gnome3.adwaita-icon-theme
+    gsettings-desktop-schemas
+    gst_all_1.gst-plugins-base
+    gst_all_1.gstreamer
+    gtk3
+    json-glib
+    lcms2
+    libchamplain
+    libjpeg
+    libraw
+    librsvg
+    libsecret
+    libsoup
+    libtiff
+    libwebp
+    webkitgtk
+  ];
+
+  mesonFlags = [
+    "-Dlibchamplain=true"
+  ];
+
+  postPatch = ''
+    chmod +x gthumb/make-gthumb-h.py
+
+    patchShebangs data/gschemas/make-enums.py \
+      gthumb/make-gthumb-h.py \
+      po/make-potfiles-in.py \
+      postinstall.py \
+      gthumb/make-authors-tab.py
+  '';
+
+  preFixup = ''
+    gappsWrapperArgs+=(--prefix XDG_DATA_DIRS : "${shared-mime-info}/share")
+  '';
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+    };
+  };
+
+  meta = with stdenv.lib; {
+    homepage = "https://wiki.gnome.org/Apps/Gthumb";
+    description = "Image browser and viewer for GNOME";
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
+    maintainers = [ maintainers.mimame ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/guetzli/default.nix b/nixpkgs/pkgs/applications/graphics/guetzli/default.nix
new file mode 100644
index 000000000000..d7b964259683
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/guetzli/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, libpng, fetchFromGitHub, pkgconfig }:
+let
+  version = "1.0.1";
+in
+stdenv.mkDerivation {
+  pname = "guetzli";
+  inherit version;
+  src = fetchFromGitHub {
+    owner = "google";
+    repo = "guetzli";
+    rev = "v${version}";
+    sha256 = "1wy9wfvyradp0aigfv8yijvj0dgb5kpq2yf2xki15f605jc1r5dm";
+  };
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libpng ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    install bin/Release/guetzli $out/bin/
+  '';
+
+  meta = {
+    description = "Perceptual JPEG encoder";
+    longDescription = "Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality.";
+    homepage = https://github.com/google/guetzli;
+    license = stdenv.lib.licenses.asl20;
+    platforms = stdenv.lib.platforms.x86_64;
+    maintainers = [ stdenv.lib.maintainers.seppeljordan ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/hugin/default.nix b/nixpkgs/pkgs/applications/graphics/hugin/default.nix
new file mode 100644
index 000000000000..d7888da15ef6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/hugin/default.nix
@@ -0,0 +1,55 @@
+{ stdenv, cmake, fetchurl, gnumake, makeWrapper, pkgconfig, fetchpatch
+, autopanosiftc, boost, cairo, enblend-enfuse, exiv2, fftw, flann, gettext
+, glew, ilmbase, lcms2, lensfun, libjpeg, libpng, libtiff, libX11, libXi
+, libXmu, libGLU_combined, openexr, panotools, perlPackages, sqlite, vigra, wxGTK, zlib
+}:
+
+stdenv.mkDerivation rec {
+  name = "hugin-2019.0.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/hugin/${name}.tar.bz2";
+    sha256 = "1l925qslp98gg7yzmgps10h6dq0nb60wbfk345anlxsv0g2ifizr";
+  };
+
+  patches = [
+    # Fixes build with exiv2 0.27.1
+    (fetchpatch {
+      url = "https://git.archlinux.org/svntogit/community.git/plain/trunk/hugin-exiv2-0.27.1.patch?h=packages/hugin";
+      sha256 = "1yxvlpvrhyrfd2w6kwx1w3mncsvlzdhp0w7xchy8q6kc2kd5nf7r";
+    })
+  ];
+
+  buildInputs = [
+    boost cairo exiv2 fftw flann gettext glew ilmbase lcms2 lensfun libjpeg
+    libpng libtiff libX11 libXi libXmu libGLU_combined openexr panotools sqlite vigra
+    wxGTK zlib
+  ];
+
+  nativeBuildInputs = [ cmake makeWrapper pkgconfig ];
+
+  # disable installation of the python scripting interface
+  cmakeFlags = [ "-DBUILD_HSI:BOOl=OFF" ];
+
+  enableParallelBuilding = true;
+
+  NIX_CFLAGS_COMPILE = "-I${ilmbase.dev}/include/OpenEXR";
+
+  postInstall = ''
+    for p in $out/bin/*; do
+      wrapProgram "$p" \
+        --suffix PATH : ${autopanosiftc}/bin \
+        --suffix PATH : ${enblend-enfuse}/bin \
+        --suffix PATH : ${gnumake}/bin \
+        --suffix PATH : ${perlPackages.ImageExifTool}/bin
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://hugin.sourceforge.net/;
+    description = "Toolkit for stitching photographs and assembling panoramas, together with an easy to use graphical front end";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ hrdinka ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/ideogram/default.nix b/nixpkgs/pkgs/applications/graphics/ideogram/default.nix
new file mode 100644
index 000000000000..0efb08741835
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/ideogram/default.nix
@@ -0,0 +1,70 @@
+{ stdenv
+, fetchFromGitHub
+, fetchpatch
+, pkgconfig
+, python3
+, glib
+, gtk3
+, meson
+, ninja
+, libgee
+, pantheon
+, desktop-file-utils
+, xorg
+, hicolor-icon-theme
+, wrapGAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "ideogram";
+  version = "1.2.2";
+
+  src = fetchFromGitHub {
+    owner = "cassidyjames";
+    repo = pname;
+    rev = version;
+    sha256 = "1qakgg3y4n2vcnykk2004ndvwmjbk2yy0p4j30mlb7p14dxscif6";
+  };
+
+  nativeBuildInputs = [
+    desktop-file-utils
+    hicolor-icon-theme # for setup-hook
+    meson
+    ninja
+    pantheon.vala
+    pkgconfig
+    python3
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    glib
+    gtk3
+    libgee
+    pantheon.granite
+    xorg.libX11
+    xorg.libXtst
+  ];
+
+  patches = [
+    # See: https://github.com/cassidyjames/ideogram/issues/26
+    (fetchpatch {
+      url = "https://github.com/cassidyjames/ideogram/commit/65994ee11bd21f8316b057cec01afbf50639a708.patch";
+      sha256 = "12vrvvggpqq53dmhbm7gbbbigncn19m1fjln9wxaady21m0w776c";
+    })
+  ];
+
+  postPatch = ''
+    chmod +x meson/post_install.py
+    patchShebangs meson/post_install.py
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Insert emoji anywhere, even in non-native apps - designed for elementary OS";
+    homepage = https://github.com/cassidyjames/ideogram;
+    license = licenses.gpl2Plus;
+    maintainers = pantheon.maintainers;
+    platforms = platforms.linux;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/graphics/image_optim/Gemfile b/nixpkgs/pkgs/applications/graphics/image_optim/Gemfile
new file mode 100644
index 000000000000..d6a0f13a4c1a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/image_optim/Gemfile
@@ -0,0 +1,2 @@
+source 'https://rubygems.org'
+gem 'image_optim'
diff --git a/nixpkgs/pkgs/applications/graphics/image_optim/Gemfile.lock b/nixpkgs/pkgs/applications/graphics/image_optim/Gemfile.lock
new file mode 100644
index 000000000000..20c9772ce464
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/image_optim/Gemfile.lock
@@ -0,0 +1,23 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    exifr (1.3.6)
+    fspath (3.1.0)
+    image_optim (0.26.3)
+      exifr (~> 1.2, >= 1.2.2)
+      fspath (~> 3.0)
+      image_size (>= 1.5, < 3)
+      in_threads (~> 1.3)
+      progress (~> 3.0, >= 3.0.1)
+    image_size (2.0.0)
+    in_threads (1.5.1)
+    progress (3.5.0)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  image_optim
+
+BUNDLED WITH
+   1.16.3
diff --git a/nixpkgs/pkgs/applications/graphics/image_optim/default.nix b/nixpkgs/pkgs/applications/graphics/image_optim/default.nix
new file mode 100644
index 000000000000..385f9825e46f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/image_optim/default.nix
@@ -0,0 +1,66 @@
+{ lib, bundlerApp, bundlerUpdateScript, makeWrapper,
+  withPngcrush ? true,       pngcrush ? null,
+  withPngout ? true,         pngout ? null,
+  withAdvpng ? true,         advancecomp ? null,
+  withOptipng ? true,        optipng ? null,
+  withPngquant ? true,       pngquant ? null,
+  withJhead ? true,          jhead ? null,
+  withJpegoptim ? true,      jpegoptim ? null,
+  withJpegrecompress ? true, jpeg-archive ? null,
+  withJpegtran ? true,       libjpeg ? null,
+  withGifsicle ? true,       gifsicle ? null,
+  withSvgo ? true,           svgo ? null
+}:
+
+assert withPngcrush       -> pngcrush != null;
+assert withPngout         -> pngout != null;
+assert withAdvpng         -> advancecomp != null;
+assert withOptipng        -> optipng != null;
+assert withPngquant       -> pngquant != null;
+assert withJhead          -> jhead != null;
+assert withJpegoptim      -> jpegoptim != null;
+assert withJpegrecompress -> jpeg-archive != null;
+assert withJpegtran       -> libjpeg != null;
+assert withGifsicle       -> gifsicle != null;
+assert withSvgo           -> svgo != null;
+
+with lib;
+
+let
+  optionalDepsPath = []
+    ++ optional withPngcrush pngcrush
+    ++ optional withPngout pngout
+    ++ optional withAdvpng advancecomp
+    ++ optional withOptipng optipng
+    ++ optional withPngquant pngquant
+    ++ optional withJhead jhead
+    ++ optional withJpegoptim jpegoptim
+    ++ optional withJpegrecompress jpeg-archive
+    ++ optional withJpegtran libjpeg
+    ++ optional withGifsicle gifsicle
+    ++ optional withSvgo svgo;
+in
+
+bundlerApp {
+  pname = "image_optim";
+  gemdir = ./.;
+
+  exes = [ "image_optim" ];
+
+  buildInputs = [ makeWrapper ];
+
+  postBuild = ''
+    wrapProgram $out/bin/image_optim \
+      --prefix PATH : ${makeBinPath optionalDepsPath}
+  '';
+
+  passthru.updateScript = bundlerUpdateScript "image_optim";
+
+  meta = with lib; {
+    description = "Command line tool and ruby interface to optimize (lossless compress, optionally lossy) jpeg, png, gif and svg images using external utilities (advpng, gifsicle, jhead, jpeg-recompress, jpegoptim, jpegrescan, jpegtran, optipng, pngcrush, pngout, pngquant, svgo)";
+    homepage    = https://github.com/toy/image_optim;
+    license     = licenses.mit;
+    maintainers = with maintainers; [ srghma nicknovitski ];
+    platforms   = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/image_optim/gemset.nix b/nixpkgs/pkgs/applications/graphics/image_optim/gemset.nix
new file mode 100644
index 000000000000..6c9ec2de7457
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/image_optim/gemset.nix
@@ -0,0 +1,51 @@
+{
+  exifr = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0q2abhiyvgfv23i0izbskjxcqaxiw9bfg6s57qgn4li4yxqpwpfg";
+      type = "gem";
+    };
+    version = "1.3.6";
+  };
+  fspath = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1vjn9sy4hklr2d5wxmj5x1ry31dfq3sjp779wyprb3nbbdmra1sc";
+      type = "gem";
+    };
+    version = "3.1.0";
+  };
+  image_optim = {
+    dependencies = ["exifr" "fspath" "image_size" "in_threads" "progress"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "082w9qcyy9j6m6s2pknfdcik7l2qch4j48axs13m06l4s1hz0dmg";
+      type = "gem";
+    };
+    version = "0.26.3";
+  };
+  image_size = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0bcn7nc6qix3w4sf7xd557lnsgjniqa7qvz7nnznx70m8qfbc7ig";
+      type = "gem";
+    };
+    version = "2.0.0";
+  };
+  in_threads = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "14hqm59sgqi91ag187zwpgwi58xckjkk58m031ghkp0csl8l9mkx";
+      type = "gem";
+    };
+    version = "1.5.1";
+  };
+  progress = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1yrzq4v5sp7cg4nbgqh11k3d1czcllfz98dcdrxrsjxwq5ziiw0p";
+      type = "gem";
+    };
+    version = "3.5.0";
+  };
+}
\ No newline at end of file
diff --git a/nixpkgs/pkgs/applications/graphics/imagej/default.nix b/nixpkgs/pkgs/applications/graphics/imagej/default.nix
new file mode 100644
index 000000000000..6472712bcb40
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/imagej/default.nix
@@ -0,0 +1,48 @@
+{ stdenv, fetchurl, jre, unzip, makeWrapper }:
+
+# Note:
+# - User config dir is hard coded by upstream to $HOME/.imagej on linux systems
+#   and to $HOME/Library/Preferences on macOS.
+#  (The current trend appears to be to use $HOME/.config/imagej
+#    on linux systems, but we here do not attempt to fix it.)
+
+let
+  imagej150 = stdenv.mkDerivation {
+    pname = "imagej";
+    version = "150";
+
+    src = fetchurl {
+      url = "https://wsr.imagej.net/distros/cross-platform/ij150.zip";
+      sha256 = "97aba6fc5eb908f5160243aebcdc4965726693cb1353d9c0d71b8f5dd832cb7b";
+    };
+    buildInputs = [ unzip makeWrapper ];
+    inherit jre;
+
+    # JAR files that are intended to be used by other packages
+    # should go to $out/share/java.
+    # (Some uses ij.jar as a library not as a standalone program.)
+    installPhase = ''
+      mkdir -p $out/share/java
+      # Read permisssion suffices for the jar and others.
+      # Simple cp shall clear suid bits, if any.
+      cp ij.jar $out/share/java
+      cp -dR luts macros plugins $out/share
+      mkdir $out/bin
+      makeWrapper ${jre}/bin/java $out/bin/imagej \
+        --add-flags "-jar $out/share/java/ij.jar -ijpath $out/share"
+    '';
+    meta = with stdenv.lib; {
+      homepage = https://imagej.nih.gov/ij/;
+      description = "Image processing and analysis in Java";
+      longDescription = ''
+        ImageJ is a public domain Java image processing program
+        inspired by NIH Image for the Macintosh.
+        It runs on any computer with a Java 1.4 or later virtual machine.
+      '';
+      license = licenses.publicDomain;
+      platforms = with platforms; linux ++ darwin;
+      maintainers = with maintainers; [ yuriaisaka ];
+    };
+  };
+in
+  imagej150
diff --git a/nixpkgs/pkgs/applications/graphics/imgcat/default.nix b/nixpkgs/pkgs/applications/graphics/imgcat/default.nix
new file mode 100644
index 000000000000..1fa3ec8ccc68
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/imgcat/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub, autoconf, automake, libtool, ncurses }:
+
+stdenv.mkDerivation rec {
+  pname = "imgcat";
+  version = "2.3.1";
+
+  nativeBuildInputs = [ autoconf automake libtool ];
+  buildInputs = [ ncurses ];
+
+  preConfigure = ''
+    ${autoconf}/bin/autoconf
+    sed -i -e "s|-ltermcap|-L ${ncurses}/lib -lncurses|" Makefile
+  '';
+
+  makeFlags = [ "PREFIX=$(out)" ];
+
+  src = fetchFromGitHub {
+    owner = "eddieantonio";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0frz40rjwi73nx2dlqvmnn56zwr29bmnngfb11hhwr7v58yfajdi";
+  };
+
+  NIX_CFLAGS_COMPILE = "-Wno-error";
+
+  meta = with stdenv.lib; {
+    description = "It's like cat, but for images";
+    homepage = https://github.com/eddieantonio/imgcat;
+    license = licenses.isc;
+    maintainers = with maintainers; [ jwiegley ];
+    platforms = platforms.unix;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/graphics/imlibsetroot/default.nix b/nixpkgs/pkgs/applications/graphics/imlibsetroot/default.nix
new file mode 100644
index 000000000000..49868bbd831f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/imlibsetroot/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, libX11, libXinerama, imlib2 }:
+
+stdenv.mkDerivation {
+  pname = "imlibsetroot";
+  version = "1.2";
+  src = fetchurl {
+    url = "https://robotmonkeys.net/wp-content/uploads/2010/03/imlibsetroot-12.tar.gz";
+    sha256 = "8c1b3b7c861e4d865883ec13a96b8e4ab22464a87d4e6c67255b17a88e3cfd1c";
+  };
+
+  buildInputs = [ libX11 imlib2 libXinerama ];
+  buildPhase = ''
+    gcc -g imlibsetroot.c -o imlibsetroot             \
+      `imlib2-config --cflags` `imlib2-config --libs` \
+      -I/include/X11/extensions -lXinerama -lX11
+  '';
+  installPhase = ''
+    mkdir -p $out/bin
+    install -m 755 imlibsetroot $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A Xinerama Aware Background Changer";
+    homepage = http://robotmonkeys.net/2010/03/30/imlibsetroot/;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ lucas8 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/imv/default.nix b/nixpkgs/pkgs/applications/graphics/imv/default.nix
new file mode 100644
index 000000000000..5f06feb7c622
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/imv/default.nix
@@ -0,0 +1,60 @@
+{ stdenv, fetchFromGitHub
+, freeimage, fontconfig, pkgconfig
+, asciidoc, docbook_xsl, libxslt, cmocka
+, librsvg, pango, libxkbcommon, wayland
+, libGLU
+}:
+
+stdenv.mkDerivation rec {
+  pname = "imv";
+  version = "4.0.1";
+
+  src = fetchFromGitHub {
+    owner  = "eXeC64";
+    repo   = "imv";
+    rev    = "v${version}";
+    sha256 = "sha256:01fbkbwwsyr00k3mwans8jfb9p4gl02v6z62vgx0pkgrzxjkcz07";
+  };
+
+  preBuild = ''
+    # Version is 4.0.1, but Makefile was not updated
+    sed -i 's/echo v4\.0\.0/echo v4.0.1/' Makefile
+  '';
+
+  nativeBuildInputs = [
+    asciidoc
+    cmocka
+    docbook_xsl
+    libxslt
+  ];
+
+  buildInputs = [
+    freeimage
+    libGLU
+    librsvg
+    libxkbcommon
+    pango
+    pkgconfig
+    wayland
+  ];
+
+  installFlags = [ "PREFIX=$(out)" "CONFIGPREFIX=$(out)/etc" ];
+
+  postFixup = ''
+    # The `bin/imv` script assumes imv-wayland or imv-x11 in PATH,
+    # so we have to fix those to the binaries we installed into the /nix/store
+
+    sed -i "s|\bimv-wayland\b|$out/bin/imv-wayland|" $out/bin/imv
+    sed -i "s|\bimv-x11\b|$out/bin/imv-x11|" $out/bin/imv
+  '';
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "A command line image viewer for tiling window managers";
+    homepage    = https://github.com/eXeC64/imv;
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ rnhmjoj markus1189 ];
+    platforms   = [ "i686-linux" "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/inkscape/default.nix b/nixpkgs/pkgs/applications/graphics/inkscape/default.nix
new file mode 100644
index 000000000000..547e2914399b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/inkscape/default.nix
@@ -0,0 +1,80 @@
+{ stdenv, fetchurl, pkgconfig, perlPackages, libXft
+, libpng, zlib, popt, boehmgc, libxml2, libxslt, glib, gtkmm2
+, glibmm, libsigcxx, lcms, boost, gettext, makeWrapper
+, gsl, python2, poppler, imagemagick, libwpg, librevenge
+, libvisio, libcdr, libexif, potrace, cmake, hicolor-icon-theme
+, librsvg, wrapGAppsHook
+}:
+
+let
+  python2Env = python2.withPackages(ps: with ps;
+    [ numpy lxml scour ]);
+in
+
+stdenv.mkDerivation rec {
+  name = "inkscape-0.92.4";
+
+  src = fetchurl {
+    url = "https://media.inkscape.org/dl/resources/file/${name}.tar.bz2";
+    sha256 = "0pjinhjibfsz1aywdpgpj3k23xrsszpj4a1ya5562dkv2yl2vv2p";
+  };
+
+  # Inkscape hits the ARGMAX when linking on macOS. It appears to be
+  # CMake’s ARGMAX check doesn’t offer enough padding for NIX_LDFLAGS.
+  # Setting strictDeps it avoids duplicating some dependencies so it
+  # will leave us under ARGMAX.
+  strictDeps = true;
+
+  unpackPhase = ''
+    cp $src ${name}.tar.bz2
+    tar xvjf ${name}.tar.bz2 > /dev/null
+    cd ${name}
+  '';
+
+  postPatch = ''
+    patchShebangs share/extensions
+    patchShebangs fix-roff-punct
+
+    # Python is used at run-time to execute scripts, e.g., those from
+    # the "Effects" menu.
+    substituteInPlace src/extension/implementation/script.cpp \
+      --replace '"python-interpreter", "python"' '"python-interpreter", "${python2Env}/bin/python"'
+  '';
+
+  nativeBuildInputs = [ pkgconfig cmake makeWrapper python2Env wrapGAppsHook ]
+    ++ (with perlPackages; [ perl XMLParser ]);
+  buildInputs = [
+    libXft libpng zlib popt boehmgc
+    libxml2 libxslt glib gtkmm2 glibmm libsigcxx lcms boost gettext
+    gsl poppler imagemagick libwpg librevenge
+    libvisio libcdr libexif potrace hicolor-icon-theme
+
+    librsvg # for loading icons
+
+    python2Env perlPackages.perl
+  ];
+
+  enableParallelBuilding = true;
+
+  # Make sure PyXML modules can be found at run-time.
+  postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
+    install_name_tool -change $out/lib/libinkscape_base.dylib $out/lib/inkscape/libinkscape_base.dylib $out/bin/inkscape
+    install_name_tool -change $out/lib/libinkscape_base.dylib $out/lib/inkscape/libinkscape_base.dylib $out/bin/inkview
+  '';
+
+  # 0.92.3 complains about an invalid conversion from const char * to char *
+  NIX_CFLAGS_COMPILE = " -fpermissive ";
+
+  meta = with stdenv.lib; {
+    license = "GPL";
+    homepage = https://www.inkscape.org;
+    description = "Vector graphics editor";
+    platforms = platforms.all;
+    longDescription = ''
+      Inkscape is a feature-rich vector graphics editor that edits
+      files in the W3C SVG (Scalable Vector Graphics) file format.
+
+      If you want to import .eps files install ps2edit.
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/ipe/default.nix b/nixpkgs/pkgs/applications/graphics/ipe/default.nix
new file mode 100644
index 000000000000..ae2db5181ccb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/ipe/default.nix
@@ -0,0 +1,47 @@
+{ stdenv, fetchurl, makeWrapper, pkgconfig, zlib, freetype, cairo, lua5, texlive, ghostscript
+, libjpeg, libpng, qtbase
+}:
+
+stdenv.mkDerivation rec {
+  name = "ipe-7.2.12";
+
+  src = fetchurl {
+    url = "https://dl.bintray.com/otfried/generic/ipe/7.2/${name}-src.tar.gz";
+    sha256 = "1qw1cmwzi3wxk4x916i9y4prhi9brnwl14i9a1cbw23x1sr7i6kw";
+  };
+
+  sourceRoot = "${name}/src";
+
+  IPEPREFIX=placeholder "out";
+  URWFONTDIR="${texlive}/texmf-dist/fonts/type1/urw/";
+  LUA_PACKAGE = "lua";
+
+  buildInputs = [
+    libjpeg libpng zlib qtbase freetype cairo lua5 texlive ghostscript
+  ];
+
+  nativeBuildInputs = [ makeWrapper pkgconfig ];
+
+  postFixup = ''
+    for prog in $out/bin/*; do
+      wrapProgram "$prog" --prefix PATH : "${texlive}/bin"
+    done
+  '';
+
+  enableParallelBuilding = true;
+
+  #TODO: make .desktop entry
+
+  meta = {
+    description = "An editor for drawing figures";
+    homepage = http://ipe.otfried.org;
+    license = stdenv.lib.licenses.gpl3Plus;
+    longDescription = ''
+      Ipe is an extensible drawing editor for creating figures in PDF and Postscript format.
+      It supports making small figures for inclusion into LaTeX-documents
+      as well as presentations in PDF.
+    '';
+    maintainers = [ stdenv.lib.maintainers.ttuegel ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/jbrout/default.nix b/nixpkgs/pkgs/applications/graphics/jbrout/default.nix
new file mode 100644
index 000000000000..4eb7518cc102
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/jbrout/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchsvn, pythonPackages, makeWrapper, fbida, which }:
+
+let
+  inherit (pythonPackages) python;
+in pythonPackages.buildPythonApplication rec {
+  pname = "jbrout";
+  version = "338";
+
+  src = fetchsvn {
+    url = "http://jbrout.googlecode.com/svn/trunk";
+    rev = version;
+    sha256 = "0257ni4vkxgd0qhs73fw5ppw1qpf11j8fgwsqc03b1k1yv3hk4hf";
+  };
+
+  doCheck = false;
+
+  # XXX: patchPhase to avoid this
+  #  File "/nix/store/vnyjxn6h3rbrn49m25yyw7i1chlxglhw-python-2.7.1/lib/python2.7/zipfile.py", line 348, in FileHeader
+  #    len(filename), len(extra))
+  #struct.error: ushort format requires 0 <= number <= USHRT_MAX
+  patchPhase = ''
+    find | xargs touch
+
+    substituteInPlace setup.py --replace "version=__version__" "version=baseVersion"
+  '';
+
+  postInstall = ''
+    mkdir $out/bin
+    echo "python $out/${python.sitePackages}/jbrout/jbrout.py" > $out/bin/jbrout
+    chmod +x $out/bin/jbrout
+  '';
+
+  buildInputs = [ python makeWrapper which ];
+  propagatedBuildInputs = with pythonPackages; [ pillow lxml pyGtkGlade pyexiv2 fbida ];
+
+  meta = {
+    homepage = https://manatlan.com/jbrout/;
+    description = "Photo manager";
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.gpl2Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/jpeg-archive/default.nix b/nixpkgs/pkgs/applications/graphics/jpeg-archive/default.nix
new file mode 100644
index 000000000000..97c15d2eec09
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/jpeg-archive/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchFromGitHub, mozjpeg, makeWrapper, coreutils, parallel, findutils }:
+
+stdenv.mkDerivation {
+  pname = "jpeg-archive";
+  version = "2.2.0"; # can be found here https://github.com/danielgtaylor/jpeg-archive/blob/master/src/util.c#L15
+
+  # update with
+  # nix-prefetch-git https://github.com/danielgtaylor/jpeg-archive
+  src = fetchFromGitHub {
+    owner = "danielgtaylor";
+    repo = "jpeg-archive";
+    rev = "8da4bf76b6c3c0e11e4941294bfc1857c119419b";
+    sha256 = "1639y9qp2ls80fzimwmwds792q8rq5p6c14c0r4jswx4yp6dcs33";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ mozjpeg ];
+
+  prePatch = ''
+    # allow override LIBJPEG
+    substituteInPlace Makefile --replace 'LIBJPEG =' 'LIBJPEG ?='
+  '';
+
+  makeFlags = [
+    "PREFIX=$(out)"
+    "MOZJPEG_PREFIX=${mozjpeg}"
+    "LIBJPEG=${mozjpeg}/lib/libjpeg.so"
+  ];
+
+  postInstall = ''
+    wrapProgram $out/bin/jpeg-archive \
+      --set PATH "$out/bin:${coreutils}/bin:${parallel}/bin:${findutils}/bin"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Utilities for archiving photos for saving to long term storage or serving over the web";
+    homepage    = "https://github.com/danielgtaylor/jpeg-archive";
+    # license = ...; # mixed?
+    maintainers = [ maintainers.srghma ];
+    platforms   = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/jpeginfo/default.nix b/nixpkgs/pkgs/applications/graphics/jpeginfo/default.nix
new file mode 100644
index 000000000000..e15aedd77e1c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/jpeginfo/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, libjpeg }:
+
+stdenv.mkDerivation rec {
+  pname = "jpeginfo";
+  version = "1.6.1";
+
+  src = fetchurl {
+    url = "https://www.kokkonen.net/tjko/src/${pname}-${version}.tar.gz";
+    sha256 = "0lvn3pnylyj56158d3ix9w1gas1s29klribw9bz1xym03p7k37k2";
+  };
+
+  buildInputs = [ libjpeg ];
+
+  meta = with stdenv.lib; {
+    description = "Prints information and tests integrity of JPEG/JFIF files";
+    homepage = "https://www.kokkonen.net/tjko/projects.html";
+    license = licenses.gpl2Plus;
+    maintainers = [ maintainers.bjornfor ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/jpegoptim/default.nix b/nixpkgs/pkgs/applications/graphics/jpegoptim/default.nix
new file mode 100644
index 000000000000..cc1ca3a0ff2a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/jpegoptim/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, libjpeg }:
+
+stdenv.mkDerivation rec {
+  version = "1.4.6";
+  pname = "jpegoptim";
+
+  src = fetchurl {
+    url = "https://www.kokkonen.net/tjko/src/${pname}-${version}.tar.gz";
+    sha256 = "1dss7907fclfl8zsw0bl4qcw0hhz6fqgi3867w0jyfm3q9jfpcc8";
+  };
+
+  # There are no checks, it seems.
+  doCheck = false;
+
+  buildInputs = [ libjpeg ];
+
+  meta = with stdenv.lib; {
+    description = "Optimize JPEG files";
+    homepage = https://www.kokkonen.net/tjko/projects.html ;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.aristid ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/jpegrescan/default.nix b/nixpkgs/pkgs/applications/graphics/jpegrescan/default.nix
new file mode 100644
index 000000000000..1c65c7da3a28
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/jpegrescan/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchFromGitHub, makeWrapper, libjpeg_turbo, perl, perlPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "jpegrescan";
+  date = "2016-06-01";
+  name = "${pname}-${date}";
+
+  src = fetchFromGitHub {
+    owner = "kud";
+    repo = pname;
+    rev = "e5e39cd972b48ccfb2cba4da6855c511385c05f9";
+    sha256 = "0jbx1vzkzif6yjx1fnsm7fjsmq166sh7mn22lf01ll7s245nmpdp";
+  };
+
+  patchPhase = ''
+    patchShebangs jpegrescan
+  '';
+
+  installPhase = ''
+    mkdir -p $out/share/jpegrescan
+    mv README.md $out/share/jpegrescan/
+    mkdir $out/bin
+    mv jpegrescan $out/bin
+    chmod +x $out/bin/jpegrescan
+
+    wrapProgram $out/bin/jpegrescan --prefix PERL5LIB : $PERL5LIB
+  '';
+
+  propagatedBuildInputs = [ perlPackages.FileSlurp ];
+
+  buildInputs = [
+    perl libjpeg_turbo makeWrapper
+  ];
+
+  meta = with stdenv.lib; {
+    description = "losslessly shrink any JPEG file";
+    homepage = https://github.com/kud/jpegrescan;
+    license = licenses.publicDomain;
+    maintainers = [ maintainers.ramkromberg ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/k3d/default.nix b/nixpkgs/pkgs/applications/graphics/k3d/default.nix
new file mode 100644
index 000000000000..1487fb8adbac
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/k3d/default.nix
@@ -0,0 +1,53 @@
+{ stdenv, fetchFromGitHub, fetchpatch, ftgl, glew, asciidoc
+, cmake, ninja, libGLU_combined, zlib, python, expat, libxml2, libsigcxx, libuuid, freetype
+, libpng, boost, doxygen, cairomm, pkgconfig, imagemagick, libjpeg, libtiff
+, gettext, intltool, perl, gtkmm2, glibmm, gtkglext, pangox_compat, libXmu }:
+
+stdenv.mkDerivation rec {
+  version = "0.8.0.6";
+  pname = "k3d";
+  src = fetchFromGitHub {
+    owner = "K-3D";
+    repo = "k3d";
+    rev = "${pname}-${version}";
+    sha256 = "0vdjjg6h8mxm2n8mvkkg2mvd27jn2xx90hnmx23cbd35mpz9p4aa";
+  };
+
+  patches = [
+    (fetchpatch { /* glibmm 2.50 fix */
+      url = https://github.com/K-3D/k3d/commit/c65889d0652490d88a573e47de7a9324bf27bff2.patch;
+      sha256 = "162icv1hicr2dirkb9ijacvg9bhz5j30yfwg7b45ijavk8rns62j";
+    })
+  ];
+
+  cmakeFlags = [
+    "-DK3D_BUILD_DOCS=false"
+    "-DK3D_BUILD_GUIDE=false"
+  ];
+
+  preConfigure = ''
+    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/build/lib"
+  '';
+
+  nativeBuildInputs = [ cmake ninja gettext intltool doxygen pkgconfig perl asciidoc ];
+
+  buildInputs = [
+     libGLU_combined zlib python expat libxml2 libsigcxx libuuid freetype libpng
+     boost cairomm imagemagick libjpeg libtiff
+     ftgl glew gtkmm2 glibmm gtkglext pangox_compat libXmu
+    ];
+
+  #doCheck = false;
+
+  NIX_CFLAGS_COMPILE = [
+    "-Wno-deprecated-declarations"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A 3D editor with support for procedural editing";
+    homepage = http://www.k-3d.org/;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.raskin ];
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/kcc/default.nix b/nixpkgs/pkgs/applications/graphics/kcc/default.nix
new file mode 100644
index 000000000000..da3589189725
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/kcc/default.nix
@@ -0,0 +1,38 @@
+{ lib
+, mkDerivationWith
+, python3Packages
+, p7zip
+, archiveSupport ? true
+}:
+
+mkDerivationWith python3Packages.buildPythonApplication rec {
+  pname = "kcc";
+  version = "5.5.1";
+
+  src = python3Packages.fetchPypi {
+    inherit version;
+    pname = "KindleComicConverter";
+    sha256 = "5dbee5dc5ee06a07316ae5ebaf21ffa1970094dbae5985ad735e2807ef112644";
+  };
+  
+  propagatedBuildInputs = with python3Packages ; [
+    pillow
+    pyqt5
+    psutil
+    python-slugify
+    raven
+  ];
+
+  qtWrapperArgs = lib.optional archiveSupport [ "--prefix" "PATH" ":" "${ lib.makeBinPath [ p7zip ] }" ];
+
+  postFixup =  ''
+    wrapProgram $out/bin/kcc "''${qtWrapperArgs[@]}"
+  '';
+
+  meta = with lib; {
+    description = "Python app to convert comic/manga files or folders to EPUB, Panel View MOBI or E-Ink optimized CBZ";
+    homepage = "https://kcc.iosphe.re";
+    license = licenses.isc;
+    maintainers = with maintainers; [ dawidsowa ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/kgraphviewer/default.nix b/nixpkgs/pkgs/applications/graphics/kgraphviewer/default.nix
new file mode 100644
index 000000000000..9b96b30c62b1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/kgraphviewer/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, mkDerivation, fetchurl, cmake, extra-cmake-modules, pkgconfig, wrapGAppsHook
+, kconfig, kinit, kdoctools, kio, kparts, kwidgetsaddons
+, qtbase, qtsvg
+, boost, graphviz
+}:
+
+mkDerivation rec {
+  pname = "kgraphviewer";
+  version = "2.4.3";
+
+  src = fetchurl {
+    url = "mirror://kde/stable/kgraphviewer/${version}/${pname}-${version}.tar.xz";
+    sha256 = "1h6pgg89gvxl8gw7wmkabyqqrzad5pxyv5lsmn1fl4ir8lcc5q2l";
+  };
+
+  buildInputs = [
+    qtbase qtsvg
+    boost graphviz
+  ];
+
+  nativeBuildInputs = [
+    cmake extra-cmake-modules pkgconfig wrapGAppsHook
+    kdoctools
+  ];
+
+  propagatedBuildInputs = [
+    kconfig kinit kio kparts kwidgetsaddons
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "A Graphviz dot graph viewer for KDE";
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ lethalman ];
+    platforms   = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/kodelife/default.nix b/nixpkgs/pkgs/applications/graphics/kodelife/default.nix
new file mode 100644
index 000000000000..b86560d1319e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/kodelife/default.nix
@@ -0,0 +1,53 @@
+{ stdenv
+, fetchzip
+, alsaLib
+, glib
+, gst_all_1
+, libGLU_combined
+, xorg
+}:
+
+stdenv.mkDerivation rec {
+  pname = "kodelife";
+  version = "0.8.3.93";
+
+  src = fetchzip {
+    url = "https://hexler.net/pub/${pname}/${pname}-${version}-linux-x86_64.zip";
+    sha256 = "1gidh0745g5mc8h5ypm2wamv1paymnrq3nh3yx1j70jwjg8v2v7g";
+  };
+
+  dontConfigure = true;
+  dontBuild = true;
+  dontStrip = true;
+  dontPatchELF = true;
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv KodeLife $out/bin
+  '';
+
+  preFixup = let
+    libPath = stdenv.lib.makeLibraryPath [
+      stdenv.cc.cc.lib
+      alsaLib
+      glib
+      gst_all_1.gstreamer
+      gst_all_1.gst-plugins-base
+      libGLU_combined
+      xorg.libX11
+    ];
+  in ''
+    patchelf \
+      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+      --set-rpath "${libPath}" \
+      $out/bin/KodeLife
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = "https://hexler.net/products/kodelife";
+    description = "Real-time GPU shader editor";
+    license = licenses.unfree;
+    maintainers = with maintainers; [ prusnak ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/krita/default.nix b/nixpkgs/pkgs/applications/graphics/krita/default.nix
new file mode 100644
index 000000000000..30f7739167ca
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/krita/default.nix
@@ -0,0 +1,52 @@
+{ mkDerivation, lib, stdenv, makeWrapper, fetchurl, cmake, extra-cmake-modules
+, karchive, kconfig, kwidgetsaddons, kcompletion, kcoreaddons
+, kguiaddons, ki18n, kitemmodels, kitemviews, kwindowsystem
+, kio, kcrash
+, boost, libraw, fftw, eigen, exiv2, libheif, lcms2, gsl, openexr, giflib
+, openjpeg, opencolorio, vc, poppler, curl, ilmbase
+, qtmultimedia, qtx11extras, quazip
+, python3Packages
+}:
+
+mkDerivation rec {
+  pname = "krita";
+  version = "4.2.6";
+
+  src = fetchurl {
+    url = "https://download.kde.org/stable/${pname}/${version}/${pname}-${version}.tar.xz";
+    sha256 = "0qdaw8xx3h91v8iw6nw2h276ka8hflaq4r4qwz5mqfd3h254jzym";
+  };
+
+  nativeBuildInputs = [ cmake extra-cmake-modules python3Packages.sip makeWrapper ];
+
+  buildInputs = [
+    karchive kconfig kwidgetsaddons kcompletion kcoreaddons kguiaddons
+    ki18n kitemmodels kitemviews kwindowsystem kio kcrash
+    boost libraw fftw eigen exiv2 lcms2 gsl openexr libheif giflib
+    openjpeg opencolorio poppler curl ilmbase
+    qtmultimedia qtx11extras quazip
+    python3Packages.pyqt5
+  ] ++ lib.optional (stdenv.hostPlatform.isi686 || stdenv.hostPlatform.isx86_64) vc;
+
+  NIX_CFLAGS_COMPILE = [ "-I${ilmbase.dev}/include/OpenEXR" ];
+
+  cmakeFlags = [
+    "-DPYQT5_SIP_DIR=${python3Packages.pyqt5}/share/sip/PyQt5"
+    "-DPYQT_SIP_DIR_OVERRIDE=${python3Packages.pyqt5}/share/sip/PyQt5"
+    "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
+  ];
+
+  postInstall = ''
+    for i in $out/bin/*; do
+      wrapProgram $i --prefix PYTHONPATH : "$PYTHONPATH"
+    done
+  '';
+
+  meta = with lib; {
+    description = "A free and open source painting application";
+    homepage = https://krita.org/;
+    maintainers = with maintainers; [ abbradar ];
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/krop/default.nix b/nixpkgs/pkgs/applications/graphics/krop/default.nix
new file mode 100644
index 000000000000..c4c889cdba52
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/krop/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchFromGitHub, python3Packages, libsForQt5, ghostscript }:
+
+python3Packages.buildPythonApplication rec {
+  pname = "krop";
+  version = "0.5.1";
+
+  src = fetchFromGitHub {
+    owner = "arminstraub";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0b1zqpks4vzq7sfhf7r9qrshr77f1ncj18x7d0fa3g29rxa42dcr";
+  };
+
+  propagatedBuildInputs = with python3Packages; [
+    pyqt5
+    pypdf2
+    poppler-qt5
+    libsForQt5.poppler
+    ghostscript
+  ];
+
+  # Disable checks because of interference with older Qt versions // xcb
+  doCheck = false;
+
+  meta = {
+    homepage = http://arminstraub.com/software/krop;
+    description = "Graphical tool to crop the pages of PDF files";
+    longDescription = ''
+    Krop is a tool that allows you to optimise your PDF files, and remove
+    sections of the page you do not want.  A unique feature of krop, at least to my
+    knowledge, is its ability to automatically split pages into subpages to fit the
+    limited screensize of devices such as eReaders. This is particularly useful, if
+    your eReader does not support convenient scrolling. Krop also has a command line
+    interface.
+    '';
+    license = stdenv.lib.licenses.gpl3Plus;
+    maintainers = with stdenv.lib.maintainers; [ leenaars ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/ktikz/default.nix b/nixpkgs/pkgs/applications/graphics/ktikz/default.nix
new file mode 100644
index 000000000000..4ddc2074f2f4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/ktikz/default.nix
@@ -0,0 +1,54 @@
+{ stdenv, fetchFromGitHub, fetchpatch
+, pkgconfig, wrapQtAppsHook
+, poppler, qt5, gnuplot
+}:
+
+# This package only builds ktikz without KDE integration because KDE4 is
+# deprecated and upstream does not (yet ?) support KDE5.
+# See historical versions of this file for building ktikz with KDE4.
+
+stdenv.mkDerivation rec {
+  version = "0.12";
+  pname = "qtikz";
+
+  meta = with stdenv.lib; {
+    description = "Editor for the TikZ language";
+    homepage = "https://github.com/fhackenberger/ktikz";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.layus ];
+    longDescription = ''
+      You will also need a working *tex installation in your PATH, containing at least `preview` and `pgf`.
+    '';
+  };
+
+  src = fetchFromGitHub {
+    owner = "fhackenberger";
+    repo = "ktikz";
+    rev = version;
+    sha256 = "1s83x8r2yi64wc6ah2iz09dj3qahy0fkxx6cfgpkavjw9x0j0582";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/fhackenberger/ktikz/commit/972685a406517bb85eb561f2c8e26f029eacd7db.patch";
+      sha256 = "13z40rcd4m4n088v7z2ns17lnpn0z3rzp31lsamic3qdcwjwa5k8";
+    })
+  ];
+
+  nativeBuildInputs = [ pkgconfig qt5.qttools qt5.qmake wrapQtAppsHook ];
+  QT_PLUGIN_PATH = "${qt5.qtbase}/${qt5.qtbase.qtPluginPrefix}";
+
+  buildInputs = [ qt5.qtbase poppler ];
+  enableParallelBuilding = true;
+
+  qmakeFlags = [
+    "DESKTOP_INSTALL_DIR=${placeholder "out"}/share/applications"
+    "MIME_INSTALL_DIR=${placeholder "out"}/share/mime/packages"
+    # qcollectiongenerator does no more exist in `qt5.qttools`.
+    # It was merged with qhelpgenerator at some point.
+    "QCOLLECTIONGENERATORCOMMAND=qhelpgenerator"
+  ];
+
+  qtWrapperArgs = [ ''--prefix PATH : "${gnuplot}/bin"'' ];
+}
diff --git a/nixpkgs/pkgs/applications/graphics/leocad/default.nix b/nixpkgs/pkgs/applications/graphics/leocad/default.nix
new file mode 100644
index 000000000000..201a4fe113e3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/leocad/default.nix
@@ -0,0 +1,31 @@
+/*
+To use aditional parts libraries
+set the variable LEOCAD_LIB=/path/to/libs/ or use option -l /path/to/libs/
+*/
+
+{ stdenv, fetchFromGitHub, qt4, qmake4Hook, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "leocad";
+  version = "19.07.1";
+
+  src = fetchFromGitHub {
+    owner = "leozide";
+    repo = "leocad";
+    rev = "v${version}";
+    sha256 = "02kv1m18g6s4dady9jv4sjivfkrp192bmdw2a3d9lzlp60zks0p2";
+  };
+
+  nativeBuildInputs = [ qmake4Hook ];
+  buildInputs = [ qt4 zlib ];
+  postPatch = ''
+    export qmakeFlags="$qmakeFlags INSTALL_PREFIX=$out"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "CAD program for creating virtual LEGO models";
+    homepage = https://www.leocad.org/;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/luminance-hdr/default.nix b/nixpkgs/pkgs/applications/graphics/luminance-hdr/default.nix
new file mode 100644
index 000000000000..94899c937a86
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/luminance-hdr/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, cmake, fetchFromGitHub, pkgconfig, boost, exiv2, fftwFloat, gsl
+, ilmbase, lcms2, libraw, libtiff, openexr
+, qtbase, qtdeclarative, qttools, qtwebengine, eigen
+}:
+
+stdenv.mkDerivation rec {
+  pname = "luminance-hdr";
+  version = "2.6.0";
+
+  src = fetchFromGitHub {
+    owner = "LuminanceHDR";
+    repo = "LuminanceHDR";
+    rev = "v.${version}";
+    sha256 = "1izmgjjp8mgyxv57sjjr05z7g7059ykb5wchlcn4wrnnb6aslnvn";
+  };
+
+  NIX_CFLAGS_COMPILE = "-I${ilmbase.dev}/include/OpenEXR";
+
+  buildInputs = [
+    qtbase qtdeclarative qttools qtwebengine eigen
+    boost exiv2 fftwFloat gsl ilmbase lcms2 libraw libtiff openexr
+  ];
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  meta = with stdenv.lib; {
+    homepage = http://qtpfsgui.sourceforge.net/;
+    description = "A complete open source solution for HDR photography";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.hrdinka ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/mcomix/default.nix b/nixpkgs/pkgs/applications/graphics/mcomix/default.nix
new file mode 100644
index 000000000000..7ae5286f7622
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/mcomix/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, python27Packages }:
+
+python27Packages.buildPythonApplication rec {
+    name = "mcomix-${version}";
+    version = "1.2.1";
+
+    src = fetchurl {
+      url = "mirror://sourceforge/mcomix/${name}.tar.bz2";
+      sha256 = "0fzsf9pklhfs1rzwzj64c0v30b74nk94p93h371rpg45qnfiahvy";
+    };
+
+    propagatedBuildInputs = with python27Packages; [ pygtk pillow ];
+
+    doCheck = false;
+
+    meta = {
+      description = "Image viewer designed to handle comic books";
+      longDescription = ''
+        MComix is an user-friendly, customizable image viewer. It is specifically
+        designed to handle comic books, but also serves as a generic viewer.
+        It reads images in ZIP, RAR, 7Zip or tar archives as well as plain image
+        files. It is written in Python and uses GTK through the PyGTK bindings,
+        and runs on both Linux and Windows.
+
+        MComix is a fork of the Comix project, and aims to add bug fixes and
+        stability improvements after Comix development came to a halt in late 2009.
+      '';
+      homepage = http://mcomix.sourceforge.net/;
+      license = stdenv.lib.licenses.gpl2;
+      maintainers = with stdenv.lib.maintainers; [ fuuzetsu AndersonTorres ];
+    };
+}
+# TODO:
+# - error in check phase
diff --git a/nixpkgs/pkgs/applications/graphics/meh/default.nix b/nixpkgs/pkgs/applications/graphics/meh/default.nix
new file mode 100644
index 000000000000..7ad8c388a203
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/meh/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub, libX11, libXext, libjpeg, libpng, giflib }:
+
+stdenv.mkDerivation {
+  name = "meh-unstable-2015-04-11";
+
+  src = fetchFromGitHub {
+    owner = "jhawthorn";
+    repo = "meh";
+    rev = "4ab1c75f97cb70543db388b3ed99bcfb7e94c758";
+    sha256 = "1j1n3m9hjhz4faryai97jq7cr6a322cqrd878gpkm9nrikap3bkk";
+  };
+
+  installPhase = ''
+    make PREFIX=$out install
+  '';
+
+  outputs = [ "out" "man" ];
+
+  buildInputs = [ libXext libX11 libjpeg libpng giflib ];
+
+  meta = {
+    description = "A minimal image viewer using raw XLib";
+    homepage = https://www.johnhawthorn.com/meh/;
+    license = stdenv.lib.licenses.mit;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/meme/default.nix b/nixpkgs/pkgs/applications/graphics/meme/default.nix
new file mode 100644
index 000000000000..5f8a0bb6eed3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/meme/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  pname = "meme-unstable";
+  version = "2017-09-10";
+
+  owner = "nomad-software";
+  repo = "meme";
+  goPackagePath = "github.com/${owner}/${repo}";
+
+  src = fetchFromGitHub {
+    inherit owner repo;
+    rev = "a6521f2eecb0aac22937b0013747ed9cb40b81ea";
+    sha256 = "1gbsv1d58ck6mj89q31s5b0ppw51ab76yqgz39jgwqnkidvzdfly";
+  };
+
+  meta = with stdenv.lib; {
+    description = "A command line utility for creating image macro style memes";
+    homepage = "https://github.com/nomad-software/meme";
+    license = licenses.mit;
+    maintainers = [ maintainers.fgaz ];
+    platforms = with platforms; linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/meshlab/default.nix b/nixpkgs/pkgs/applications/graphics/meshlab/default.nix
new file mode 100644
index 000000000000..bd5dea8014d6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/meshlab/default.nix
@@ -0,0 +1,69 @@
+{ fetchFromGitHub, libGLU, llvmPackages, qtbase, qtscript, qtxmlpatterns }:
+
+let
+  meshlabRev = "d596d7c086c51fbdfb56050f9c30b55dd0286d4c";
+  vcglibRev = "6c3c940e34327322507c703889f9f1cfa73ab183";
+  # ^ this should be the latest commit in the vcglib devel branch at the time of the meshlab revision
+
+  stdenv = llvmPackages.stdenv; # only building with clang seems to be tested upstream
+in stdenv.mkDerivation {
+  name = "meshlab-20180627-beta";
+
+  srcs =
+    [
+      (fetchFromGitHub {
+        owner = "cnr-isti-vclab";
+        repo = "meshlab";
+        rev = meshlabRev;
+        sha256 = "0xi7wiyy0yi545l5qvccbqahlcsf70mhx829gf7bq29640si4rax";
+        name = "meshlab-${meshlabRev}";
+      })
+      (fetchFromGitHub {
+        owner = "cnr-isti-vclab";
+        repo = "vcglib";
+        rev = vcglibRev;
+        sha256 = "0jfgjvf21y9ncmyr7caipy3ardhig7hh9z8miy885c99b925hhwd";
+        name = "vcglib-${vcglibRev}";
+      })
+    ];
+
+  sourceRoot = "meshlab-${meshlabRev}";
+
+  hardeningDisable = [ "format" ];
+  enableParallelBuilding = true;
+
+  patches = [ ./fix-20180627-beta.patch ];
+
+  buildPhase = ''
+    # MeshLab has ../vcglib hardcoded everywhere, so move the source dir
+    mv ../vcglib-${vcglibRev} ../vcglib
+
+    cd src
+    export NIX_LDFLAGS="-rpath $out/opt/meshlab $NIX_LDFLAGS"
+    export QMAKESPEC="linux-clang"
+
+    pushd external
+    qmake -recursive external.pro
+    buildPhase
+    popd
+    qmake -recursive meshlab_full.pro
+    buildPhase
+  '';
+
+  installPhase = ''
+    mkdir -p $out/opt/meshlab $out/bin
+    cp -Rv distrib/* $out/opt/meshlab
+    ln -s $out/opt/meshlab/meshlab $out/bin/meshlab
+    ln -s $out/opt/meshlab/meshlabserver $out/bin/meshlabserver
+  '';
+
+  buildInputs = [ libGLU llvmPackages.openmp qtbase qtscript qtxmlpatterns ];
+
+  meta = {
+    description = "A system for processing and editing 3D triangular meshes.";
+    homepage = http://www.meshlab.net/;
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/meshlab/fix-20180627-beta.patch b/nixpkgs/pkgs/applications/graphics/meshlab/fix-20180627-beta.patch
new file mode 100644
index 000000000000..177b8e90c574
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/meshlab/fix-20180627-beta.patch
@@ -0,0 +1,25 @@
+diff --git a/src/meshlabplugins/edit_paint/paintbox.cpp b/src/meshlabplugins/edit_paint/paintbox.cpp
+index 2097a5b..6bcd1a4 100644
+--- a/src/meshlabplugins/edit_paint/paintbox.cpp
++++ b/src/meshlabplugins/edit_paint/paintbox.cpp
+@@ -23,6 +23,7 @@
+ 
+ #include "paintbox.h"
+ #include <QFileDialog>
++#include <QAction>
+ 
+ Paintbox::Paintbox(QWidget * parent, Qt::WindowFlags flags) : QWidget(parent, flags)
+ {
+diff --git a/src/meshlabplugins/render_gdp/shaderDialog.h b/src/meshlabplugins/render_gdp/shaderDialog.h
+index a62d3b5..7eb1594 100644
+--- a/src/meshlabplugins/render_gdp/shaderDialog.h
++++ b/src/meshlabplugins/render_gdp/shaderDialog.h
+@@ -32,6 +32,8 @@
+ #include "shaderStructs.h"
+ #include "ui_shaderDialog.h"
+ #include <QMap>
++#include <QSlider>
++#include <QLineEdit>
+ 
+ class QGLWidget;
+ 
diff --git a/nixpkgs/pkgs/applications/graphics/minidjvu/default.nix b/nixpkgs/pkgs/applications/graphics/minidjvu/default.nix
new file mode 100644
index 000000000000..d629c776194d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/minidjvu/default.nix
@@ -0,0 +1,27 @@
+{stdenv, fetchurl, libtiff, gettext }:
+
+stdenv.mkDerivation {
+  name = "minidjvu-0.8";
+  src = fetchurl {
+    url = mirror://sourceforge/minidjvu/minidjvu-0.8.tar.gz;
+    sha256 = "0jmpvy4g68k6xgplj9zsl6brg6vi81mx3nx2x9hfbr1f4zh95j79";
+  };
+
+  patchPhase = ''
+    sed -i s,/usr/bin/gzip,gzip, Makefile.in
+  '';
+
+  buildInputs = [ libtiff gettext];
+
+  preInstall = ''
+    mkdir -p $out/lib
+  '';
+
+  meta = {
+    homepage = http://djvu.sourceforge.net/djview4.html;
+    description = "Black-and-white djvu page encoder and decoder that use interpage information";
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = [ stdenv.lib.maintainers.viric ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/mirage/default.nix b/nixpkgs/pkgs/applications/graphics/mirage/default.nix
new file mode 100644
index 000000000000..fbe8f10c72f7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/mirage/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, pythonPackages, libX11, gettext }:
+
+pythonPackages.buildPythonApplication rec {
+    pname = "mirage";
+    version = "0.9.5.2";
+
+    src = fetchurl {
+      url = "mirror://sourceforge/mirageiv/${pname}-${version}.tar.bz2";
+      sha256 = "d214a1b6d99d1d1e83da5848a2cef181f6781e0990e93f7ebff5880b0c43f43c";
+    };
+
+    doCheck = false;
+
+    nativeBuildInputs = [ gettext ];
+
+    buildInputs = [ stdenv libX11 gettext ];
+
+    patchPhase = ''
+      sed -i "s@/usr/local/share/locale@$out/share/locale@" mirage.py
+    '';
+
+    propagatedBuildInputs = with pythonPackages; [ pygtk pillow ];
+
+    meta = {
+      description = "Simple image viewer written in PyGTK";
+
+      homepage = http://mirageiv.sourceforge.net/;
+
+      license = stdenv.lib.licenses.gpl2;
+    };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/mozjpeg/default.nix b/nixpkgs/pkgs/applications/graphics/mozjpeg/default.nix
new file mode 100644
index 000000000000..63cc4a3a8d35
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/mozjpeg/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, libpng, nasm }:
+
+stdenv.mkDerivation rec {
+  version = "3.3.1";
+  pname = "mozjpeg";
+
+  src = fetchFromGitHub {
+    owner = "mozilla";
+    repo = "mozjpeg";
+    rev = "v${version}";
+    sha256 = "1na68860asn8b82ny5ilwbhh4nyl9gvx2yxmm4wr2v1v95v51fky";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ libpng nasm ];
+
+  meta = {
+    description = "Mozilla JPEG Encoder Project";
+    longDescription = ''
+      This project's goal is to reduce the size of JPEG files without reducing quality or compatibility with the
+      vast majority of the world's deployed decoders.
+
+      The idea is to reduce transfer times for JPEGs on the Web, thus reducing page load times.
+    '';
+    homepage = https://github.com/mozilla/mozjpeg ;
+    license = stdenv.lib.licenses.bsd3;
+    maintainers = [ stdenv.lib.maintainers.aristid ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/mtpaint/default.nix b/nixpkgs/pkgs/applications/graphics/mtpaint/default.nix
new file mode 100644
index 000000000000..7274bdacd9d0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/mtpaint/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchFromGitHub
+, pkgconfig
+, freetype, giflib, gtk2, lcms2, libjpeg, libpng, libtiff, openjpeg, gifsicle
+}:
+
+stdenv.mkDerivation rec {
+  p_name  = "mtPaint";
+  ver_maj = "3.49";
+  ver_min = "12";
+  name = "${p_name}-${ver_maj}.${ver_min}";
+
+  src = fetchFromGitHub {
+    owner = "wjaguar";
+    repo = p_name;
+    rev = "6aed1b0441f99055fc7d475942f8bd5cb23c41f8";
+    sha256 = "0bvf623g0n2ifijcxv1nw0z3wbs2vhhdky4n04ywsbjlykm44nd1";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    freetype giflib gtk2 lcms2 libjpeg libpng libtiff openjpeg gifsicle
+  ];
+
+  meta = {
+    description = "A simple GTK painting program";
+    longDescription = ''
+      mtPaint is a simple GTK painting program designed for
+      creating icons and pixel based artwork.  It can edit indexed palette
+      or 24 bit RGB images and offers basic painting and palette manipulation
+      tools. It also has several other more powerful features such as channels,
+      layers and animation.
+      Due to its simplicity and lack of dependencies it runs well on
+      GNU/Linux, Windows and older PC hardware.
+    '';
+    homepage = http://mtpaint.sourceforge.net/;
+    license = stdenv.lib.licenses.gpl3;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.vklquevs ];
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/graphics/mypaint/default.nix b/nixpkgs/pkgs/applications/graphics/mypaint/default.nix
new file mode 100644
index 000000000000..1b51732b918c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/mypaint/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromGitHub, gtk3, intltool, json_c, lcms2, libpng, librsvg, gobject-introspection, hicolor-icon-theme
+, gdk-pixbuf, pkgconfig, python2Packages, scons, swig, wrapGAppsHook }:
+
+let
+  inherit (python2Packages) python pycairo pygobject3 numpy;
+in stdenv.mkDerivation {
+  pname = "mypaint";
+  version = "1.2.1";
+
+  src = fetchFromGitHub {
+    owner = "mypaint";
+    repo = "mypaint";
+    rev = "bcf5a28d38bbd586cc9d4cee223f849fa303864f";
+    sha256 = "1zwx7n629vz1jcrqjqmw6vl6sxdf81fq6a5jzqiga8167gg8s9pf";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [
+    intltool pkgconfig scons swig wrapGAppsHook
+    gobject-introspection # for setup hook
+  ];
+
+  buildInputs = [
+    gtk3 gdk-pixbuf json_c lcms2 libpng librsvg pycairo pygobject3 python hicolor-icon-theme
+  ];
+
+  propagatedBuildInputs = [ numpy ];
+
+  postInstall = ''
+    sed -i -e 's|/usr/bin/env python2.7|${python}/bin/python|' $out/bin/mypaint
+  '';
+
+  preFixup = ''
+    gappsWrapperArgs+=(--prefix PYTHONPATH : $PYTHONPATH)
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A graphics application for digital painters";
+    homepage = http://mypaint.org/;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ goibhniu jtojnar ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/nomacs/default.nix b/nixpkgs/pkgs/applications/graphics/nomacs/default.nix
new file mode 100644
index 000000000000..62fae518b929
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/nomacs/default.nix
@@ -0,0 +1,66 @@
+{ stdenv
+, mkDerivation
+, fetchFromGitHub
+, cmake
+, pkgconfig
+
+, qtbase
+, qttools
+, qtsvg
+
+, exiv2
+, opencv
+, libraw
+, libtiff
+, quazip
+}:
+
+mkDerivation rec {
+  pname = "nomacs";
+  version = "3.12";
+
+  src = fetchFromGitHub {
+    owner = "nomacs";
+    repo = "nomacs";
+    rev = version;
+    sha256 = "12582i5v85da7vwjxj8grj99hxg34ij5cn3b1578wspdfw1xfy1i";
+  };
+
+  patches = [
+    ./nomacs-iostream.patch
+  ];
+
+  enableParallelBuilding = true;
+
+  setSourceRoot = ''
+    sourceRoot=$(echo */ImageLounge)
+  '';
+
+  nativeBuildInputs = [cmake
+                       pkgconfig];
+
+  buildInputs = [qtbase
+                 qttools
+                 qtsvg
+                 exiv2
+                 opencv
+                 libraw
+                 libtiff
+                 quazip];
+
+  cmakeFlags = ["-DENABLE_OPENCV=ON"
+                "-DENABLE_RAW=ON"
+                "-DENABLE_TIFF=ON"
+                "-DENABLE_QUAZIP=ON"
+                "-DENABLE_TRANSLATIONS=ON"
+                "-DUSE_SYSTEM_QUAZIP=ON"];
+
+  meta = with stdenv.lib; {
+    homepage = https://nomacs.org;
+    description = "Qt-based image viewer";
+    maintainers = [maintainers.ahmedtd];
+    license = licenses.gpl3Plus;
+    repositories.git = https://github.com/nomacs/nomacs.git;
+    inherit (qtbase.meta) platforms;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/nomacs/nomacs-iostream.patch b/nixpkgs/pkgs/applications/graphics/nomacs/nomacs-iostream.patch
new file mode 100644
index 000000000000..53224e0260eb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/nomacs/nomacs-iostream.patch
@@ -0,0 +1,26 @@
+diff --git a/src/DkCore/DkMetaData.cpp b/src/DkCore/DkMetaData.cpp
+index d195757e..affec7be 100644
+--- a/src/DkCore/DkMetaData.cpp
++++ b/src/DkCore/DkMetaData.cpp
+@@ -42,6 +42,8 @@
+ #include <QApplication>
+ #pragma warning(pop)		// no warnings from includes - end
+
++#include <iostream>
++
+ namespace nmc {
+
+ // DkMetaDataT --------------------------------------------------------------------
+diff --git a/src/DkGui/DkNoMacs.cpp b/src/DkGui/DkNoMacs.cpp
+index 6a412f70..bbfba233 100644
+--- a/src/DkGui/DkNoMacs.cpp
++++ b/src/DkGui/DkNoMacs.cpp
+@@ -96,6 +96,8 @@
+ #include <QWinTaskbarButton>
+ #endif
+
++#include <iostream>
++
+ namespace nmc {
+
+ DkNomacsOSXEventFilter::DkNomacsOSXEventFilter(QObject *parent) : QObject(parent) {
diff --git a/nixpkgs/pkgs/applications/graphics/ocrad/default.nix b/nixpkgs/pkgs/applications/graphics/ocrad/default.nix
new file mode 100644
index 000000000000..80f592681110
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/ocrad/default.nix
@@ -0,0 +1,36 @@
+{ fetchurl, stdenv, lzip, texinfo }:
+
+stdenv.mkDerivation rec {
+  pname = "ocrad";
+  version = "0.27";
+
+  src = fetchurl {
+    url = "mirror://gnu/ocrad/${pname}-${version}.tar.lz";
+    sha256 = "0divffvcaim89g4pvqs8kslbcxi475bcl3b4ynphf284k9zfdgx9";
+  };
+
+  nativeBuildInputs = [ lzip /* unpack */ ];
+  buildInputs = [ texinfo ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "Optical character recognition (OCR) program & library";
+    longDescription =
+      '' GNU Ocrad is an OCR (Optical Character Recognition) program based on
+         a feature extraction method.  It reads images in pbm (bitmap), pgm
+         (greyscale) or ppm (color) formats and produces text in byte (8-bit)
+         or UTF-8 formats.
+
+         Also includes a layout analyser able to separate the columns or
+         blocks of text normally found on printed pages.
+
+         Ocrad can be used as a stand-alone console application, or as a
+         backend to other programs.
+      '';
+
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ pSub ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/openimageio/2.x.nix b/nixpkgs/pkgs/applications/graphics/openimageio/2.x.nix
new file mode 100644
index 000000000000..4e61fccaa372
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/openimageio/2.x.nix
@@ -0,0 +1,58 @@
+{ stdenv
+, fetchFromGitHub
+, boost
+, cmake
+, ilmbase
+, libjpeg
+, libpng
+, libtiff
+, opencolorio
+, openexr
+, robin-map
+, unzip
+}:
+
+stdenv.mkDerivation rec {
+  pname = "openimageio";
+  version = "2.0.10";
+
+  src = fetchFromGitHub {
+    owner = "OpenImageIO";
+    repo = "oiio";
+    rev = "Release-${version}";
+    sha256 = "0k60kgfahsqcgmydsf1kh1qzshn8mksaw772z48a40qnx28pfjys";
+  };
+
+  outputs = [ "bin" "out" "dev" "doc" ];
+
+  nativeBuildInputs = [
+    cmake
+    unzip
+  ];
+
+  buildInputs = [
+    boost
+    ilmbase
+    libjpeg
+    libpng
+    libtiff
+    opencolorio
+    openexr
+    robin-map
+  ];
+
+  cmakeFlags = [
+    "-DUSE_PYTHON=OFF"
+    "-DUSE_QT=OFF"
+    # GNUInstallDirs
+    "-DCMAKE_INSTALL_LIBDIR=lib" # needs relative path for pkgconfig
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = http://www.openimageio.org;
+    description = "A library and tools for reading and writing images";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ goibhniu jtojnar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/openimageio/default.nix b/nixpkgs/pkgs/applications/graphics/openimageio/default.nix
new file mode 100644
index 000000000000..7225efadebd9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/openimageio/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromGitHub, boost, cmake, ilmbase, libjpeg, libpng, libtiff
+, opencolorio, openexr, unzip
+}:
+
+stdenv.mkDerivation rec {
+  pname = "openimageio";
+  version = "1.8.16";
+
+  src = fetchFromGitHub {
+    owner = "OpenImageIO";
+    repo = "oiio";
+    rev = "Release-${version}";
+    sha256 = "0isx137c6anvs1xfxi0z35v1cw855xvnq2ca0pakqqpdh0yivrps";
+  };
+
+  outputs = [ "bin" "out" "dev" "doc" ];
+
+  nativeBuildInputs = [ cmake unzip ];
+  buildInputs = [
+    boost ilmbase libjpeg libpng
+    libtiff opencolorio openexr
+  ];
+
+  cmakeFlags = [
+    "-DUSE_PYTHON=OFF"
+  ];
+
+  makeFlags = [
+    "ILMBASE_HOME=${ilmbase.dev}"
+    "OPENEXR_HOME=${openexr.dev}"
+    "USE_PYTHON=0"
+    "INSTALLDIR=${placeholder "out"}"
+    "dist_dir="
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = http://www.openimageio.org;
+    description = "A library and tools for reading and writing images";
+    license = licenses.bsd3;
+    maintainers = [ maintainers.goibhniu ];
+    platforms = platforms.unix;
+    badPlatforms = [ "x86_64-darwin" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/openscad/default.nix b/nixpkgs/pkgs/applications/graphics/openscad/default.nix
new file mode 100644
index 000000000000..9f7fbc8421ba
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/openscad/default.nix
@@ -0,0 +1,86 @@
+{ stdenv
+, fetchFromGitHub
+, qtbase
+, qtmultimedia
+, qscintilla
+, bison
+, flex
+, eigen
+, boost
+, libGLU_combined
+, glew
+, opencsg
+, cgal
+, mpfr
+, gmp
+, glib
+, pkgconfig
+, harfbuzz
+, gettext
+, freetype
+, fontconfig
+, double-conversion
+, lib3mf
+, libzip
+, mkDerivation
+, qtmacextras
+, qmake
+}:
+
+mkDerivation rec {
+  pname = "openscad";
+  version = "2019.05";
+
+  src = fetchFromGitHub {
+    owner = "openscad";
+    repo = "openscad";
+    rev = "${pname}-${version}";
+    sha256 = "1qz384jqgk75zxk7sqd22ma9pyd94kh4h6a207ldx7p9rny6vc5l";
+  };
+
+  nativeBuildInputs = [ bison flex pkgconfig gettext qmake ];
+
+  buildInputs = [
+    eigen boost glew opencsg cgal mpfr gmp glib
+    harfbuzz lib3mf libzip double-conversion freetype fontconfig
+    qtbase qtmultimedia qscintilla
+  ] ++ stdenv.lib.optional stdenv.isLinux libGLU_combined
+    ++ stdenv.lib.optional stdenv.isDarwin qtmacextras
+  ;
+
+  qmakeFlags = [ "VERSION=${version}" ];
+
+  # src/lexer.l:36:10: fatal error: parser.hxx: No such file or directory
+  enableParallelBuilding = false; # true by default due to qmake
+
+  postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
+    mkdir $out/Applications
+    mv $out/bin/*.app $out/Applications
+    rmdir $out/bin || true
+
+    mv --target-directory=$out/Applications/OpenSCAD.app/Contents/Resources \
+      $out/share/openscad/{examples,color-schemes,locale,libraries,fonts}
+
+    rmdir $out/share/openscad
+  '';
+
+  meta = {
+    description = "3D parametric model compiler";
+    longDescription = ''
+      OpenSCAD is a software for creating solid 3D CAD objects. It is free
+      software and available for Linux/UNIX, MS Windows and macOS.
+
+      Unlike most free software for creating 3D models (such as the famous
+      application Blender) it does not focus on the artistic aspects of 3D
+      modelling but instead on the CAD aspects. Thus it might be the
+      application you are looking for when you are planning to create 3D models of
+      machine parts but pretty sure is not what you are looking for when you are more
+      interested in creating computer-animated movies.
+    '';
+    homepage = http://openscad.org/;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers;
+      [ bjornfor raskin the-kenny gebner ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/panotools/default.nix b/nixpkgs/pkgs/applications/graphics/panotools/default.nix
new file mode 100644
index 000000000000..719aca5096a5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/panotools/default.nix
@@ -0,0 +1,23 @@
+{ fetchurl, stdenv, libjpeg, libpng, libtiff, perl }:
+
+stdenv.mkDerivation rec {
+  name = "libpano13-2.9.19";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/panotools/${name}.tar.gz";
+    sha256 = "1a4m3plmfcrrplqs9zfzhc5apibn10m5sajpizm1sd3q74w5fwq3";
+  };
+
+  buildInputs = [ perl libjpeg libpng libtiff ];
+
+  # one of the tests succeeds on my machine but fails on Hydra (no idea why)
+  #doCheck = true;
+
+  meta = {
+    homepage = http://panotools.sourceforge.net/;
+    description = "Free software suite for authoring and displaying virtual reality panoramas";
+    license = stdenv.lib.licenses.gpl2Plus;
+
+    platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;  # arbitrary choice
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/paraview/default.nix b/nixpkgs/pkgs/applications/graphics/paraview/default.nix
new file mode 100644
index 000000000000..13a00991265f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/paraview/default.nix
@@ -0,0 +1,71 @@
+{
+stdenv, fetchFromGitHub, cmake, makeWrapper
+,qtbase, qttools, python, libGLU_combined
+,libXt, qtx11extras, qtxmlpatterns
+}:
+
+stdenv.mkDerivation rec {
+  pname = "paraview";
+  version = "5.6.0";
+
+  # fetching from GitHub instead of taking an "official" source
+  # tarball because of missing submodules there
+  src = fetchFromGitHub {
+    owner = "Kitware";
+    repo = "ParaView";
+    rev = "v${version}";
+    sha256 = "1j13yfdgcv4yzfr449i4c8r4rs1c9zr6qd3igr4vv3ani8zixkzi";
+    fetchSubmodules = true;
+  };
+
+  cmakeFlags = [
+    "-DPARAVIEW_ENABLE_PYTHON=ON"
+    "-DPARAVIEW_INSTALL_DEVELOPMENT_FILES=ON"
+    "-DPARAVIEW_ENABLE_EMBEDDED_DOCUMENTATION=OFF"
+    "-DOpenGL_GL_PREFERENCE=GLVND"
+  ];
+
+  # During build, binaries are called that rely on freshly built
+  # libraries.  These reside in build/lib, and are not found by
+  # default.
+  preBuild = ''
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib:$PWD/VTK/ThirdParty/vtkm/vtk-m/lib
+  '';
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [
+    cmake
+    makeWrapper
+  ];
+
+  buildInputs = [
+    python
+    python.pkgs.numpy
+    libGLU_combined
+    libXt
+    qtbase
+    qtx11extras
+    qttools
+    qtxmlpatterns
+  ];
+
+  # Paraview links into the Python library, resolving symbolic links on the way,
+  # so we need to put the correct sitePackages (with numpy) back on the path
+  postInstall = ''
+    wrapProgram $out/bin/paraview \
+      --set PYTHONPATH "${python.pkgs.numpy}/${python.sitePackages}"
+    wrapProgram $out/bin/pvbatch \
+      --set PYTHONPATH "${python.pkgs.numpy}/${python.sitePackages}"
+    wrapProgram $out/bin/pvpython \
+      --set PYTHONPATH "${python.pkgs.numpy}/${python.sitePackages}"
+  '';
+
+  meta = {
+    homepage = http://www.paraview.org/;
+    description = "3D Data analysis and visualization application";
+    license = stdenv.lib.licenses.free;
+    maintainers = with stdenv.lib.maintainers; [guibert];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/pbrt/default.nix b/nixpkgs/pkgs/applications/graphics/pbrt/default.nix
new file mode 100644
index 000000000000..78f6d8bcbaff
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/pbrt/default.nix
@@ -0,0 +1,31 @@
+{stdenv, fetchFromGitHub, flex, bison, cmake, git, zlib}:
+
+stdenv.mkDerivation {
+
+  version = "2018-08-15";
+  pname = "pbrt-v3";
+
+  src = fetchFromGitHub {
+    rev = "86b5821308088deea70b207bc8c22219d0103d65";
+    owner  = "mmp";
+    repo   = "pbrt-v3";
+    sha256 = "0f7ivsczba6zfk5f0bba1js6dcwf6w6jrkiby147qp1sx5k35cv8";
+    fetchSubmodules = true;
+  };
+
+  patches = [
+    # https://github.com/mmp/pbrt-v3/issues/196
+    ./openexr-cmake-3.12.patch
+  ];
+
+  buildInputs = [ git flex bison cmake zlib ];
+
+  meta = with stdenv.lib; {
+    homepage = http://pbrt.org;
+    description = "The renderer described in the third edition of the book 'Physically Based Rendering: From Theory To Implementation'";
+    platforms = platforms.linux ;
+    license = licenses.bsd2;
+    maintainers = [ maintainers.juliendehos ];
+    priority = 10;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/pbrt/openexr-cmake-3.12.patch b/nixpkgs/pkgs/applications/graphics/pbrt/openexr-cmake-3.12.patch
new file mode 100644
index 000000000000..2993922a1ecf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/pbrt/openexr-cmake-3.12.patch
@@ -0,0 +1,26 @@
+diff -ur a/src/ext/openexr/CMakeLists.txt b/src/ext/openexr/CMakeLists.txt
+--- a/src/ext/openexr/CMakeLists.txt	1970-01-01 09:00:01.000000000 +0900
++++ b/src/ext/openexr/CMakeLists.txt	2018-08-31 21:44:56.490714484 +0900
+@@ -26,22 +26,4 @@
+   ${CMAKE_CURRENT_BINARY_DIR}/IlmBase/config
+ )
+ 
+-add_custom_target(CopyIlmBaseLibs
+-  COMMAND ${CMAKE_COMMAND} -E copy_directory
+-  ${CMAKE_CURRENT_BINARY_DIR}/IlmBase/Half/$<CONFIGURATION>
+-  ${CMAKE_CURRENT_BINARY_DIR}/OpenEXR/IlmImf/$<CONFIGURATION>
+-  COMMAND ${CMAKE_COMMAND} -E copy_directory
+-  ${CMAKE_CURRENT_BINARY_DIR}/IlmBase/IlmThread/$<CONFIGURATION>
+-  ${CMAKE_CURRENT_BINARY_DIR}/OpenEXR/IlmImf/$<CONFIGURATION>
+-  COMMAND ${CMAKE_COMMAND} -E copy_directory
+-  ${CMAKE_CURRENT_BINARY_DIR}/IlmBase/Iex/$<CONFIGURATION>
+-  ${CMAKE_CURRENT_BINARY_DIR}/OpenEXR/IlmImf/$<CONFIGURATION>
+-  COMMAND ${CMAKE_COMMAND} -E copy_directory
+-  ${CMAKE_CURRENT_BINARY_DIR}/IlmBase/Imath/$<CONFIGURATION>
+-  ${CMAKE_CURRENT_BINARY_DIR}/OpenEXR/IlmImf/$<CONFIGURATION>
+-)
+-add_dependencies(CopyIlmBaseLibs Iex Imath IlmThread Half)
+-
+ add_subdirectory(OpenEXR OpenEXR)
+-add_dependencies(b44ExpLogTable CopyIlmBaseLibs)
+-add_dependencies(dwaLookups CopyIlmBaseLibs)
diff --git a/nixpkgs/pkgs/applications/graphics/pdfcpu/default.nix b/nixpkgs/pkgs/applications/graphics/pdfcpu/default.nix
new file mode 100644
index 000000000000..7b1077d18a9d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/pdfcpu/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, buildGoModule, fetchFromGitHub }:
+
+buildGoModule rec {
+  pname = "pdfcpu";
+  version = "0.2.4";
+
+  src = fetchFromGitHub {
+    owner = "pdfcpu";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0inlwrpv5zkcv48g5gq1xdrvd7w1zkhf8p57fpr2cpd7hd3am7n8";
+  };
+
+  modSha256 = "1nagb3k2ghfw27g4vcmn7v8s5flg387jpf1l18gw6c44a1xjcivs";
+
+  subPackages = [ "cmd/pdfcpu" ];
+
+  meta = with stdenv.lib; {
+    description = "A PDF processor written in Go";
+    homepage = https://pdfcpu.io;
+    license = licenses.asl20;
+    maintainers = with maintainers; [ doronbehar ];
+    platforms = platforms.all;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/graphics/pencil/default.nix b/nixpkgs/pkgs/applications/graphics/pencil/default.nix
new file mode 100644
index 000000000000..37857fc459ea
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/pencil/default.nix
@@ -0,0 +1,104 @@
+{ stdenv, fetchurl, lib, makeWrapper,
+  # build dependencies
+  alsaLib, atk, cairo, cups, dbus, expat, fontconfig,
+  freetype, gdk-pixbuf, glib, gnome2, nspr, nss, xorg,
+  glibc, systemd
+}:
+
+stdenv.mkDerivation rec {
+  version = "3.0.4";
+  pname = "pencil";
+
+  src = fetchurl {
+    url    = "http://pencil.evolus.vn/dl/V${version}/Pencil_${version}_amd64.deb";
+    sha256 = "58e2b794c615ea8715d8374f177e19c87f7071e359826ec34a59836d537a62fd";
+  };
+
+  sourceRoot = ".";
+
+  unpackCmd = ''
+    ar p "$src" data.tar.xz | tar xJ
+  '';
+
+  dontBuild = true;
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -R usr/share opt $out/
+
+    # fix the path in the desktop file
+    substituteInPlace \
+      $out/share/applications/pencil.desktop \
+      --replace /opt/ $out/opt/
+
+    # symlink the binary to bin/
+    ln -s $out/opt/Pencil/pencil $out/bin/pencil
+  '';
+
+
+  preFixup = let
+    packages = [
+      alsaLib
+      atk
+      cairo
+      cups
+      dbus
+      expat
+      fontconfig
+      freetype
+      gdk-pixbuf
+      glib
+      gnome2.GConf
+      gnome2.gtk
+      gnome2.pango
+      nspr
+      nss
+      xorg.libX11
+      xorg.libXScrnSaver
+      xorg.libXcomposite
+      xorg.libXcursor
+      xorg.libXdamage
+      xorg.libXext
+      xorg.libXfixes
+      xorg.libXi
+      xorg.libXrandr
+      xorg.libXrender
+      xorg.libXtst
+      stdenv.cc.cc.lib
+      stdenv.cc.cc
+      glibc
+    ];
+    libPathNative = lib.makeLibraryPath packages;
+    libPath64 = lib.makeSearchPathOutput "lib" "lib64" packages;
+    libPath = "${libPathNative}:${libPath64}";
+  in ''
+    # patch executable
+    patchelf \
+      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+      --set-rpath "${libPath}:$out/opt/Pencil" \
+      $out/opt/Pencil/pencil
+
+    # patch libnode
+    patchelf \
+      --set-rpath "${libPath}" \
+      $out/opt/Pencil/libnode.so
+
+    # libffmpeg is for some reason  not executable
+    chmod a+x $out/opt/Pencil/libffmpeg.so
+
+    # fix missing libudev
+    ln -s ${systemd.lib}/lib/libudev.so.1 $out/opt/Pencil/libudev.so.1
+    wrapProgram $out/opt/Pencil/pencil \
+      --prefix LD_LIBRARY_PATH : $out/opt/Pencil
+  '';
+
+  meta = with stdenv.lib; {
+    description = "GUI prototyping/mockup tool";
+    homepage    = "https://pencil.evolus.vn/";
+    license     = licenses.gpl2; # Commercial license is also available
+    maintainers = with maintainers; [ bjornfor prikhi mrVanDalo ];
+    platforms   = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/photivo/default.nix b/nixpkgs/pkgs/applications/graphics/photivo/default.nix
new file mode 100644
index 000000000000..09b5bd378397
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/photivo/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchhg, fetchpatch, cmake, qt4, fftw, graphicsmagick_q16,
+  lcms2, lensfun, pkgconfig, libjpeg, exiv2, liblqr1 }:
+
+stdenv.mkDerivation {
+  name = "photivo-2014-01-25";
+
+  src = fetchhg {
+    url = "http://code.google.com/p/photivo/";
+    rev = "d687864489da";
+    sha256 = "0f6y18k7db2ci6xn664zcwm1g1k04sdv7gg1yd5jk41bndjb7z8h";
+  };
+
+  patches = [
+    # Patch fixing build with lensfun >= 0.3, taken from
+    # https://www.linuxquestions.org/questions/slackware-14/photivo-4175530230/#post5296578
+    (fetchpatch {
+      url = "https://www.linuxquestions.org/questions/attachment.php?attachmentid=17287&d=1420577220";
+      name = "lensfun-0.3.patch";
+      sha256 = "0ys45x4r4bjjlx0zpd5d56rgjz7k8gxili4r4k8zx3zfka4a3zwv";
+    })
+    ./gcc6.patch
+  ];
+
+  postPatch = '' # kinda icky
+    sed -e '/("@INSTALL@")/d' \
+        -e s,@INSTALL@,$out/share/photivo, \
+        -i Sources/ptSettings.cpp
+    sed '1i#include <math.h>' -i Sources/filters/ptFilter_StdCurve.cpp
+  '';
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  buildInputs = [ qt4 fftw graphicsmagick_q16 lcms2 lensfun libjpeg exiv2 liblqr1 ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    platforms = platforms.linux;
+    license = licenses.gpl3;
+    broken = true; # exiv2 0.27.1 FTBFS
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/photivo/gcc6.patch b/nixpkgs/pkgs/applications/graphics/photivo/gcc6.patch
new file mode 100644
index 000000000000..e2eb795fc8e2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/photivo/gcc6.patch
@@ -0,0 +1,13 @@
+diff --git c/Sources/ptImage.cpp i/Sources/ptImage.cpp
+index 9c95093..623c157 100755
+--- c/Sources/ptImage.cpp
++++ i/Sources/ptImage.cpp
+@@ -5291,7 +5291,7 @@ ptImage* ptImage::Box(const uint16_t MaxRadius, float* Mask) {
+         NewRow = NewRow < 0? -NewRow : NewRow > Height1? Height1_2-NewRow : NewRow ;

+         NewRow *= m_Width;

+         for(j = -IntRadius; j <= IntRadius; j++) {

+-          if (Dist[abs(i)][abs(j)] < Radius) {

++          if (Dist[int16_t(abs(i))][int16_t(abs(j))] < Radius) {

+             NewCol = Col+j;

+             NewCol = NewCol < 0? -NewCol : NewCol > Width1? Width1_2-NewCol : NewCol ;

+ 

diff --git a/nixpkgs/pkgs/applications/graphics/photoflow/default.nix b/nixpkgs/pkgs/applications/graphics/photoflow/default.nix
new file mode 100644
index 000000000000..db41ee0566fe
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/photoflow/default.nix
@@ -0,0 +1,56 @@
+{ stdenv, fetchFromGitHub, gettext, glib, libxml2, pkgconfig, swig, automake, gobject-introspection, cmake, ninja, libtiff, libjpeg, fftw, exiv2, lensfun, gtkmm2, libraw, lcms2, libexif, vips, expat, pcre, pugixml }:
+
+stdenv.mkDerivation {
+  name = "photoflow-unstable-2018-08-28";
+
+  src = fetchFromGitHub {
+    owner = "aferrero2707";
+    repo = "PhotoFlow";
+    rev = "df03f2538ddd232e693c307db4ab63eb5bdfea38";
+    sha256 = "08ybhv08h24y4li8wb4m89xgrz1szlwpksf6vjharp8cznn4y4x9";
+  };
+
+  nativeBuildInputs = [
+    gettext
+    glib
+    libxml2
+    pkgconfig
+    swig
+    automake
+    gobject-introspection
+    cmake
+    ninja
+  ];
+
+  buildInputs = [
+    libtiff
+    libjpeg
+    fftw
+    exiv2
+    lensfun
+    gtkmm2  # Could be build with gtk3 but proper UI theme is missing and therefore not very usable with gtk3
+            # See: https://discuss.pixls.us/t/help-needed-for-gtk3-theme/5803
+    libraw
+    lcms2
+    libexif
+    vips
+    expat
+    pcre
+    pugixml
+  ];
+
+  cmakeFlags = [
+    "-DBUNDLED_EXIV2=OFF"
+    "-DBUNDLED_LENSFUN=OFF"
+    "-DBUNDLED_GEXIV2=OFF"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A fully non-destructive photo retouching program providing a complete RAW image editing workflow";
+    homepage = https://aferrero2707.github.io/PhotoFlow/;
+    license = licenses.gpl3Plus;
+    maintainers = [ maintainers.MtP ];
+    platforms = platforms.linux;
+    broken = stdenv.isAarch64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/photoqt/default.nix b/nixpkgs/pkgs/applications/graphics/photoqt/default.nix
new file mode 100644
index 000000000000..68afdd8694b1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/photoqt/default.nix
@@ -0,0 +1,48 @@
+{ stdenv, fetchurl, cmake, exiv2, graphicsmagick, libraw, fetchpatch
+, qtbase, qtdeclarative, qtmultimedia, qtquickcontrols, qttools, qtgraphicaleffects
+, extra-cmake-modules, poppler, kimageformats, libarchive, libdevil
+}:
+
+stdenv.mkDerivation rec {
+  pname = "photoqt";
+  version = "1.7.1";
+
+  src = fetchurl {
+    url = "https://${pname}.org/pkgs/${pname}-${version}.tar.gz";
+    sha256 = "1qvxdh3cbjcywqx0da2qp8z092660qyzv5yknqbps2zr12qqb103";
+  };
+
+  patches = [
+    # Fixes build with exiv2 0.27.1
+    (fetchpatch {
+      url = "https://gitlab.com/luspi/photoqt/commit/c6fd41478e818f3a651d40f96cab3d790e1c09a4.patch";
+      sha256 = "1j2pdr7hm3js7lswhb4qkf9sj9viclhjqz50qxpyd7pqrl1gf2va";
+    })
+  ];
+
+  nativeBuildInputs = [ cmake extra-cmake-modules qttools ];
+
+  buildInputs = [
+    qtbase qtquickcontrols exiv2 graphicsmagick poppler
+    qtmultimedia qtdeclarative libraw qtgraphicaleffects
+    kimageformats libarchive
+  ];
+
+  cmakeFlags = [
+    "-DFREEIMAGE=OFF"
+    "-DDEVIL=OFF"
+  ];
+
+  preConfigure = ''
+    export MAGICK_LOCATION="${graphicsmagick}/include/GraphicsMagick"
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    homepage = https://photoqt.org/;
+    description = "Simple, yet powerful and good looking image viewer";
+    license = stdenv.lib.licenses.gpl2Plus;
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/phototonic/default.nix b/nixpkgs/pkgs/applications/graphics/phototonic/default.nix
new file mode 100644
index 000000000000..5e7fb5cf7a0a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/phototonic/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub, qtbase, qmake, exiv2 }:
+
+stdenv.mkDerivation rec {
+  pname = "phototonic";
+  version = "2.1";
+
+  src = fetchFromGitHub {
+    repo = "phototonic";
+    owner = "oferkv";
+    rev = "v${version}";
+    sha256 = "0csidmxl1sfmn6gq81vn9f9jckb4swz3sgngnwqa4f75lr6604h7";
+  };
+
+  buildInputs = [ qtbase exiv2 ];
+  nativeBuildInputs = [ qmake ];
+
+  preConfigure = ''
+    sed -i 's;/usr;$$PREFIX/;g' phototonic.pro
+  '';
+
+  meta = with stdenv.lib; {
+    description = "An image viewer and organizer";
+    homepage = https://sourceforge.net/projects/phototonic/;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ pSub ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/pinta/default.nix b/nixpkgs/pkgs/applications/graphics/pinta/default.nix
new file mode 100644
index 000000000000..140903766848
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/pinta/default.nix
@@ -0,0 +1,83 @@
+{ stdenv, fetchFromGitHub, buildDotnetPackage, dotnetPackages, gtksharp,
+  gettext }:
+
+let
+  mono-addins = dotnetPackages.MonoAddins;
+in
+buildDotnetPackage rec {
+  name = "pinta-1.6";
+
+  baseName = "Pinta";
+  version = "1.6";
+  outputFiles = [ "bin/*" ];
+  buildInputs = [ gtksharp mono-addins gettext ];
+  xBuildFiles = [ "Pinta.sln" ];
+
+  src = fetchFromGitHub {
+    owner = "PintaProject";
+    repo = "Pinta";
+    rev = version;
+    sha256 = "0vgswy981c7ys4q7js5k85sky7bz8v32wsfq3br4j41vg92pw97d";
+  };
+
+  # Remove version information from nodes <Reference Include="... Version=... ">
+  postPatch = with stdenv.lib; let
+    csprojFiles = [
+      "Pinta/Pinta.csproj"
+      "Pinta.Core/Pinta.Core.csproj"
+      "Pinta.Effects/Pinta.Effects.csproj"
+      "Pinta.Gui.Widgets/Pinta.Gui.Widgets.csproj"
+      "Pinta.Resources/Pinta.Resources.csproj"
+      "Pinta.Tools/Pinta.Tools.csproj"
+    ];
+    versionedNames = [
+      "Mono\\.Addins"
+      "Mono\\.Posix"
+      "Mono\\.Addins\\.Gui"
+      "Mono\\.Addins\\.Setup"
+    ];
+
+    stripVersion = name: file: let
+        match = ''<Reference Include="${name}([ ,][^"]*)?"'';
+        replace = ''<Reference Include="${name}"'';
+      in "sed -i -re 's/${match}/${replace}/g' ${file}\n";
+
+    # Map all possible pairs of two lists
+    map2 = f: listA: listB: concatMap (a: map (f a) listB) listA;
+    concatMap2Strings = f: listA: listB: concatStrings (map2 f listA listB);
+  in
+    concatMap2Strings stripVersion versionedNames csprojFiles
+    + ''
+      # For some reason there is no Microsoft.Common.tasks file
+      # in ''${mono}/lib/mono/3.5 .
+      substituteInPlace Pinta.Install.proj \
+        --replace 'ToolsVersion="3.5"' 'ToolsVersion="4.0"' \
+        --replace "/usr/local" "$out"
+    '';
+
+  makeWrapperArgs = [
+    ''--prefix MONO_GAC_PREFIX : ${gtksharp}''
+    ''--prefix LD_LIBRARY_PATH : ${gtksharp}/lib''
+    ''--prefix LD_LIBRARY_PATH : ${gtksharp.gtk.out}/lib''
+  ];
+
+  postInstall = ''
+    # Do automake's job manually
+    substitute xdg/pinta.desktop.in xdg/pinta.desktop \
+      --replace _Name Name \
+      --replace _Comment Comment \
+      --replace _GenericName GenericName \
+      --replace _X-GNOME-FullName X-GNOME-FullName
+
+    xbuild /target:CompileTranslations Pinta.Install.proj
+    xbuild /target:Install Pinta.Install.proj
+  '';
+
+  meta = {
+    homepage = http://www.pinta-project.com/;
+    description = "Drawing/editing program modeled after Paint.NET";
+    license = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ ];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/potrace/default.nix b/nixpkgs/pkgs/applications/graphics/potrace/default.nix
new file mode 100644
index 000000000000..f50af2925a3a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/potrace/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "potrace";
+  version = "1.15";
+
+  src = fetchurl {
+    url = "http://potrace.sourceforge.net/download/${version}/potrace-${version}.tar.gz";
+    sha256 = "17ajildjp14shsy339xarh1lw1p0k60la08ahl638a73mh23kcx9";
+  };
+
+  configureFlags = [ "--with-libpotrace" ];
+
+  buildInputs = [ zlib ];
+
+  meta = with stdenv.lib; {
+    homepage = http://potrace.sourceforge.net/;
+    description = "A tool for tracing a bitmap, which means, transforming a bitmap into a smooth, scalable image";
+    platforms = platforms.unix;
+    maintainers = [ maintainers.pSub ];
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/pqiv/default.nix b/nixpkgs/pkgs/applications/graphics/pqiv/default.nix
new file mode 100644
index 000000000000..1ad51e92d472
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/pqiv/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub, pkgconfig
+, ffmpeg, gtk3, imagemagick, libarchive, libspectre, libwebp, poppler
+}:
+
+stdenv.mkDerivation (rec {
+  pname = "pqiv";
+  version = "2.11";
+
+  src = fetchFromGitHub {
+    owner = "phillipberndt";
+    repo = "pqiv";
+    rev = version;
+    sha256 = "06cwm28b7j1skwp21s5snmj1pqh3xh6y2i5v4w3pz0b8k3053h9i";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ ffmpeg gtk3 imagemagick libarchive libspectre libwebp poppler ];
+
+  prePatch = "patchShebangs .";
+
+  meta = with stdenv.lib; {
+    description = "Powerful image viewer with minimal UI";
+    homepage = http://www.pberndt.com/Programme/Linux/pqiv;
+    license = licenses.gpl3;
+    maintainers = [ maintainers.ndowens ];
+    platforms = platforms.linux;
+  };
+})
diff --git a/nixpkgs/pkgs/applications/graphics/processing/default.nix b/nixpkgs/pkgs/applications/graphics/processing/default.nix
new file mode 100644
index 000000000000..9972ea757098
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/processing/default.nix
@@ -0,0 +1,63 @@
+{ stdenv, fetchFromGitHub, fetchurl, xmlstarlet, makeWrapper, ant, jdk, rsync, javaPackages, libXxf86vm, gsettings-desktop-schemas }:
+
+stdenv.mkDerivation rec {
+  pname = "processing";
+  version = "3.5.3";
+
+  src = fetchFromGitHub {
+    owner = "processing";
+    repo = "processing";
+    rev = "processing-0269-${version}";
+    sha256 = "0ajniy3a0i0rx7is46r85yh3ah4zm4ra1gbllmihw9pmnfjgfajn";
+  };
+
+  nativeBuildInputs = [ ant rsync makeWrapper ];
+  buildInputs = [ jdk ];
+
+  buildPhase = ''
+    # use compiled jogl to avoid patchelf'ing .so files inside jars
+    rm core/library/*.jar
+    cp ${javaPackages.jogl_2_3_2}/share/java/*.jar core/library/
+
+    # do not download a file during build
+    ${xmlstarlet}/bin/xmlstarlet ed --inplace -P -d '//get[@src="http://download.processing.org/reference.zip"]' build/build.xml
+    install -D -m0444 ${fetchurl {
+                          url    = http://download.processing.org/reference.zip;
+                          sha256 = "198bpk8mzns6w5h0zdf50wr6iv7sgdi6v7jznj5rbsnpgyilxz35";
+                        }
+                       } ./java/reference.zip
+
+    # suppress "Not fond of this Java VM" message box
+    substituteInPlace app/src/processing/app/platform/LinuxPlatform.java \
+      --replace 'Messages.showWarning' 'if (false) Messages.showWarning'
+
+    ( cd build
+      substituteInPlace build.xml --replace "jre-download," ""  # do not download jre1.8.0_144
+      mkdir -p linux/jre1.8.0_144                               # fake dir to avoid error
+      ant build )
+  '';
+
+  installPhase = ''
+    mkdir $out
+    cp -dpR build/linux/work $out/${pname}
+
+    rmdir $out/${pname}/java
+    ln -s ${jdk} $out/${pname}/java
+
+    makeWrapper $out/${pname}/processing      $out/bin/processing \
+        --prefix XDG_DATA_DIRS : ${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name} \
+        --prefix _JAVA_OPTIONS " " -Dawt.useSystemAAFontSettings=lcd \
+        --prefix LD_LIBRARY_PATH : ${libXxf86vm}/lib
+    makeWrapper $out/${pname}/processing-java $out/bin/processing-java \
+        --prefix XDG_DATA_DIRS : ${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name} \
+        --prefix _JAVA_OPTIONS " " -Dawt.useSystemAAFontSettings=lcd \
+        --prefix LD_LIBRARY_PATH : ${libXxf86vm}/lib
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A language and IDE for electronic arts";
+    homepage = https://processing.org;
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/qcomicbook/default.nix b/nixpkgs/pkgs/applications/graphics/qcomicbook/default.nix
new file mode 100644
index 000000000000..4d416a7c106d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/qcomicbook/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchFromGitHub, pkgconfig, cmake, qtbase, qttools, qtx11extras, poppler }:
+
+stdenv.mkDerivation rec {
+  pname = "qcomicbook";
+  version = "0.9.1";
+
+  src = fetchFromGitHub {
+    owner = "stolowski";
+    repo = "QComicBook";
+    rev = version;
+    sha256 = "1b769lp6gfwds4jb2g7ymhdm9c06zg57zpyz3zpdb40w07zfsjzv";
+  };
+
+  nativeBuildInputs = [
+    cmake pkgconfig
+  ];
+
+  buildInputs = [
+    qtbase qttools qtx11extras poppler
+  ];
+
+  postInstall = ''
+    substituteInPlace $out/share/applications/*.desktop \
+      --replace "Exec=qcomicbook" "Exec=$out/bin/qcomicbook"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/stolowski/QComicBook;
+    description = "Comic book reader in Qt5";
+    license = licenses.gpl2;
+
+    longDescription = ''
+      QComicBook is a viewer for PDF files and comic book archives containing
+      jpeg/png/xpm/gif/bmp images, which aims at convenience and simplicity.
+      Features include: automatic unpacking of archive files, full-screen mode, continuous
+      scrolling mode, double-pages viewing, manga mode, thumbnails view, page scaling,
+      mouse or keyboard navigation etc.
+    '';
+
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ greydot ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/qiv/default.nix b/nixpkgs/pkgs/applications/graphics/qiv/default.nix
new file mode 100644
index 000000000000..750217d99188
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/qiv/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, pkgconfig, gtk2, imlib2, file, lcms2, libexif } :
+
+stdenv.mkDerivation (rec {
+  version = "2.3.2";
+  pname = "qiv";
+
+  src = fetchurl {
+    url = "https://spiegl.de/qiv/download/${pname}-${version}.tgz";
+    sha256 = "1mc0f2nnas4q0d7zc9r6g4z93i32xlx0p9hl4fn5zkyml24a1q28";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ gtk2 imlib2 file lcms2 libexif ];
+
+  preBuild=''
+    substituteInPlace Makefile --replace /usr/local "$out"
+    substituteInPlace Makefile --replace /man/ /share/man/
+    substituteInPlace Makefile --replace /share/share/ /share/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Quick image viewer";
+    homepage = http://spiegl.de/qiv/;
+    inherit version;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+})
diff --git a/nixpkgs/pkgs/applications/graphics/qiv/default.upstream b/nixpkgs/pkgs/applications/graphics/qiv/default.upstream
new file mode 100644
index 000000000000..e6c7ef2408e8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/qiv/default.upstream
@@ -0,0 +1,3 @@
+url http://spiegl.de/qiv/download/
+version_link '[.]tgz$'
+do_overwrite() { do_overwrite_just_version; }
diff --git a/nixpkgs/pkgs/applications/graphics/qscreenshot/default.nix b/nixpkgs/pkgs/applications/graphics/qscreenshot/default.nix
new file mode 100644
index 000000000000..fafc76a76ffe
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/qscreenshot/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, dos2unix, which, qt, Carbon }:
+
+stdenv.mkDerivation rec {
+  name = "qscreenshot-1.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/qscreenshot/${name}-src.tar.gz";
+    sha256 = "1spj5fg2l8p5bk81xsv6hqn1kcrdiy54w19jsfb7g5i94vcb1pcx";
+  };
+
+  buildInputs = [ dos2unix which qt ]
+    ++ stdenv.lib.optional stdenv.isDarwin Carbon;
+
+  # Remove carriage returns that cause /bin/sh to abort
+  preConfigure = ''
+    dos2unix configure
+    sed -i "s|lrelease-qt4|lrelease|" src/src.pro
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Simple creation and editing of screenshots";
+    homepage = https://sourceforge.net/projects/qscreenshot/;
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/qview/default.nix b/nixpkgs/pkgs/applications/graphics/qview/default.nix
new file mode 100644
index 000000000000..0595ab2963ca
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/qview/default.nix
@@ -0,0 +1,22 @@
+{stdenv, fetchFromGitHub, qmake}:
+stdenv.mkDerivation rec {
+  pname = "qview";
+  version = "2.0";
+  src = fetchFromGitHub {
+    owner = "jurplel";
+    repo = "qView";
+    rev = version;
+    sha256 = "1s29hz44rb5dwzq8d4i4bfg77dr0v3ywpvidpa6xzg7hnnv3mhi5";
+  };
+  nativeBuildInputs = [ qmake ];
+  patchPhase = ''
+    sed "s|/usr/|$out/|g" -i qView.pro
+  '';
+  meta = with stdenv.lib; {
+    description = "Practical and minimal image viewer";
+    homepage = "https://interversehq.com/qview/";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ acowley ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/rapcad/default.nix b/nixpkgs/pkgs/applications/graphics/rapcad/default.nix
new file mode 100644
index 000000000000..7e9547c1067c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/rapcad/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub, fetchurl, cgal, boost, gmp, mpfr, flex, bison, dxflib, readline
+, qtbase, qmake, libGLU
+}:
+
+stdenv.mkDerivation rec {
+  version = "0.9.8";
+  pname = "rapcad";
+
+  src = fetchFromGitHub {
+    owner = "gilesbathgate";
+    repo = "rapcad";
+    rev = "v${version}";
+    sha256 = "0a0sqf6h227zalh0jrz6jpm8iwji7q3i31plqk76i4qm9vsgrhir";
+  };
+
+  patches = [
+    (fetchurl {
+      url = "https://github.com/GilesBathgate/RapCAD/commit/278a8d6c7b8fe08f867002528bbab4a6319a7bb6.patch";
+      sha256 = "1vvkyf0wg79zdzs5zlggfrr1lrp1x75dglzl0mspnycwldsdwznj";
+      name = "disable-QVector-qHash.patch";
+    })
+  ];
+
+  nativeBuildInputs = [ qmake ];
+  buildInputs = [ qtbase cgal boost gmp mpfr flex bison dxflib readline libGLU ];
+
+  meta = with stdenv.lib; {
+    license = licenses.gpl3;
+    maintainers = [ maintainers.raskin ];
+    platforms = platforms.linux;
+    description = ''Constructive solid geometry package'';
+    broken = true; # 2018-04-11
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/rapid-photo-downloader/default.nix b/nixpkgs/pkgs/applications/graphics/rapid-photo-downloader/default.nix
new file mode 100644
index 000000000000..28d05480dae1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/rapid-photo-downloader/default.nix
@@ -0,0 +1,86 @@
+{ stdenv, mkDerivationWith, fetchurl, python3Packages
+, file, intltool, gobject-introspection, libgudev
+, udisks, gexiv2, gst_all_1, libnotify
+, exiftool, gdk-pixbuf, libmediainfo, vmtouch
+}:
+
+mkDerivationWith python3Packages.buildPythonApplication rec {
+  pname = "rapid-photo-downloader";
+  version = "0.9.16";
+
+  src = fetchurl {
+    url = "https://launchpad.net/rapid/pyqt/${version}/+download/${pname}-${version}.tar.gz";
+    sha256 = "0ij3li17jcqjx79ldv6zg2ckn8m2l9n4xvvq2x79y4q8yx9fqg85";
+  };
+
+  # Disable version check and fix install tests
+  postPatch = ''
+    substituteInPlace raphodo/constants.py \
+      --replace "disable_version_check = False" "disable_version_check = True"
+    substituteInPlace raphodo/rescan.py \
+      --replace "from preferences" "from raphodo.preferences"
+  '';
+
+  nativeBuildInputs = [
+    file
+    intltool
+  ];
+
+  # Package has no generally usable unit tests.
+  # The included doctests expect specific, hardcoded hardware to be present.
+  doCheck = false;
+
+  # NOTE: Without gobject-introspection in buildInputs, launching fails with
+  #       "Namespace [Notify / GExiv2 / GUdev] not available"
+  buildInputs = [
+    gdk-pixbuf
+    gexiv2
+    gobject-introspection
+    gst_all_1.gst-libav
+    gst_all_1.gst-plugins-base
+    gst_all_1.gst-plugins-good
+    gst_all_1.gstreamer
+    gst_all_1.gstreamer.dev
+    libgudev
+    libnotify
+    udisks
+  ];
+
+  propagatedBuildInputs = with python3Packages; [
+    pyqt5
+    pygobject3
+    gphoto2
+    pyzmq
+    tornado
+    psutil
+    pyxdg
+    arrow
+    dateutil
+    easygui
+    colour
+    pymediainfo
+    sortedcontainers
+    rawkit
+    requests
+    colorlog
+    pyprind
+    tenacity
+  ];
+
+  makeWrapperArgs = [
+    "--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\""
+    "--set PYTHONPATH \"$PYTHONPATH\""
+    "--prefix PATH : ${stdenv.lib.makeBinPath [ exiftool vmtouch ]}"
+    "--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ libmediainfo ]}"
+    "--prefix GST_PLUGIN_SYSTEM_PATH_1_0 : \"$GST_PLUGIN_SYSTEM_PATH_1_0\""
+    "\${qtWrapperArgs[@]}"
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Photo and video importer for cameras, phones, and memory cards";
+    homepage = http://www.damonlynch.net/rapid/;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ jfrankenau ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/rawtherapee/default.nix b/nixpkgs/pkgs/applications/graphics/rawtherapee/default.nix
new file mode 100644
index 000000000000..74e8c0e6b434
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/rawtherapee/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromGitHub, pkgconfig, cmake, pixman, libpthreadstubs, gtkmm3, libXau
+, libXdmcp, lcms2, libiptcdata, libcanberra-gtk3, fftw, expat, pcre, libsigcxx, wrapGAppsHook
+, lensfun
+}:
+
+stdenv.mkDerivation rec {
+  version = "5.5";
+  name = "rawtherapee-" + version;
+
+  src = fetchFromGitHub {
+    owner = "Beep6581";
+    repo = "RawTherapee";
+    rev = version;
+    sha256 = "13clnx7rwkfa7wxgsim1xdx2pd7gwmmdad1m8a3fvywr20ml8xzk";
+  };
+
+  nativeBuildInputs = [ cmake pkgconfig wrapGAppsHook ];
+
+  buildInputs = [
+    pixman libpthreadstubs gtkmm3 libXau libXdmcp
+    lcms2 libiptcdata libcanberra-gtk3 fftw expat pcre libsigcxx lensfun
+  ];
+
+  cmakeFlags = [
+    "-DPROC_TARGET_NUMBER=2"
+    "-DCACHE_NAME_SUFFIX=\"\""
+  ];
+
+  CMAKE_CXX_FLAGS = "-std=c++11 -Wno-deprecated-declarations -Wno-unused-result";
+
+  postUnpack = ''
+    echo "set(HG_VERSION $version)" > $sourceRoot/ReleaseInfo.cmake
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "RAW converter and digital photo processing software";
+    homepage = http://www.rawtherapee.com/;
+    license = stdenv.lib.licenses.gpl3Plus;
+    maintainers = with stdenv.lib.maintainers; [ jcumming mahe the-kenny ];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/renderdoc/default.nix b/nixpkgs/pkgs/applications/graphics/renderdoc/default.nix
new file mode 100644
index 000000000000..594429503a35
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/renderdoc/default.nix
@@ -0,0 +1,73 @@
+{ stdenv, fetchFromGitHub, cmake, pkgconfig
+, qtbase, qtx11extras, qtsvg, makeWrapper
+, vulkan-loader, xorg
+, python3, bison, pcre, automake, autoconf
+}:
+let
+  custom_swig = fetchFromGitHub {
+    owner = "baldurk";
+    repo = "swig";
+    rev = "renderdoc-modified-6";
+    sha256 = "00ykqlzx1k9iwqjlc54kfch7cnzsj53hxn7ql70dj3rxqzrnadc0";
+  };
+in
+stdenv.mkDerivation rec {
+  version = "1.4";
+  pname = "renderdoc";
+
+  src = fetchFromGitHub {
+    owner = "baldurk";
+    repo = "renderdoc";
+    rev = "v${version}";
+    sha256 = "1iann73r4yzkwnm13h4zqipqrp5i5cnkv27yyap0axz6h3npw94r";
+  };
+
+  buildInputs = [
+    qtbase qtsvg xorg.libpthreadstubs xorg.libXdmcp qtx11extras vulkan-loader python3
+  ];
+
+  nativeBuildInputs = [ cmake makeWrapper pkgconfig bison pcre automake autoconf ];
+
+  postUnpack = ''
+    cp -r ${custom_swig} swig
+    chmod -R +w swig
+    patchShebangs swig/autogen.sh
+  '';
+
+  cmakeFlags = [
+    "-DBUILD_VERSION_HASH=${src.rev}"
+    "-DBUILD_VERSION_DIST_NAME=NixOS"
+    "-DBUILD_VERSION_DIST_VER=${version}"
+    "-DBUILD_VERSION_DIST_CONTACT=https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/graphics/renderdoc"
+    "-DBUILD_VERSION_STABLE=ON"
+    # TODO: add once pyside2 is in nixpkgs
+    #"-DPYSIDE2_PACKAGE_DIR=${python36Packages.pyside2}"
+  ];
+
+  # Future work: define these in the above array via placeholders
+  preConfigure = ''
+    cmakeFlags+=" -DVULKAN_LAYER_FOLDER=$out/share/vulkan/implicit_layer.d/"
+    cmakeFlags+=" -DRENDERDOC_SWIG_PACKAGE=$PWD/../swig"
+  '';
+
+  preFixup = ''
+    wrapProgram $out/bin/qrenderdoc --suffix LD_LIBRARY_PATH : $out/lib --suffix LD_LIBRARY_PATH : ${vulkan-loader}/lib
+    wrapProgram $out/bin/renderdoccmd --suffix LD_LIBRARY_PATH : $out/lib --suffix LD_LIBRARY_PATH : ${vulkan-loader}/lib
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "A single-frame graphics debugger";
+    homepage = https://renderdoc.org/;
+    license = licenses.mit;
+    longDescription = ''
+      RenderDoc is a free MIT licensed stand-alone graphics debugger that
+      allows quick and easy single-frame capture and detailed introspection
+      of any application using Vulkan, D3D11, OpenGL or D3D12 across
+      Windows 7 - 10, Linux or Android.
+    '';
+    maintainers = [maintainers.jansol];
+    platforms = ["i686-linux" "x86_64-linux"];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/runwayml/default.nix b/nixpkgs/pkgs/applications/graphics/runwayml/default.nix
new file mode 100644
index 000000000000..c527ce2b229a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/runwayml/default.nix
@@ -0,0 +1,45 @@
+{ lib
+, fetchurl
+, appimageTools
+, symlinkJoin
+}:
+
+let
+  pname = "runwayml";
+  version = "0.9.0";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "https://runway-releases.s3.amazonaws.com/Runway%20${version}.AppImage";
+    sha256 = "0rg7ipp7kx0l4qgcymfg5d3saz0c6d2j0c6rf28rwqgbm92gbjjq";
+    name="${pname}-${version}.AppImage";
+  };
+
+  binary = appimageTools.wrapType2 {
+    name = pname;
+    inherit src;
+  };
+  # we only use this to extract the icon
+  appimage-contents = appimageTools.extractType2 {
+    inherit name src;
+  };
+
+in
+  symlinkJoin {
+    inherit name;
+    paths = [ binary ];
+
+    postBuild = ''
+      mkdir -p $out/share/pixmaps/ $out/share/applications
+      cp ${appimage-contents}/usr/share/icons/hicolor/1024x1024/apps/runway.png $out/share/pixmaps/runway.png
+      sed 's:Exec=AppRun:Exec=runwayml:' ${appimage-contents}/runway.desktop > $out/share/applications/runway.desktop
+    '';
+
+  meta = with lib; {
+    description = "Machine learning for creators";
+    homepage = https://runwayml.com/;
+    license = licenses.unfree;
+    maintainers = with maintainers; [ prusnak ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/default.nix b/nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/default.nix
new file mode 100644
index 000000000000..b431cf51b019
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/default.nix
@@ -0,0 +1,94 @@
+{ stdenv, fetchurl, callPackage, patchelf, makeWrapper, coreutils, libusb }:
+
+let
+  myPatchElf = file: with stdenv.lib; ''
+    patchelf --set-interpreter \
+      ${stdenv.glibc}/lib/ld-linux${optionalString stdenv.is64bit "-x86-64"}.so.2 \
+      ${file}
+  '';
+
+  udevRules = callPackage ./udev_rules_type1.nix {};
+
+in stdenv.mkDerivation rec {
+  name = "brscan4-0.4.4-4";
+  src = 
+    if stdenv.hostPlatform.system == "i686-linux" then
+      fetchurl {
+        url = "http://download.brother.com/welcome/dlf006646/${name}.i386.deb";
+        sha256 = "13mhjbzf9nvpdzrc2s98684r7likg76zxs1wlz2h8w59fsqgx4k2";
+      }
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
+      fetchurl {
+        url = "https://download.brother.com/welcome/dlf006645/${name}.amd64.deb";
+        sha256 = "0xy5px96y1saq9l80vwvfn6anr2q42qlxdhm6ci2a0diwib5q9fd";
+      }
+    else throw "${name} is not supported on ${stdenv.hostPlatform.system} (only i686-linux and x86_64 linux are supported)";
+
+  unpackPhase = ''
+    ar x $src
+    tar xfvz data.tar.gz
+  '';
+
+  nativeBuildInputs = [ makeWrapper patchelf coreutils udevRules ];
+  buildInputs = [ libusb ];
+  dontBuild = true;
+
+  patchPhase = ''
+    ${myPatchElf "opt/brother/scanner/brscan4/brsaneconfig4"}
+
+    RPATH=${libusb.out}/lib
+    for a in usr/lib64/sane/*.so*; do
+      if ! test -L $a; then
+        patchelf --set-rpath $RPATH $a
+      fi
+    done
+  '';
+
+  installPhase = with stdenv.lib; ''
+    PATH_TO_BRSCAN4="opt/brother/scanner/brscan4"
+    mkdir -p $out/$PATH_TO_BRSCAN4
+    cp -rp $PATH_TO_BRSCAN4/* $out/$PATH_TO_BRSCAN4
+    mkdir -p $out/lib/sane
+    cp -rp usr/lib${optionalString stdenv.is64bit "64"}/sane/* $out/lib/sane
+
+    # Symbolic links were absolute. Fix them so that they point to $out.
+    pushd "$out/lib/sane" > /dev/null
+    for a in *.so*; do
+      if test -L $a; then
+        fixedTargetFileName="$(basename $(readlink $a))"
+        unlink "$a"
+        ln -s -T "$fixedTargetFileName" "$a"
+      fi
+    done
+    popd > /dev/null
+
+    # Generate an LD_PRELOAD wrapper to redirect execvp(), open() and open64()
+    # calls to `/opt/brother/scanner/brscan4`.
+    preload=$out/libexec/brother/scanner/brscan4/libpreload.so
+    mkdir -p $(dirname $preload)
+    gcc -shared ${./preload.c} -o $preload -ldl -DOUT=\"$out\" -fPIC
+
+    makeWrapper \
+      "$out/$PATH_TO_BRSCAN4/brsaneconfig4" \
+      "$out/bin/brsaneconfig4" \
+      --set LD_PRELOAD $preload
+
+    mkdir -p $out/etc/sane.d
+    echo "brother4" > $out/etc/sane.d/dll.conf
+
+    mkdir -p $out/etc/udev/rules.d
+    cp -p ${udevRules}/etc/udev/rules.d/*.rules \
+      $out/etc/udev/rules.d
+  '';
+
+  dontStrip = true;
+  dontPatchELF = true;
+
+  meta = {
+    description = "Brother brscan4 sane backend driver";
+    homepage = http://www.brother.com;
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.unfree;
+    maintainers = with stdenv.lib.maintainers; [ jraygauthier ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/preload.c b/nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/preload.c
new file mode 100644
index 000000000000..016162770934
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/preload.c
@@ -0,0 +1,170 @@
+/* Brgen4 search for configuration under `/etc/opt/brother/scanner/brscan4`. This
+   LD_PRELOAD library intercepts execvp(), open and open64 calls to redirect them to
+   the corresponding location in $out. Also support specifying an alternate
+   file name for `brsanenetdevice4.cfg` which otherwise is invariable
+   created at `/etc/opt/brother/scanner/brscan4`*/
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <string.h>
+#include <dirent.h>
+
+char origDir [] = "/etc/opt/brother/scanner/brscan4";
+char realDir [] = OUT "/opt/brother/scanner/brscan4";
+
+char devCfgFileNameEnvVar [] = "BRSANENETDEVICE4_CFG_FILENAME";
+char devCfgFileName [] = "/etc/opt/brother/scanner/brscan4//brsanenetdevice4.cfg";
+
+const char * rewrite(const char * path, char * buf)
+{
+    if (strncmp(path, devCfgFileName, sizeof(devCfgFileName)) == 0) {
+
+      const char* newCfgFileName = getenv(devCfgFileNameEnvVar);
+      if (!newCfgFileName) return path;
+
+      if (snprintf(buf, PATH_MAX, "%s", newCfgFileName) >= PATH_MAX)
+          abort();
+      return buf;
+    }
+
+    if (strncmp(path, origDir, sizeof(origDir) - 1) != 0) return path;
+    if (snprintf(buf, PATH_MAX, "%s%s", realDir, path + sizeof(origDir) - 1) >= PATH_MAX)
+        abort();
+    return buf;
+}
+
+const char* findAndReplaceFirstOccurence(const char* inStr, const char* subStr, 
+                                         const char* replaceStr, 
+                                         char* buf, unsigned maxBuf)
+{
+    const char* foundStr = strstr(inStr, subStr);
+    if (!foundStr)
+      return inStr;
+
+    const unsigned inStrLen = strlen(inStr);
+    const unsigned subStrLen = strlen(subStr);
+    const unsigned replaceStrLen = strlen(replaceStr);
+
+    const unsigned precedingStrLen = foundStr - inStr;
+    if (precedingStrLen + 1 > maxBuf)
+      return NULL;
+
+    const unsigned followingStrPos = precedingStrLen + subStrLen;
+    const unsigned followingStrLen = inStrLen - followingStrPos;
+
+    strncpy(buf, inStr, precedingStrLen);
+    unsigned outLength = precedingStrLen;
+
+    if (outLength + replaceStrLen + 1 > maxBuf)
+      return NULL;
+
+    strncpy(buf + outLength, replaceStr, replaceStrLen);
+    outLength += replaceStrLen;
+    
+    if (outLength + followingStrLen + 1 > maxBuf)
+      return NULL;
+
+    strncpy(buf + outLength, inStr + followingStrPos, followingStrLen);
+    outLength += followingStrLen;
+    
+    buf[outLength] = '\0';
+
+    return buf;
+}
+
+const char* rewriteSystemCall(const char* command, char* buf, unsigned maxBuf)
+{
+
+    const char* foundStr = strstr(command, devCfgFileName);
+    if (!foundStr)
+      return command;
+
+    const char* replaceStr = getenv(devCfgFileNameEnvVar);
+    if (!replaceStr) return command;
+
+    const char* result = 
+      findAndReplaceFirstOccurence(command, devCfgFileName, replaceStr, buf, maxBuf);
+
+    if (!result)
+      abort();
+
+    return result;
+}
+
+int execvp(const char * path, char * const argv[])
+{
+    int (*_execvp) (const char *, char * const argv[]) = dlsym(RTLD_NEXT, "execvp");
+    char buf[PATH_MAX];
+    return _execvp(rewrite(path, buf), argv);
+}
+
+
+int open(const char *path, int flags, ...)
+{
+    char buf[PATH_MAX];
+    int (*_open) (const char *, int, mode_t) = dlsym(RTLD_NEXT, "open");
+    mode_t mode = 0;
+    if (flags & O_CREAT) {
+        va_list ap;
+        va_start(ap, flags);
+        mode = va_arg(ap, mode_t);
+        va_end(ap);
+    }
+    return _open(rewrite(path, buf), flags, mode);
+}
+
+int open64(const char *path, int flags, ...)
+{
+    char buf[PATH_MAX];
+    int (*_open64) (const char *, int, mode_t) = dlsym(RTLD_NEXT, "open64");
+    mode_t mode = 0;
+    if (flags & O_CREAT) {
+        va_list ap;
+        va_start(ap, flags);
+        mode = va_arg(ap, mode_t);
+        va_end(ap);
+    }
+    return _open64(rewrite(path, buf), flags, mode);
+}
+
+FILE* fopen(const char* path, const char* mode)
+{
+  char buf[PATH_MAX];
+	FILE* (*_fopen) (const char*, const char*) = dlsym(RTLD_NEXT, "fopen");
+
+	return _fopen(rewrite(path, buf), mode);
+}
+
+FILE *fopen64(const char *path, const char *mode)
+{
+  char buf[PATH_MAX];
+	FILE* (*_fopen64) (const char*, const char*) = dlsym(RTLD_NEXT, "fopen64");
+
+	return _fopen64(rewrite(path, buf), mode);
+}
+
+DIR* opendir(const char* path)
+{
+  char buf[PATH_MAX];
+	DIR* (*_opendir) (const char*) = dlsym(RTLD_NEXT, "opendir");
+
+	return _opendir(rewrite(path, buf));
+}
+
+#define SYSTEM_CMD_MAX 512
+
+int system(const char *command)
+{
+    char buf[SYSTEM_CMD_MAX];
+    int (*_system) (const char*) = dlsym(RTLD_NEXT, "system");
+
+    const char* newCommand = rewriteSystemCall(command, buf, SYSTEM_CMD_MAX);
+    return _system(newCommand);
+}
diff --git a/nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix b/nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix
new file mode 100644
index 000000000000..da136a7f9e1e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/backends/brscan4/udev_rules_type1.nix
@@ -0,0 +1,55 @@
+{ stdenv, fetchurl, libsaneUDevRuleNumber ? "49"}:
+
+stdenv.mkDerivation rec {
+  name = "brother-udev-rule-type1-1.0.0-1";
+
+  src = fetchurl {
+    url = "http://download.brother.com/welcome/dlf006654/${name}.all.deb";
+    sha256 = "0i0x5jw135pli4jl9mgnr5n2rrdvml57nw84yq2999r4frza53xi";
+  };
+
+  dontBuild = true;
+
+  unpackPhase = ''
+    ar x $src
+    tar xfvz data.tar.gz
+  '';
+
+  /*
+    Fix the following error:
+
+    ~~~
+    invalid rule 49-brother-libsane-type1.rules
+    unknown key 'SYSFS{idVendor}'
+    ~~~
+
+    Apparently the udev rules syntax has change and the SYSFS key has to
+    be changed to ATTR.
+
+    See:
+
+     -  <http://ubuntuforums.org/showthread.php?t=1496878>
+     -  <http://www.planet-libre.org/index.php?post_id=10937>
+  */
+  patchPhase = ''
+    sed -i -e s/SYSFS/ATTR/g opt/brother/scanner/udev-rules/type1/*.rules
+  '';
+
+  installPhase = ''
+    mkdir -p $out/etc/udev/rules.d
+    cp opt/brother/scanner/udev-rules/type1/NN-brother-mfp-type1.rules \
+      $out/etc/udev/rules.d/${libsaneUDevRuleNumber}-brother-libsane-type1.rules
+    chmod 644 $out/etc/udev/rules.d/${libsaneUDevRuleNumber}-brother-libsane-type1.rules
+  '';
+
+  dontStrip = true;
+  dontPatchELF = true;
+
+  meta = {
+    description = "Brother type1 scanners udev rules";
+    homepage = http://www.brother.com;
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.unfree;
+    maintainers = with stdenv.lib.maintainers; [ jraygauthier ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/sane/backends/default.nix b/nixpkgs/pkgs/applications/graphics/sane/backends/default.nix
new file mode 100644
index 000000000000..20d5629b83a9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/backends/default.nix
@@ -0,0 +1,11 @@
+{ callPackage, fetchurl, ... } @ args:
+
+callPackage ./generic.nix (args // rec {
+  version = "1.0.27";
+  src = fetchurl {
+    sha256 = "1j9nbqspaj0rlgalafb5z6r606k0i22kz0rcpd744p176yzlfdr9";
+    urls = [
+      "https://alioth.debian.org/frs/download.php/latestfile/176/sane-backends-${version}.tar.gz"
+    ];
+  };
+})
diff --git a/nixpkgs/pkgs/applications/graphics/sane/backends/dsseries/default.nix b/nixpkgs/pkgs/applications/graphics/sane/backends/dsseries/default.nix
new file mode 100644
index 000000000000..d4165be3784f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/backends/dsseries/default.nix
@@ -0,0 +1,53 @@
+{ stdenv, fetchurl, rpmextract }:
+
+stdenv.mkDerivation rec {
+  pname = "libsane-dsseries";
+  version = "1.0.5-1";
+
+  src = fetchurl {
+    url = "https://download.brother.com/welcome/dlf100974/${pname}-${version}.x86_64.rpm";
+    sha256 = "1wfdbfbf51cc7njzikdg48kwpnpc0pg5s6p0s0y3z0q7y59x2wbq";
+  };
+
+  nativeBuildInputs = [ rpmextract ];
+
+  unpackCmd = ''
+    mkdir ${pname}-${version} && pushd ${pname}-${version}
+    rpmextract $curSrc
+    popd
+  '';
+
+  patchPhase = ''
+    substituteInPlace etc/udev/rules.d/50-Brother_DSScanner.rules \
+      --replace 'GROUP="users"' 'GROUP="scanner", ENV{libsane_matched}="yes"'
+
+    mkdir -p etc/sane.d/dll.d
+    echo "dsseries" > etc/sane.d/dll.d/dsseries.conf
+  '';
+
+  installPhase = ''
+    mkdir -p $out
+    cp -dr etc $out
+    cp -dr usr/lib64 $out/lib
+  '';
+
+  preFixup = ''
+    for f in `find $out/lib/sane/ -type f`; do
+      # Make it possible to find libstdc++.so.6
+      patchelf --set-rpath ${stdenv.cc.cc.lib}/lib:$out/lib/sane $f
+
+      # Horrible kludge: The driver hardcodes /usr/lib/sane/ as a dlopen path.
+      # We can directly modify the binary to force a relative lookup instead.
+      # The new path is NULL-padded to the same length as the original path.
+      sed -i "s|/usr/lib/sane/%s|%s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|g" $f
+    done
+  '';
+
+  meta = {
+    description = "Brother DSSeries SANE backend driver";
+    homepage = http://www.brother.com;
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.unfree;
+    maintainers = with stdenv.lib.maintainers; [ callahad ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/sane/backends/generic.nix b/nixpkgs/pkgs/applications/graphics/sane/backends/generic.nix
new file mode 100644
index 000000000000..0f47c82f0325
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/backends/generic.nix
@@ -0,0 +1,77 @@
+{ stdenv
+, avahi, libjpeg, libusb1, libv4l, net_snmp, libpng
+, gettext, pkgconfig
+
+# List of { src name backend } attibute sets - see installFirmware below:
+, extraFirmware ? []
+
+# For backwards compatibility with older setups; use extraFirmware instead:
+, gt68xxFirmware ? null, snapscanFirmware ? null
+
+# Passed from versioned package (e.g. default.nix, git.nix):
+, version, src, ...
+}:
+
+stdenv.mkDerivation {
+  inherit src version;
+
+  name = "sane-backends-${version}";
+
+  outputs = [ "out" "doc" "man" ];
+
+  configureFlags = []
+    ++ stdenv.lib.optional (avahi != null)   "--enable-avahi"
+    ++ stdenv.lib.optional (libusb1 != null) "--enable-libusb_1_0"
+    ;
+
+  buildInputs = [ avahi libusb1 libv4l net_snmp libpng ];
+  nativeBuildInputs = [ gettext pkgconfig ];
+  enableParallelBuilding = true;
+
+  postInstall = let
+
+    compatFirmware = extraFirmware
+      ++ stdenv.lib.optional (gt68xxFirmware != null) {
+        src = gt68xxFirmware.fw;
+        inherit (gt68xxFirmware) name;
+        backend = "gt68xx";
+      }
+      ++ stdenv.lib.optional (snapscanFirmware != null) {
+        src = snapscanFirmware;
+        name = "your-firmwarefile.bin";
+        backend = "snapscan";
+      };
+
+    installFirmware = f: ''
+      mkdir -p $out/share/sane/${f.backend}
+      ln -sv ${f.src} $out/share/sane/${f.backend}/${f.name}
+    '';
+
+  in ''
+    mkdir -p $out/etc/udev/rules.d/
+    ./tools/sane-desc -m udev > $out/etc/udev/rules.d/49-libsane.rules || \
+    cp tools/udev/libsane.rules $out/etc/udev/rules.d/49-libsane.rules
+    # the created 49-libsane references /bin/sh
+    substituteInPlace $out/etc/udev/rules.d/49-libsane.rules \
+      --replace "RUN+=\"/bin/sh" "RUN+=\"${stdenv.shell}"
+
+    substituteInPlace $out/lib/libsane.la \
+      --replace "-ljpeg" "-L${libjpeg.out}/lib -ljpeg"
+  '' + stdenv.lib.concatStrings (builtins.map installFirmware compatFirmware);
+
+  meta = with stdenv.lib; {
+    description = "SANE (Scanner Access Now Easy) backends";
+    longDescription = ''
+      Collection of open-source SANE backends (device drivers).
+      SANE is a universal scanner interface providing standardized access to
+      any raster image scanner hardware: flatbed scanners, hand-held scanners,
+      video- and still-cameras, frame-grabbers, etc. For a list of supported
+      scanners, see http://www.sane-project.org/sane-backends.html.
+    '';
+    homepage = http://www.sane-project.org/;
+    license = licenses.gpl2Plus;
+
+    maintainers = with maintainers; [ peti ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/sane/backends/git.nix b/nixpkgs/pkgs/applications/graphics/sane/backends/git.nix
new file mode 100644
index 000000000000..e746f83e5d49
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/backends/git.nix
@@ -0,0 +1,10 @@
+{ callPackage, fetchgit, ... } @ args:
+
+callPackage ./generic.nix (args // {
+  version = "2017-12-01";
+  src = fetchgit {
+    sha256 = "0qf7d7268kdxnb723c03m6icxhbgx0vw8gqvck2q1w5b948dy9g8";
+    rev = "e895ee55bec8a3320a0e972b32c05d35b47fe226";
+    url = "git://alioth.debian.org/git/sane/sane-backends.git";
+  };
+})
diff --git a/nixpkgs/pkgs/applications/graphics/sane/config.nix b/nixpkgs/pkgs/applications/graphics/sane/config.nix
new file mode 100644
index 000000000000..c0a0206ddd1f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/config.nix
@@ -0,0 +1,38 @@
+{ stdenv }:
+
+{ paths }:
+
+with stdenv.lib;
+let installSanePath = path: ''
+      if [ -e "${path}/lib/sane" ]; then
+        find "${path}/lib/sane" -maxdepth 1 -not -type d | while read backend; do
+          ln -s "$backend" "$out/lib/sane/$(basename "$backend")"
+        done
+      fi
+
+      if [ -e "${path}/etc/sane.d" ]; then
+        find "${path}/etc/sane.d" -maxdepth 1 -not -type d | while read conf; do
+          name="$(basename $conf)"
+          if [ "$name" = "dll.conf" ] || [ "$name" = "saned.conf" ] || [ "$name" = "net.conf" ]; then
+            cat "$conf" >> "$out/etc/sane.d/$name"
+          else
+            ln -s "$conf" "$out/etc/sane.d/$name"
+          fi
+        done
+      fi
+
+      if [ -e "${path}/etc/sane.d/dll.d" ]; then
+        find "${path}/etc/sane.d/dll.d" -maxdepth 1 -not -type d | while read conf; do
+          ln -s "$conf" "$out/etc/sane.d/dll.d/$(basename $conf)"
+        done
+      fi
+    '';
+in
+stdenv.mkDerivation {
+  name = "sane-config";
+  phases = "installPhase";
+
+  installPhase = ''
+    mkdir -p $out/etc/sane.d $out/etc/sane.d/dll.d $out/lib/sane
+  '' + concatMapStrings installSanePath paths;
+}
diff --git a/nixpkgs/pkgs/applications/graphics/sane/frontends.nix b/nixpkgs/pkgs/applications/graphics/sane/frontends.nix
new file mode 100644
index 000000000000..66473c4a155f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/frontends.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, sane-backends, libX11, gtk2, pkgconfig, libusb ? null }:
+
+stdenv.mkDerivation rec {
+  pname = "sane-frontends";
+  version = "1.0.14";
+
+  src = fetchurl {
+    url = "https://alioth.debian.org/frs/download.php/latestfile/175/${pname}-${version}.tar.gz";
+    sha256 = "1ad4zr7rcxpda8yzvfkq1rfjgx9nl6lan5a628wvpdbh3fn9v0z7";
+  };
+
+  preConfigure = ''
+    sed -e '/SANE_CAP_ALWAYS_SETTABLE/d' -i src/gtkglue.c
+  '';
+
+  buildInputs = [ sane-backends libX11 gtk2 ]
+    ++ stdenv.lib.optional (libusb != null) libusb;
+  nativeBuildInputs = [ pkgconfig ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Scanner Access Now Easy";
+    homepage    = http://www.sane-project.org/;
+    license     = licenses.gpl2Plus;
+    maintainers = with maintainers; [ peti ];
+    platforms   = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/sane/xsane.nix b/nixpkgs/pkgs/applications/graphics/sane/xsane.nix
new file mode 100644
index 000000000000..09b431fdb116
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sane/xsane.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, sane-backends, sane-frontends, libX11, gtk2, pkgconfig, libpng
+, libusb ? null
+, gimpSupport ? false, gimp ? null
+}:
+
+assert gimpSupport -> gimp != null;
+
+stdenv.mkDerivation rec {
+  name = "xsane-0.999";
+
+  src = fetchurl {
+    url = "http://www.xsane.org/download/${name}.tar.gz";
+    sha256 = "0jrb918sfb9jw3vmrz0z7np4q55hgsqqffpixs0ir5nwcwzd50jp";
+  };
+
+  preConfigure = ''
+    sed -e '/SANE_CAP_ALWAYS_SETTABLE/d' -i src/xsane-back-gtk.c
+    chmod a+rX -R .
+  '';
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [libpng sane-backends sane-frontends libX11 gtk2 ]
+    ++ (if libusb != null then [libusb] else [])
+    ++ stdenv.lib.optional gimpSupport gimp;
+
+  meta = {
+    homepage = http://www.sane-project.org/;
+    description = "Graphical scanning frontend for sane";
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [peti];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/scantailor/advanced.nix b/nixpkgs/pkgs/applications/graphics/scantailor/advanced.nix
new file mode 100644
index 000000000000..63f16f688acd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/scantailor/advanced.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub
+, cmake, libjpeg, libpng, libtiff, boost
+, qtbase, qttools }:
+
+stdenv.mkDerivation rec {
+  pname = "scantailor-advanced";
+  version = "1.0.16";
+
+  src = fetchFromGitHub {
+    owner = "4lex4";
+    repo = "scantailor-advanced";
+    rev = "v${version}";
+    sha256 = "0lc9lzbpiy5hgimyhl4s4q67pb9gacpy985gl6iy8pl79zxhmcyp";
+  };
+
+  nativeBuildInputs = [ cmake qttools ];
+  buildInputs = [ libjpeg libpng libtiff boost qtbase ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/4lex4/scantailor-advanced;
+    description = "Interactive post-processing tool for scanned pages";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ jfrankenau ];
+    platforms = with platforms; gnu ++ linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/scantailor/default.nix b/nixpkgs/pkgs/applications/graphics/scantailor/default.nix
new file mode 100644
index 000000000000..14efe48f30db
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/scantailor/default.nix
@@ -0,0 +1,24 @@
+{stdenv, fetchurl, qt4, cmake, libjpeg, libtiff, boost }:
+
+stdenv.mkDerivation {
+  name = "scantailor-0.9.12.1";
+
+  src = fetchurl {
+    url = "https://github.com/scantailor/scantailor/archive/RELEASE_0_9_12_1.tar.gz";
+    sha256 = "1pjx3a6hs16az6rki59bchy3biy7jndjx8r125q01aq7lbf5npgg";
+  };
+
+  buildInputs = [ qt4 cmake libjpeg libtiff boost ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    homepage = http://scantailor.org/;
+    description = "Interactive post-processing tool for scanned pages";
+
+    license = stdenv.lib.licenses.gpl3Plus;
+
+    maintainers = [ stdenv.lib.maintainers.viric ];
+    platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/screencloud/default.nix b/nixpkgs/pkgs/applications/graphics/screencloud/default.nix
new file mode 100644
index 000000000000..88bbbd9d8646
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/screencloud/default.nix
@@ -0,0 +1,77 @@
+{ stdenv, fetchFromGitHub, cmake, qt4, quazip, qt-mobility, qxt, pythonPackages }:
+
+with stdenv.lib;
+stdenv.mkDerivation rec {
+  pname = "screencloud";
+  version = "1.2.0";
+
+  # API Keys. According to the author of the AUR package, these are only used
+  # for tracking usage.
+  consumerKey = "23e747012c68601f27ab69c6de129ed70552d55b6";
+  consumerSecret = "4701cb00c1bd357bbcae7c3d713dd216";
+  
+  src = fetchFromGitHub {
+    owner = "olav-st";
+    repo = "screencloud";
+    rev = "v${version}";
+    sha256 = "1s0dxa1sa37nvna5nfqdsp294810favj68qb7ghl78qna7zw0cim";
+  };
+
+  buildInputs = [ cmake qt4 quazip qt-mobility qxt pythonPackages.python pythonPackages.pycrypto ];
+
+  patchPhase = ''
+    # Required to make the configure script work. Normally, screencloud's
+    # CMakeLists file sets the install prefix to /opt by force. This is stupid
+    # and breaks nix, so we force it to install where we want. Please don't
+    # write CMakeLists files like this, as things like this are why we can't
+    # have nice things.
+    substituteInPlace "CMakeLists.txt" --replace "set(CMAKE_INSTALL_PREFIX \"/opt\")" ""
+  '';
+
+  enableParallelBuilding = true;
+
+  # We need to append /opt to our CMAKE_INSTALL_PREFIX, so we tell the Nix not
+  # to add the argument for us.
+  dontAddPrefix = true;
+
+  cmakeFlags = [
+    "-DQXT_QXTCORE_INCLUDE_DIR=${qxt}/include/QxtCore"
+    "-DQXT_QXTCORE_LIB_RELEASE=${qxt}/lib/libQxtCore.so"
+    "-DQXT_QXTGUI_INCLUDE_DIR=${qxt}/include/QxtGui"
+    "-DQXT_QXTGUI_LIB_RELEASE=${qxt}/lib/libQxtGui.so"
+    "-DCONSUMER_KEY_SCREENCLOUD=${consumerKey}"
+    "-DCONSUMER_SECRET_SCREENCLOUD=${consumerSecret}"
+  ];
+
+  setSourceRoot = ''
+    sourceRoot=$(echo */screencloud)
+  '';
+
+  preConfigure = ''
+    # This needs to be set in preConfigure instead of cmakeFlags in order to
+    # access the $prefix environment variable.
+    export cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix/opt $cmakeFlags"
+  '';
+
+  # There are a number of issues with screencloud's installation. We need to add
+  # pycrypto to the PYTHONPATH so that the SFTP plugin will work properly; and
+  # we need to move the libPythonQt library into a folder where it can actually
+  # be found.
+  postInstall = ''
+    patchShebangs $prefix/opt/screencloud/screencloud.sh
+    substituteInPlace "$prefix/opt/screencloud/screencloud.sh" --replace "/opt" "$prefix/opt"
+    sed -i "2 i\export PYTHONPATH=$(toPythonPath ${pythonPackages.pycrypto}):\$PYTHONPATH" "$prefix/opt/screencloud/screencloud.sh"
+    mkdir $prefix/bin
+    mkdir $prefix/lib
+    ln -s $prefix/opt/screencloud/screencloud.sh $prefix/bin/screencloud
+    ln -s $prefix/opt/screencloud/libPythonQt.so $prefix/lib/libPythonQt.so
+  '';
+
+  meta = {
+    homepage = https://screencloud.net/;
+    description = "Client for Screencloud, an easy to use screenshot sharing tool";
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = with stdenv.lib.maintainers; [ forkk ];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/seg3d/cstdio.patch b/nixpkgs/pkgs/applications/graphics/seg3d/cstdio.patch
new file mode 100644
index 000000000000..0d9eed07a367
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/seg3d/cstdio.patch
@@ -0,0 +1,81 @@
+diff --git a/Core/Geometry/Transform.cc b/Core/Geometry/Transform.cc
+index 4f16fdc..0da4679 100644
+--- a/Core/Geometry/Transform.cc
++++ b/Core/Geometry/Transform.cc
+@@ -28,6 +28,7 @@
+ 
+ #include <cassert>
+ #include <cstring>
++#include <cstdio>
+ 
+ #include <Core/Util/TypeDescription.h>
+ #include <Core/Geometry/Transform.h>
+diff --git a/Core/Util/FullFileName.cc b/Core/Util/FullFileName.cc
+index 7a2cad7..7710e92 100644
+--- a/Core/Util/FullFileName.cc
++++ b/Core/Util/FullFileName.cc
+@@ -29,6 +29,7 @@
+ 
+ #include <Core/Util/FullFileName.h>
+ #include <iostream>
++#include <cstdio>
+ 
+ namespace SCIRun {
+ 
+diff --git a/Externals/particle-system-mm/src/sizingfield/LFS.cxx b/Externals/particle-system-mm/src/sizingfield/LFS.cxx
+index d1fa5aa..a5a4358 100644
+--- a/Externals/particle-system-mm/src/sizingfield/LFS.cxx
++++ b/Externals/particle-system-mm/src/sizingfield/LFS.cxx
+@@ -1,5 +1,6 @@
+ #include <cstdlib>
+ #include <iostream>
++#include <cstdio>
+ #include <LFS.h>
+ 
+ using namespace std;
+diff --git a/Externals/slivr/Point.cc b/Externals/slivr/Point.cc
+index d3be03e..ed4e503 100644
+--- a/Externals/slivr/Point.cc
++++ b/Externals/slivr/Point.cc
+@@ -42,6 +42,7 @@
+ #include <slivr/Point.h>
+ #include <slivr/Vector.h>
+ #include <iostream>
++#include <cstdio>
+ 
+ namespace SLIVR {
+ 
+diff --git a/Externals/slivr/Transform.cc b/Externals/slivr/Transform.cc
+index c0a4430..520179f 100644
+--- a/Externals/slivr/Transform.cc
++++ b/Externals/slivr/Transform.cc
+@@ -47,6 +47,7 @@
+ #include <math.h>
+ #include <string.h>
+ #include <iostream>
++#include <cstdio>
+ 
+ using namespace SLIVR;
+ using namespace std;
+diff --git a/Externals/slivr/Vector.cc b/Externals/slivr/Vector.cc
+index 8370d65..8b04bb9 100644
+--- a/Externals/slivr/Vector.cc
++++ b/Externals/slivr/Vector.cc
+@@ -43,6 +43,7 @@
+ #include <slivr/Point.h>
+ #include <assert.h>
+ #include <iostream>
++#include <cstdio>
+ 
+ using std::istream;
+ using std::ostream;
+diff --git a/Externals/vispack/src/image/imagefile.txx b/Externals/vispack/src/image/imagefile.txx
+index ced2590..13a32b2 100644
+--- a/Externals/vispack/src/image/imagefile.txx
++++ b/Externals/vispack/src/image/imagefile.txx
+@@ -1,3 +1,5 @@
++#include <cstdio>
++
+ template <class T>
+ int write_raw(const char* name, const VISImage<T>& im)
+ {
diff --git a/nixpkgs/pkgs/applications/graphics/seg3d/default.nix b/nixpkgs/pkgs/applications/graphics/seg3d/default.nix
new file mode 100644
index 000000000000..58cec2ec1703
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/seg3d/default.nix
@@ -0,0 +1,54 @@
+{ fetchurl, stdenv, cmake, wxGTK, itk, libGLU_combined, libXft, libXext, libXi, zlib, libXmu,
+libuuid }:
+
+assert (stdenv ? glibc);
+
+stdenv.mkDerivation {
+  name = "seg3d-1.12_20090930";
+  src = fetchurl {
+    url = https://www.sci.utah.edu/releases/seg3d_v1.12/Seg3D_1.12_20090930_source.tgz;
+    sha256 = "1wr6rc6v5qjjkmws8yrc03z35h3iydxk1z28p06v1wdnca0y71z8";
+  };
+
+  patches = [ ./cstdio.patch ];
+
+  cmakeFlags = [
+    "-DM_LIBRARY=${stdenv.glibc.out}/lib/libm.so"
+    "-DDL_LIBRARY=${stdenv.glibc.out}/lib/libdl.so"
+    "-DBUILD_UTILS=1"
+    "-DBUILD_SEG3D=1"
+    "-DBUILD_DATAFLOW=0"
+    "-DBUILD_SHARED_LIBS=0"
+    "-DWITH_X11=1"
+    "-DBUILD_BIOMESH3D=1"
+    "-DWITH_TETGEN=1"
+    "-DBUILD_TYPE=Release"
+    "-DWITH_WXWIDGETS=ON"
+    "-DITK_DIR=${itk}/lib/InsightToolkit"
+    "-DGDCM_LIBRARY=${itk}/lib/libitkgdcm.a"
+  ];
+
+
+  makeFlags = "VERBOSE=1";
+
+  preBuild = ''
+    export LD_LIBRARY_PATH=`pwd`/lib
+    export NIX_LDFLAGS="$NIX_LDFLAGS -lGLU -lSM -lICE -lX11 -lXext -luuid";
+  '';
+
+  preUnpack = ''
+    set -x
+    sourceRoot=`pwd`/src
+  '';
+
+  postInstall = ''
+    cp Seg3D $out/bin
+    exit 1
+  '';
+
+  buildInputs = [ cmake wxGTK itk libGLU_combined libXft libXext libXi zlib libXmu libuuid ];
+
+  meta = {
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/shotwell/default.nix b/nixpkgs/pkgs/applications/graphics/shotwell/default.nix
new file mode 100644
index 000000000000..79bc743fbf01
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/shotwell/default.nix
@@ -0,0 +1,108 @@
+{ stdenv
+, fetchurl
+, meson
+, ninja
+, gtk3
+, libexif
+, libgphoto2
+, libwebp
+, libsoup
+, libxml2
+, vala
+, sqlite
+, webkitgtk
+, pkgconfig
+, gnome3
+, gst_all_1
+, libgudev
+, libraw
+, glib
+, json-glib
+, gcr
+, libgee
+, gexiv2
+, librest
+, gettext
+, desktop-file-utils
+, gdk-pixbuf
+, librsvg
+, wrapGAppsHook
+, gobject-introspection
+, itstool
+, libgdata
+, libchamplain
+, gsettings-desktop-schemas
+, python3
+}:
+
+# for dependencies see https://wiki.gnome.org/Apps/Shotwell/BuildingAndInstalling
+
+stdenv.mkDerivation rec {
+  pname = "shotwell";
+  version = "0.31.0";
+
+  src = fetchurl {
+    url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
+    sha256 = "1pwq953wl7h9cvw7rvlr6pcbq9w28kkr7ddb8x2si81ngp0imwyx";
+  };
+
+  nativeBuildInputs = [
+    meson
+    ninja
+    vala
+    pkgconfig
+    itstool
+    gettext
+    desktop-file-utils
+    python3
+    wrapGAppsHook
+    gobject-introspection
+  ];
+
+  buildInputs = [
+    gtk3
+    libexif
+    libgphoto2
+    libwebp
+    libsoup
+    libxml2
+    sqlite
+    webkitgtk
+    gst_all_1.gstreamer
+    gst_all_1.gst-plugins-base
+    libgee
+    libgudev
+    gexiv2
+    gsettings-desktop-schemas
+    libraw
+    json-glib
+    glib
+    gdk-pixbuf
+    librsvg
+    librest
+    gcr
+    gnome3.adwaita-icon-theme
+    libgdata
+    libchamplain
+  ];
+
+  postPatch = ''
+    chmod +x build-aux/meson/postinstall.py # patchShebangs requires executable file
+    patchShebangs build-aux/meson/postinstall.py
+  '';
+
+  passthru = {
+    updateScript = gnome3.updateScript {
+      packageName = pname;
+      versionPolicy = "none";
+    };
+  };
+
+  meta = with stdenv.lib; {
+    description = "Popular photo organizer for the GNOME desktop";
+    homepage = https://wiki.gnome.org/Apps/Shotwell;
+    license = licenses.lgpl21Plus;
+    maintainers = with maintainers; [domenkozar];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/shutter/default.nix b/nixpkgs/pkgs/applications/graphics/shutter/default.nix
new file mode 100644
index 000000000000..957692b4ba17
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/shutter/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchurl, perlPackages, makeWrapper, imagemagick, gdk-pixbuf, librsvg
+, hicolor-icon-theme, procps
+}:
+
+let
+  perlModules = with perlPackages;
+    [ Gnome2 Gnome2Canvas Gtk2 Glib Pango Gnome2VFS Gnome2Wnck Gtk2ImageView
+      Gtk2Unique FileBaseDir FileWhich FileCopyRecursive XMLSimple NetDBus XMLTwig
+      XMLParser HTTPMessage ProcSimple SortNaturally LocaleGettext
+      ProcProcessTable URI ImageExifTool Gtk2AppIndicator LWP JSON
+      PerlMagick WWWMechanize HTTPDate HTMLForm HTMLParser HTMLTagset JSONMaybeXS
+      commonsense HTTPCookies NetOAuth PathClass GooCanvas X11Protocol Cairo
+      EncodeLocale TryTiny TypesSerialiser LWPMediaTypes
+    ];
+in
+stdenv.mkDerivation {
+  name = "shutter-0.94.3";
+
+  src = fetchurl {
+    url = "https://launchpad.net/shutter/0.9x/0.94.3/+download/shutter-0.94.3.tar.gz";
+    sha256 = "01wv5k6zqfqa2rss461lpdpjxpfk4awzfdc6j2qk6bh4g4zgmgl5";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ perlPackages.perl procps gdk-pixbuf librsvg ] ++ perlModules;
+
+  installPhase = ''
+    mkdir -p "$out"
+    cp -a . "$out"
+    (cd "$out" && mv CHANGES README COPYING "$out/share/doc/shutter")
+
+    wrapProgram $out/bin/shutter \
+      --set PERL5LIB "${perlPackages.makePerlPath perlModules}" \
+      --prefix PATH : "${imagemagick.out}/bin" \
+      --suffix XDG_DATA_DIRS : "${hicolor-icon-theme}/share" \
+      --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Screenshot and annotation tool";
+    homepage = http://shutter-project.org/;
+    license = licenses.gpl3Plus;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/smartdeblur/default.nix b/nixpkgs/pkgs/applications/graphics/smartdeblur/default.nix
new file mode 100644
index 000000000000..377a5ae61687
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/smartdeblur/default.nix
@@ -0,0 +1,32 @@
+{ fetchurl, stdenv, cmake, qt4, fftw }:
+
+let
+  rev = "9895036d26";
+in
+stdenv.mkDerivation rec {
+  name = "smartdeblur-git-${rev}";
+
+  src = fetchurl {
+    url = "https://github.com/Y-Vladimir/SmartDeblur/tarball/${rev}";
+    name = "${name}.tar.gz";
+    sha256 = "126x9x1zhqdarjz9in0p1qhmqg3jwz7frizadjvx723g2ppi33s4";
+  };
+
+  preConfigure = ''
+    cd src
+  '';
+
+  enableParallelBuilding = true;
+
+  buildInputs = [ cmake qt4 fftw ];
+
+  cmakeFlags = "-DUSE_SYSTEM_FFTW=ON";
+
+  meta = {
+    homepage = https://github.com/Y-Vladimir/SmartDeblur;
+    description = "Tool for restoring blurry and defocused images";
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [ ];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/solvespace/default.nix b/nixpkgs/pkgs/applications/graphics/solvespace/default.nix
new file mode 100644
index 000000000000..7046caad295e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/solvespace/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, fetchgit, cmake, pkgconfig, zlib, libpng, cairo, freetype
+, json_c, fontconfig, gtkmm3, pangomm, glew, libGLU, xorg, pcre
+, wrapGAppsHook
+}:
+stdenv.mkDerivation rec {
+  name = "solvespace-2.3-20190501";
+  rev = "e7b75f19c34c923780db776592b47152650d8f22";
+  src = fetchgit {
+    url = https://github.com/solvespace/solvespace;
+    inherit rev;
+    sha256 = "07k4mbzxf0dmzwdhjx5nc09y7rn1schkaypsw9kz0l7ppylprpp2";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [
+    pkgconfig cmake wrapGAppsHook
+  ];
+  buildInputs = [
+    zlib libpng cairo freetype
+    json_c fontconfig gtkmm3 pangomm glew libGLU
+    xorg.libpthreadstubs xorg.libXdmcp pcre
+  ];
+  enableParallelBuilding = true;
+
+  preConfigure = ''
+    patch CMakeLists.txt <<EOF
+    @@ -20,9 +20,9 @@
+     # NOTE TO PACKAGERS: The embedded git commit hash is critical for rapid bug triage when the builds
+     # can come from a variety of sources. If you are mirroring the sources or otherwise build when
+     # the .git directory is not present, please comment the following line:
+    -include(GetGitCommitHash)
+    +# include(GetGitCommitHash)
+     # and instead uncomment the following, adding the complete git hash of the checkout you are using:
+    -# set(GIT_COMMIT_HASH 0000000000000000000000000000000000000000)
+    +set(GIT_COMMIT_HASH $rev)
+    EOF
+  '';
+
+  postInstall = ''
+    substituteInPlace $out/share/applications/solvespace.desktop \
+      --replace /usr/bin/ $out/bin/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A parametric 3d CAD program";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.edef ];
+    platforms = platforms.linux;
+    homepage = http://solvespace.com;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/swingsane/default.nix b/nixpkgs/pkgs/applications/graphics/swingsane/default.nix
new file mode 100644
index 000000000000..f56646e5aedd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/swingsane/default.nix
@@ -0,0 +1,61 @@
+{ stdenv, fetchurl, makeDesktopItem, unzip, jre, runtimeShell }:
+
+stdenv.mkDerivation rec {
+  pname = "swingsane";
+  version = "0.2";
+
+  src = fetchurl {
+    sha256 = "15pgqgyw46yd2i367ax9940pfyvinyw2m8apmwhrn0ix5nywa7ni";
+    url = "mirror://sourceforge/swingsane/swingsane-${version}-bin.zip";
+  };
+
+  nativeBuildInputs = [ unzip ];
+
+  phases = [ "unpackPhase" "installPhase" ];
+
+  installPhase = let
+
+    execWrapper = ''
+      #!${runtimeShell}
+      exec ${jre}/bin/java -jar $out/share/java/swingsane/swingsane-${version}.jar "$@"
+    '';
+
+    desktopItem = makeDesktopItem {
+      name = "swingsane";
+      exec = "swingsane";
+      icon = "swingsane";
+      desktopName = "SwingSane";
+      genericName = "Scan from local or remote SANE servers";
+      comment = meta.description;
+      categories = "Office;Application;";
+    };
+
+  in ''
+    install -v -m 755    -d $out/share/java/swingsane/
+    install -v -m 644 *.jar $out/share/java/swingsane/
+
+    echo "${execWrapper}" > swingsane
+    install -v -D -m 755 swingsane $out/bin/swingsane
+
+    unzip -j swingsane-${version}.jar "com/swingsane/images/*.png"
+    install -v -D -m 644 swingsane_512x512.png $out/share/pixmaps/swingsane.png
+
+    cp -v -r ${desktopItem}/share/applications $out/share
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Java GUI for SANE scanner servers (saned)";
+    longDescription = ''
+      SwingSane is a powerful, cross platform, open source Java front-end for
+      using both local and remote Scanner Access Now Easy (SANE) servers.
+      The most powerful feature is its ability to query back-ends for scanner
+      specific options which can be set by the user as a scanner profile.
+      It also has support for authentication, mutlicast DNS discovery,
+      simultaneous scan jobs, image transformation jobs (deskew, binarize,
+      crop, etc), PDF and PNG output.
+    '';
+    homepage = http://swingsane.com/;
+    license = licenses.asl20;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/sxiv/default.nix b/nixpkgs/pkgs/applications/graphics/sxiv/default.nix
new file mode 100644
index 000000000000..acbbf73465df
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/sxiv/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, libXft, imlib2, giflib, libexif, conf ? null }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  pname = "sxiv";
+  version = "25";
+
+  src = fetchFromGitHub {
+    owner = "muennich";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "13s1lfar142hq1j7xld0ri616p4bqs57b17yr4d0b9a9w7liz4hp";
+  };
+
+  postUnpack = ''
+    substituteInPlace $sourceRoot/Makefile \
+      --replace /usr/local $out
+  '';
+
+  configFile = optionalString (conf!=null) (builtins.toFile "config.def.h" conf);
+  preBuild = optionalString (conf!=null) "cp ${configFile} config.def.h";
+
+  buildInputs = [ libXft imlib2 giflib libexif ];
+
+  postInstall = ''
+    mkdir -p $out/share/applications/
+    cp -v sxiv.desktop $out/share/applications/
+  '';
+
+  meta = {
+    description = "Simple X Image Viewer";
+    homepage = https://github.com/muennich/sxiv;
+    license = stdenv.lib.licenses.gpl2Plus;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = with maintainers; [ jfrankenau fuuzetsu ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/synfigstudio/default.nix b/nixpkgs/pkgs/applications/graphics/synfigstudio/default.nix
new file mode 100644
index 000000000000..188f7cb29343
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/synfigstudio/default.nix
@@ -0,0 +1,127 @@
+{ stdenv, fetchFromGitHub, boost, cairo, gettext, glibmm, gtk3, gtkmm3
+, libjack2, libsigcxx, libxmlxx, makeWrapper, mlt-qt5, pango, pkgconfig
+, imagemagick, intltool, autoreconfHook, which, gnome3
+}:
+
+let
+  version = "1.0.2";
+
+  ETL = stdenv.mkDerivation {
+    name = "ETL-0.04.19";
+
+    src = fetchFromGitHub {
+       repo   = "synfig";
+       owner  = "synfig";
+       rev    = version;
+       sha256 = "09ldkvzczqvb1yvlibd62y56dkyprxlr0w3rk38rcs7jnrhj2cqc";
+    };
+
+    postUnpack = "sourceRoot=\${sourceRoot}/ETL/";
+
+    nativeBuildInputs = [ autoreconfHook ];
+  };
+
+  synfig = stdenv.mkDerivation {
+    pname = "synfig";
+    inherit version;
+
+    src = fetchFromGitHub {
+       repo   = "synfig";
+       owner  = "synfig";
+       rev    = version;
+       sha256 = "09ldkvzczqvb1yvlibd62y56dkyprxlr0w3rk38rcs7jnrhj2cqc";
+    };
+
+    postUnpack = "sourceRoot=\${sourceRoot}/synfig-core/";
+
+    configureFlags = [
+      "--with-boost=${boost.dev}"
+      "--with-boost-libdir=${boost.out}/lib"
+    ];
+
+    nativeBuildInputs = [ pkgconfig autoreconfHook gettext ];
+    buildInputs = [
+      ETL boost cairo glibmm mlt-qt5 libsigcxx libxmlxx pango
+    ];
+
+    meta.broken = true;
+  };
+in
+stdenv.mkDerivation {
+  pname = "synfigstudio";
+  inherit version;
+
+  src = fetchFromGitHub {
+     repo   = "synfig";
+     owner  = "synfig";
+     rev    = version;
+     sha256 = "09ldkvzczqvb1yvlibd62y56dkyprxlr0w3rk38rcs7jnrhj2cqc";
+  };
+
+  postUnpack = "sourceRoot=\${sourceRoot}/synfig-studio/";
+
+  postPatch = ''
+    for i in \
+      brushlib/brushlib.hpp \
+      gui/canvasview.cpp \
+      gui/compview.cpp \
+      gui/docks/dock_canvasspecific.cpp \
+      gui/docks/dock_children.cpp \
+      gui/docks/dock_curves.cpp \
+      gui/docks/dock_history.cpp \
+      gui/docks/dock_keyframes.cpp \
+      gui/docks/dock_layergroups.cpp \
+      gui/docks/dock_layers.cpp \
+      gui/docks/dock_metadata.cpp \
+      gui/docks/dock_params.cpp \
+      gui/docks/dock_timetrack.cpp \
+      gui/docks/dock_toolbox.cpp \
+      gui/docks/dockable.cpp \
+      gui/docks/dockdialog.cpp \
+      gui/docks/dockmanager.h \
+      gui/duck.h \
+      gui/duckmatic.cpp \
+      gui/duckmatic.h \
+      gui/instance.cpp \
+      gui/instance.h \
+      gui/states/state_stroke.h \
+      gui/states/state_zoom.cpp \
+      gui/widgets/widget_curves.cpp \
+      gui/workarea.cpp \
+      gui/workarearenderer/workarearenderer.h \
+      synfigapp/action_system.h \
+      synfigapp/canvasinterface.h \
+      synfigapp/instance.h \
+      synfigapp/main.h \
+      synfigapp/uimanager.h
+    do
+      substituteInPlace src/"$i" --replace '#include <sigc++/object.h>' '#include <sigc++/sigc++.h>'
+      substituteInPlace src/"$i" --replace '#include <sigc++/hide.h>' '#include <sigc++/adaptors/hide.h>'
+      substituteInPlace src/"$i" --replace '#include <sigc++/retype.h>' '#include <sigc++/adaptors/retype.h>'
+    done
+  '';
+
+  preConfigure = "./bootstrap.sh";
+
+  nativeBuildInputs = [ pkgconfig autoreconfHook gettext ];
+  buildInputs = [
+    ETL boost cairo glibmm gtk3 gtkmm3 imagemagick intltool
+    libjack2 libsigcxx libxmlxx makeWrapper mlt-qt5
+    synfig which gnome3.adwaita-icon-theme
+  ];
+
+  postInstall = ''
+    wrapProgram "$out/bin/synfigstudio" \
+      --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "A 2D animation program";
+    homepage = http://www.synfig.org;
+    license = licenses.gpl2Plus;
+    maintainers = [ maintainers.goibhniu ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/tesseract/default.nix b/nixpkgs/pkgs/applications/graphics/tesseract/default.nix
new file mode 100644
index 000000000000..840c87de216b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/tesseract/default.nix
@@ -0,0 +1,18 @@
+{ callPackage, lowPrio }:
+
+let
+  base3 = callPackage ./tesseract3.nix {};
+  base4 = callPackage ./tesseract4.nix {};
+  languages = callPackage ./languages.nix {};
+in
+{
+  tesseract3 = callPackage ./wrapper.nix {
+    tesseractBase = base3;
+    languages = languages.v3;
+  };
+
+  tesseract4 = lowPrio (callPackage ./wrapper.nix {
+    tesseractBase = base4;
+    languages = languages.v4;
+  });
+}
diff --git a/nixpkgs/pkgs/applications/graphics/tesseract/fetch-language-hashes b/nixpkgs/pkgs/applications/graphics/tesseract/fetch-language-hashes
new file mode 100755
index 000000000000..c431f1d97c26
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/tesseract/fetch-language-hashes
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+# Usage:
+#   ./fetch-language-hashes <tessdataRev> [<language code>…]
+#
+#   Fetches all languages if no language codes are given.
+#
+# Example:
+#   ./fetch-language-hashes 4.0.0 eng spa
+#
+#   Output:
+#     eng = "0iy0...";
+#     spa = "15kw...";
+
+set -e
+
+(( $# >= 1 )) || exit 1
+tessdataRev=$1
+shift
+
+if (( $# > 0 )); then
+    langCodes="$@"
+else
+    repoPage=$(curl -fs https://github.com/tesseract-ocr/tessdata/tree/$tessdataRev || {
+                   >&2 echo "Invalid tessdataRev: $tessdataRev"
+                   exit 1
+               })
+    langCodes=$(echo $(echo "$repoPage" | grep -ohP "(?<=/)[^/]+?(?=\.traineddata)" | sort))
+fi
+
+for lang in $langCodes; do
+    url=https://github.com/tesseract-ocr/tessdata/raw/$tessdataRev/$lang.traineddata
+    hash=$(nix-prefetch-url $url 2>/dev/null)
+    echo "$lang = \"$hash\";"
+done
diff --git a/nixpkgs/pkgs/applications/graphics/tesseract/languages.nix b/nixpkgs/pkgs/applications/graphics/tesseract/languages.nix
new file mode 100644
index 000000000000..08512a5cdd9d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/tesseract/languages.nix
@@ -0,0 +1,289 @@
+{ stdenv, lib, fetchurl, fetchFromGitHub }:
+
+rec {
+  makeLanguages = { tessdataRev, tessdata ? null, all ? null, languages ? {} }:
+    let
+      tessdataSrc = fetchFromGitHub {
+        owner = "tesseract-ocr";
+        repo = "tessdata";
+        rev = tessdataRev;
+        sha256 = tessdata;
+      };
+
+      languageFile = lang: sha256: fetchurl {
+        url = "https://github.com/tesseract-ocr/tessdata/raw/${tessdataRev}/${lang}.traineddata";
+        inherit sha256;
+      };
+    in
+      {
+        # Use a simple fixed-output derivation for all languages to increase nix eval performance
+        all = stdenv.mkDerivation {
+          name = "all";
+          buildCommand = ''
+            mkdir $out
+            cd ${tessdataSrc}
+            cp *.traineddata $out
+          '';
+          outputHashMode = "recursive";
+          outputHashAlgo = "sha256";
+          outputHash = all;
+        };
+      } // (lib.mapAttrs languageFile languages);
+
+  v3 = makeLanguages {
+    tessdataRev = "3cf1e2df1fe1d1da29295c9ef0983796c7958b7d";
+    tessdata = "1v4b63v5nzcxr2y3635r19l7lj5smjmc9vfk0wmxlryxncb4vpg7";
+    all = "0yj6h9n6h0kzzcqsn3z87vsi8pa60szp0yiayb0znd0v9my0dqhn";
+
+    # Run `./fetch-language-hashes <tessdataRev>` to generate these hashes
+    languages = {
+      afr = "15dsnzy4i9ai26ilm73gkfj4ck039raa88i6w443c4b1fnay2akf";
+      amh = "1wbcsdq3svxga3j1alk61xs72a9fhsfsyjxhp3cwxfaqfhrzg7h4";
+      ara = "0nk495gki6jbbnwcl2ybsx4nd02d6qykcjncq0d2g8pbgapqmj91";
+      asm = "0c3wq15yphq7x74s2sn3f90k6z1cf5j7ic62z0dynidrv99bddfh";
+      aze = "0pz073hxqkx1a1cshlgg5k11lj73s52sdxa7k3020drc314lhaxw";
+      aze_cyrl = "0djbfgx28ykcjsn2p0766qrmj256g7vhc7valc3ivsva8b906lxq";
+      bel = "04zqy8vik0fcakq6apfp8wjhkkhlg0yn9kmag1lk7s8fy9ax3ws2";
+      ben = "0q7812kn5xjm47hcgdcg911lhbgqr7hbvqckfxxm8qw0yjx2cy0m";
+      bod = "0rwq7539zzfs8xs0bf1535z1cwkm0yk1ni25f5gjav7nm6qpiaan";
+      bos = "1qr04dj7lx347gxpin5nfprbggmxq2mwx8kf3pcc3vb5x3pa57g4";
+      bul = "0cyyqgi3i4y9bfzwls0lwljzgd0r8ayfqb4bbvdh4qmbni9x42ya";
+      cat = "0kgw8f5pdw9lfbn6cfp5n1s0j8pj3418yx6rsbagzcf1gr36gbr9";
+      ceb = "1g1n4np4vhar7wfwx2km5k6kldb600rrl7npfbf75229rar068f1";
+      ces = "0zxkkyhpd74i6321nv86pkjb0k7p9cp6m174rbn42nl7jz6qxib0";
+      chi_sim = "0k250xr0gk9yh22yqxd0zpxdsrqfzs164kdv5n9rxx1g996yffij";
+      chi_tra = "03nxqpd546p0gwfj6pqzbdbv5zjpdddzlpa10xn4nvmks1mmckbp";
+      chr = "1k1sg3hap0kd5aa36ysvmhp7r3fynxf0f7lzz814h6p3g250zclb";
+      cym = "0d6wbf9cmrrzf66mhcckwdfy3xh2i38r0by9nk6isw9rl7bf7j07";
+      dan = "1s1yj56rpzmif3ir3qs4iab744cgpflk7y8812z2665bh61illpr";
+      dan_frak = "1bxi53ymib5g0139vfd2pflh7nl5925vqznq3sfgaqx7gdx630vi";
+      deu = "0fna7fqk1a8ivd7q2k38vx37qm3vbn183zh4z5zfqb4pgqmb8znb";
+      deu_frak = "1y4krkvarg7jxhcq49fgybg4phbn58y9c0z2bm8mnp28jkih1cnb";
+      dzo = "1fcz0imi7zxi99762pxfcm5iz2jcbqj3s742magka4ihrxnz07xm";
+      ell = "0r0f71jy4y29bg055qvvy93wchi3lh08zz0k9c8l7466b03yvq5v";
+      eng = "0vghah8kqcv0n5fnjb88w6siz156ysrc41fckw3f2y8c3sgmqlf0";
+      enm = "10y61xv3w1ypgqz5rgb22y5hh1i4zx03cwiqw21ifqvg4xdrln46";
+      epo = "1y5lh55mbcx33cm7qlf1dcah8ffycxmlcpzjzx9r6ij14fdd4964";
+      equ = "1nqrd0a9jqqh6byy8snfhad1hisrc92dcx44wsy7v4nf40j3mx1s";
+      est = "12ll8lq1hjcsq9hh93020w78r7f1rcxcwlvrjqw8j5p3k9jg5a4g";
+      eus = "034s9mp7lw1a4yvf2cmbbj2fbqbaq6xnjqh30yn0wq0c0jck96nw";
+      fas = "0m61p4byc0kzf75cdn6g18s8hcg9r8ifs34wr85lbsb65kil4ijx";
+      fin = "1wac333k0lcd5jwprzg99b10bq8sdc96b9d6275kg9imyqjwcc7q";
+      fra = "1ax7i0nw1lwkz4sbrvn4z0lcrcai77ymdpla7qk7yij6s4xb5bw6";
+      frk = "16nmr71p93724vk1x5mq4r8vxpwnm448p6dwqv8scg8asch1cidp";
+      frm = "00yz3hz7wcralq8wbx1ap4c6b37ac6vnz5bgmxmgdx0kqzibiddn";
+      gle = "1n8z8kmn5m628rlzgz5v0iw6h46aalflq5asa1wj5rygx1y2azpa";
+      glg = "0fdniayplc3iwmlmvhblarh1gm97dp8rqhhkb8b0clwfd9cj342z";
+      grc = "04r2193qcxqyab5998xn8bf7197wiccmjm7iakij8d0c7l61dnxb";
+      guj = "0dp8mlxmf0x9wb8dg0c508sdwz03icq94z8ji8jhwgdqgv8hw1al";
+      hat = "0793mmlxbb09c8103jhdvlczz647nyn4ykkgd3gwgavncmjh72v8";
+      heb = "16za9ff1i3ya6hz75l9v3v7j4039kscxxw21g3i2w5p9zn52hyag";
+      hin = "1vnn5wpc724kgib8jbx0kpnnp4al60ivqir72gnbyh6cpnflb6bf";
+      hrv = "15rqd6xiv2bdmalb5s6rxvw0yk6w9agn9fli3bvi703q6vpj2yn3";
+      hun = "19zzwdxwi3h3vdsgr271i1m87gfpdirk6b1ljw2j8qmfilp4sw56";
+      iku = "1v1yvc1194qycjgb4ihh5hpj6472nlbp66dii183514g2dh9x0db";
+      ind = "120d4b41wvsgcd1sgy2mp78i9hvi7w03a63078dz1yds0yqdwf1p";
+      isl = "003ngk8dfv6dglkq8pmi6jsglrfkc65js5ywh3vvkg7qfqf6qsxz";
+      ita = "1lxklk3zc3x3k8yfpp6ygyv7fndgs57dfasc97rh8782ds16wkjs";
+      ita_old = "188gby1y51pa1ycyc8y17d16hs5w27yl5ch7xzni98bdjkwbkl1z";
+      jav = "1fjyjznjchls5ifbnx2b9xagisgxvgj9lsf39rr9d87sbzdbbwbp";
+      jpn = "1wmayj8wh3pfwznjhalad2qzv38mhrzw2sxl71mycvzvpdy9ag1w";
+      kan = "0hak4953whw9vd9dzl0hq076kzb19kk45kmfxk03af4k6gb206vg";
+      kat = "16k0057cvvdc6snm5svhdv3cr7cw71g74yy8215njjbsi838imi3";
+      kat_old = "02gl755d38plyvzwfjqxvjgfqkbjs9rvzx33qfhm2zvmgbwrfrfh";
+      kaz = "0hc36w7zz5waycsk220v0r83sg991gd5f5r937mvz44viql80sgm";
+      khm = "1gb2nv5qdq5fz9w9xq4fj68p46b62sd1m986ra5qbnskxqizr12s";
+      kir = "1b1ing6qqi8qqfh4xpk76rp4gxp69wdjdl5m777ayx3v02d7nhh3";
+      kor = "1rldj6f8h1nn5wpx57b0ci7p0fnivnwzgaf0d3576xls26z2wcgv";
+      kur = "1cp2pfd6g662gvxi7ywkxfbfq1lwbis888bf1gg8ynzy342mx1ic";
+      lao = "03bdaxakmxpbbr9vsnbzzfksvm6js0l5i0ijwl71piqyxqjj1gxf";
+      lat = "1q7v7drnwpna9k2l79jbdlxiv1j617rqzjc9d48h3lfrma5z97sj";
+      lav = "0fxzyvw7n67rmw2irvlghkf1bii4w47200zv26p0v3a9dwvhc7sg";
+      lit = "0f00ggjjqrl94kwwjmjqwajyfprsml0br8vhn2gvn11gaxvm52hm";
+      mal = "1i83plhin3m6sq8p92vzlyng5z59gvvqypyh7rnmvdmm9rranx8a";
+      mar = "0ay7q53yl3709crvn5l9c9jx7hw6m5d3x2crmvnvczsh83ayfdik";
+      mkd = "1q1wadcr4j1dzssyyqz43qmizc6vfqkbivr6xi2p7p4h9rl11x73";
+      mlt = "1qp4v6habak1l7xrw322wglvjjndrfp4j7bj8d4npwbzk1sh4s0h";
+      msa = "048p6mkx9zr40s9s5vbi0gnizhvqwn0g8i1hf1l8db7igbax5xyj";
+      mya = "17nyr5bd42kzvid3421n3mwckd49vzrjhjahd8rnfsmbsy1x382l";
+      nep = "154375r32sdmvcnp1ckvgbp3wxvb2xiiypb8bxbsvrabrz4wzjqc";
+      nld = "1clwbky71zkz55zd3f8r9hj8fhpnbkply80p1js4fvs7x12r715x";
+      nor = "1ynvrz6s0vmlq1xkjd8k2w6bx8770x6v29qgx83d4nl17ngjd459";
+      ori = "0dsakc8gnwhs6z5kxc2wdkbn31gkkiqk5vriw0swghychp164aac";
+      osd = "1zq0dfliavglmix7zzrqdxz1w01rm1f1x1352bqn8xf4zivdbxcw";
+      pan = "1fwdpwkydfmr6drwgkqzn89z12r2rdm02a75vvdxhxg2a9yiwmbv";
+      pol = "155z870ygzws476kp7qpzi8jcjcv3jb5px8rbzhnag1fklqr48hx";
+      por = "1814cff2rffpzlg4hyyrjzpf5ps2i95rmpa4c8ikblbvrlcv97q8";
+      pus = "1iz5nn1zfvn1l9gb1jriwx991d2hwwc7x4k1nvzjlwpzscplx25b";
+      ron = "11lr80zhvnnngvwwk01z1d3prfpbh3qbwpl1nl5fp7h09d6n3wzl";
+      rus = "1d6a8lg4bmd3np16jds1py3qpkaq4ahnhwghd5r0159y0jpxq00q";
+      san = "169f4ajgwn99yfdfrlwfvdgvv1abal7fpdp31sknvq8l7w2sak3g";
+      sin = "1411g18r6f6j6f4n0sn7ajgs4gkplb892s6ak0hi9nyyxwv3r1gm";
+      slk = "0bxfbrg1nf6px0xzkh6ihdi71fmr1rxxs99qb191k7pm16x2lpds";
+      slk_frak = "0zyqnn1y5cyx1y7wzgw743k4584ljl0rhvk2q1ni6jnjx9ciwzqy";
+      slv = "1kjn9m9hbwp0m0p2v8c3skpzr6f8x42hz8x48zl22550a7hq8n1h";
+      spa = "1npgl8ylvfm60hd4214z8a3lriy1hckhijschrbjpzmwdfcqafgj";
+      spa_old = "0w4ivkv8flyn7bjlyjcrcrdnslkvrrfs7l33mvird1jhhkyqd8sx";
+      sqi = "15wzvh6qm3yx7yf0k5j7g1imsaqxvq7r2xh6a0xgmkqbyypbbkdf";
+      srp = "05blqriv30x02c80ds3x7zhw0y21nc6lkqlv5jwgwnjgw4yfpgrm";
+      srp_latn = "0ss8s3q60aq8sd2a3sbnzvp13qqarxnjw4hij8hd9ab5gsjw0nwr";
+      swa = "1pwwhx7ldq21cv06cchws8gvwsmkwn5sjcy9z3nk3nbp9qjsf44f";
+      swe = "0l10iyn2cr7ibgk0akmpg8725mpwpydawgv3s77izsw7y6xhfr1a";
+      syr = "08bxil13wyp5h4hvbxjcys7ypgqgg46rrp653m7gyv5q94ycjgb0";
+      tam = "1g155kyba2wjfgzgy48g6yd2csinwbfjdi5r7vw0wm3dh1z39dvz";
+      tel = "0fydrcb54b6mmqazb337x4s36i2a64sb4xm7y7g3nqqmk9afsipv";
+      tgk = "0f6j37friywj7y132fv0jm6aj4sx8f0b7brspj3pbjqqpi4v5ws0";
+      tgl = "0f1r0gicif57qhyw8xaa1sqgny720q3z5cpd5srrn9i6fihaz577";
+      tha = "1y2hw55jfpidk95y8qbsiczgg2r2khabac97s1y3gl0v93a44jna";
+      tir = "1y7iryhjr83ca4yh5jjz7qlnrx4kbrp0a0p650whjvk2gnv8m98h";
+      tur = "0xqnq99b2jb4v74bj95py6wmg14dm31zp5s3l48dmcv6zdgcxg2w";
+      uig = "1sdddr15zlb33kd1d7hzi5lfd15bfhqn105d7x6snfpqp7vq4bxv";
+      ukr = "0cdwjnfnnmzz7jdn49l96vqgaimclfxcxaw09cm63f5my382r2rg";
+      urd = "10xcn1zs2lfswp5yai0ckyg7js587qhr5cf7qib3i35qjbw7nc18";
+      uzb = "1jkkd5j6vsx5jv5gwprbfwg1vwh714prm8j446wzvp74brmk949l";
+      uzb_cyrl = "1kdia38rgm2qd3ly80a412jyagxxryr09h1nz2d0iw71bmfn4855";
+      vie = "1ja18jxxaw282y4jljxpjf1gj15il61vc2ykpfy22vn88wvydxff";
+      yid = "1jddd0g8mm5v00z5kb8rbpfs7ppzgq9kzm1xlhhvv960yfdbi6fd";
+    };
+  };
+
+  v4 = makeLanguages {
+    tessdataRev = "4.0.0";
+    tessdata = "1chw1ya5zf8aaj2ixr9x013x7vwwwjjmx6f2ag0d6i14lypygy28";
+    all = "0dqgkp369rcvq72yhgnzj1pj8yrv7kqzc7y6sqs7nzcq7l5qazlg";
+
+    # Run `./fetch-language-hashes <tessdataRev>` to generate these hashes
+    languages = {
+      afr = "1a9f8pnrspfmcq9gpjnxn2kkhjlsmh912bnpx671fjizxpmiri2y";
+      amh = "0m1vdyxjx57kmf2qra0p31k509y1cqn4pyckzw00i5n3wx11d2j0";
+      ara = "0nswl6n0s94g900j5k1gwzp7m140c0yd9a2fdb2lzhdvg1krf190";
+      asm = "025d9vrjcrwyd6cc6hrw1x8xqhicgrb9wpvhhmlw71ql04dadslf";
+      aze = "01shcs78a6xn3my8p3y42x1c9f5hzfn83w2n2nwpffbgz4y2nsgf";
+      aze_cyrl = "1sbd89i5r7rnkjh2in8j0plrxnfiill9jl8pr68iw77ghih6q1vg";
+      bel = "0dhyymsxcyzwal8474q7ag3m2akv0b92hkdz7rka5z1cxry1cn8c";
+      ben = "0a7q9414k3frn37x2qcglz722ysg2iivj6kqaaa0ik7z14ibc8v0";
+      bod = "0rh7x54nlh6ir6ldccj8hi7g8hwlp13r3fkljw8gndvhwmgfkkar";
+      bos = "1szym4n605hlx12a9vpz4jjs76jscajh22rgkqwbv4qdsl0gi3nd";
+      bre = "070f4c84iznblsw4jkwpzh9dss8nfb678160szm5r8dlv2yinrrk";
+      bul = "03bg2yw79lg8rl43y9288313jrfh0h69vl4s4cmlgbmnbx8pvxwj";
+      cat = "19xs691aj8yy2ff07c3gzm07zicd5ha0gmcjxjh9pknqf2gfy7qv";
+      ceb = "1896vn41hqc4anm6hjvrnn022i0p8pmhwsp5rv9w2cvr6738l79r";
+      ces = "0fh2g47msfr91285rnccxcmcshihm126sqy496s4vrr0vk8ix1nf";
+      chi_sim = "0qxkvbpm5l7gzsshnn72wfx473pprf5nmw8hd4i4x2qxnfddh1gw";
+      chi_sim_vert = "1f75pzvxbda82vxa2zb1z9b9f13sh81kzaw45vg5118ncsklj8w7";
+      chi_tra = "056vjws1fir1v5iv44pzykkxs5q1dbb2j8blhj47i53w1zf6g42m";
+      chi_tra_vert = "10c9cdycg1a5kwlgg60sh8yp07w2fl4whinpxfhlzrzs56allql4";
+      chr = "19qq8a6c27973djsc4xpcklis92r58x21fg4mz5azdyka5i1n46l";
+      cos = "0z9kx1hw8h5n00pcahxla808wya50wrkk8cz7x676pd93ibyrlyx";
+      cym = "13pk9cpf43xxqbz3blfz2av2yd1ma6ds6jbdiqw8anhhj7l9ch2d";
+      dan = "1jirmahxvyyswhhyzhinvcqaycz7m3ixchqrj3lgfcdi3anvabr2";
+      dan_frak = "17wcgdqxmbzn7qchnx5gsa05aj4wmhbwk43w173bl3wr6h5ylmh0";
+      deu = "194rqsg4nlycca9bg2fqf15xgcl110rxp182l7dbjfjhar4knsw9";
+      deu_frak = "12hhhp32f15c7fw2jp05mwim9ps14kmamhh6vmalvm7r2033vbm7";
+      div = "09mm9r5hxhsc4qpyg10ym9mc2kdpawx8zk0aiv1xpgd35rzpyz41";
+      dzo = "1zk7crgcazgqy5zmslp6iw4jws07nja31qdxx0rpzhn3c0bjgw1b";
+      ell = "1hhym18a9411953j47xjk47jx9ij9xi2qwlx05c93zl41528nsqg";
+      eng = "0iy07z182lwhqfa0q288ha691scpsry330aynaizn68wcmywk86s";
+      enm = "1dhr1qvil38bil43wk5ci645sbm3my2y9y7qlcbnwz2p4pflayvm";
+      epo = "1jig4db7050vww32vxsqyig3j1b0vgz9ipxbsw0jpkjia84k44n9";
+      equ = "02qwg6s1z7pynwm0p6dvpwi04ivfkr1s7qgssbla1dx7v0ih6rlg";
+      est = "1jxygahy6by7fbirbmjmd68k6560q1a3h5mvpzdx15h5fw0q58gl";
+      eus = "0cai7nm7si8680avrrls8bf9ski980rvsj560fh9y6n9rz7mh9mp";
+      fao = "1n3434jf18bzakbylzyg3jaw2ad4h376g56dsql32bgh2yvyww8a";
+      fas = "17wjkfka9725rz32clgqgk9msmbz4axs59vz30jmhhxyrkliafqb";
+      fil = "0p713k8g27df9z384ns111xqxii5kq20m8brflsmd3yckw1mibhz";
+      fin = "1wc3y9nnm7rb2c2c5fkj7cv7jb27jlkb2bh0g8kaz57h6imfmb2g";
+      fra = "04qrfvi6irlaahh1pgn5azyfhbhavm12yyybza8603alf8firh7a";
+      frk = "05cqmxxxjqdl5hjyzi6dpmixnjpd6f3jr6741yapdmnxvkzxkiyp";
+      frm = "0a86yy6hd0lvlbzvnzjmyapzc0rn7mnkdadqycd65bw1b714cvy2";
+      fry = "0i84r8g9hlkr9nlhypl4lq6ncrhbcpskqkdcijgk88c2fdknh57h";
+      gla = "17idyhb505waz9dnb8dsk54faw7y0xvvb12yw71k0skq3i90akar";
+      gle = "1q87h5zzcva54pg364d3hl6q9hdlydlyj1qmq8n5k7hqk11msxmk";
+      glg = "01xssz1rhpy3a0sm4i43nba61wc2srz6wv327vdw1kg8ijm0s0g4";
+      grc = "00x0s3smx4wg5h12y2b9al0j2jk1y3f0yy2x6f2qf7ps831drgyl";
+      guj = "028v4fgn0zi2044vk6j2rlqklc9i0kj22s52vhifmx1g02kz9154";
+      hat = "1bca516pr2cnyjlwycc7pr6gfmdjb8565hp06pw9nwpr20ry0hss";
+      heb = "1qfkffjh29b21frs0mv6llsrchixl5kjkpj1if7fq816g9mym9kx";
+      hin = "1rkfam5c6qil2590lfffzndhq3bncdgf4ij0cyjcglgyljgx0xnc";
+      hrv = "0da7b6mk0rwc9zlbqkycwjpddp3qpy07l643i00ia5a1zq35fmgp";
+      hun = "0w2s4mn9p74zqzmp9hh2017zgsh5v43k4lid4pv29f4b0y5gj9xi";
+      hye = "0ifzm875wlbjh4vkpmj1n6f14m8i174413l6pc6i44y4p5fpgxrf";
+      iku = "19arnv82xbxhbcy8pf9fv1sl5zc5707mk34nh7w46dlz86qkidmn";
+      ind = "1d421hizwni4m6sr4f3nqqpr1g744hzn0krk130m7x8mhzgamba5";
+      isl = "1hjjw8k2r9qa990ziq5wxr36kyf16mnmrqfmq5vbcjprka9h08pq";
+      ita = "1qyrvlf7pjxzyb29sc7aq3gq61bww14sijka44scxggfw7134l3r";
+      ita_old = "1pf8461jbj0vpyry0b54crmkf2bk9mh4klxvmj09jvf0aq2vm9s6";
+      jav = "18vvbyimj0y462amjmwvqa6h9n8l122j9v0w3hfp63hlxpfprm0m";
+      jpn = "16hma9w32vdh41ihymp894jza72b0d235hwriv18r78j5n86nhbg";
+      jpn_vert = "0yca09l9sbpfjgb2slnpb9q7qd7vz3a1wb6bkln30d3nl0d9r1rn";
+      kan = "0lcmx37rjfxkbhhbrld1ndmkwkm9w9b3pzxhas0cv5dqsx2f84jd";
+      kat = "1b164bgwa7bbvw4177h8fxfh0fbh4bycfl9pkaa184dpjpaiqpia";
+      kat_old = "1mgff7sh93hdp3wh0ckikdggrdgf0syp75s39pickpbkp9ic41ai";
+      kaz = "0h37y0kb5lwsp5zpl7bvxg3ryqldl5hxfnardliwgyqgnag951vi";
+      khm = "0m7x1fynr18sid2kjjw8xa9ika0a0fc6a6hvc7ihizi47893hdfb";
+      kir = "09kxwqpqf6kxjii07qlqsiii83zk12rszp88xnzzjp8rjsnk78s3";
+      kor = "0nsr43fwrp9876ia1fc0zcviv2n8hw16n0wfh158vhygwglvy84m";
+      kor_vert = "1wmvdznmikk9fq7wdffvn22scxmcl26vjh26jhicqwxpc7kg4bh8";
+      kur = "0gbsf3ny3n5mgb30v54bz3crgnimdpg19jn633pbpzryzg3xhd25";
+      kur_ara = "1sbj0cczhi9q119fbzpi0m6zr9kjp3k76bv9w8szkv1wc5y4fng6";
+      lao = "1gvxlg8bw3a4c9izg3c2a2yl7q6rsy7z9y64axdw9a04pz2ndbl5";
+      lat = "0b7an3q3xrf9c55bhiqqh7l45ga88l0kwvkp1akmlr98piach3vr";
+      lav = "0fqsmy47cygamddxyjfrdgkfa9bvmrvf4csvppnkdvfzy6iiv0c2";
+      lit = "0wjgbkwc3bf5khdqali7ylnhhs4xvpx19m3zx2y9s27v2wjbb6kv";
+      ltz = "02zdxbniiqfl87fzsiaaqgldqfsv15z5hja1xhxnqpl0nds7shfc";
+      mal = "0a41ifz8i6lj2ywxjkwvymxzxahkz2cjv4apbrawdj1h42bn7frd";
+      mar = "00swhlh9bckvmlxanfmlw5j4n9qqhggl84bsq0827bmijsqwnl44";
+      mkd = "1bqfiwxlzfpz4fs4z5ci2wbv01qhrcayk1inmk3dxq7dsywx1ajg";
+      mlt = "1rmmga2aw88hr7q7cfr5cvhnsgnf1mi069d5k7z66zp4vzbl4zyz";
+      mon = "1jksvcavn9plsmjdmhg40mwq5rlvrd1b9gvghdjg7zkf6qqqynlh";
+      mri = "0jlfawx20s5clsnk82ndy3v2zidh4cfh4acrh8nindk21xmiwh5i";
+      msa = "0m7zs8anaa3l4z5f3xvbhs4syp41dp4all2yfpi1plyr0hy784an";
+      mya = "0hljm5haadlr4k5rhw4mvhkygcnrr709rvl7amz7av3nskmi8mb1";
+      nep = "1dhy0m2h6xfgwibf92iwxsn926dmrhfvkg9rafkdaqcr4pq6w563";
+      nld = "0bspf5bv1s7qzm6k4aqbpq91zvk4kxxhx5zv08w91xfsa1zpdxmi";
+      nor = "08majhc9m0fjvac50yq52ia2af9kscclimwkv403klnj4kgf8ndq";
+      oci = "1mzrw9gsdjrd1xj3zv7l5gzgjq5jrygxf8cfkz20d9lls0wj1xdv";
+      ori = "1sh42mjzb1hv6l6lljp3wifjmz7wrv818f9f16m8qjikwqxm0s78";
+      osd = "03mvfk1q1xp1klpf4bwna903rnp51bkqr3gl5hvxybvrc3l2m7z1";
+      pan = "0165kr94p6x5yxzs4p8sfppvg9cywp65ps0xaym5rqz9iashz32h";
+      pol = "0g0b71ms6ddgykmkna4mlavgzgmh9vj6s62fi8l4ja93nfpr37hp";
+      por = "132jbhzmcsq8skanm15bw2niyx9xpbrqr411wn7w9r5i3cvnlv01";
+      pus = "0iiglnkn478al11avigsav625pn7ifscycnxpj6fg8835vjww3xr";
+      que = "01vkmfi9idjwskv5pllmrxpil0v5h7f7rzv5viclxrzkmbvrz9b5";
+      ron = "0ag6vs0cn3sryavs1mfrallgdgi4h28114g7m61rhlhq0z484g0m";
+      rus = "1hippm3w5d73sh50r136x0xff2p6x128ry2x4fywf6xdpv1f46v8";
+      san = "1qlpqkr5c5wqcf1bvlipy72advqnvd4wm61vghmrj2sda8mx87sx";
+      sin = "097d2s4ma0zsq0ab5qs1ylgl9l5phw91fnpsvb7vjmz2mw3ic964";
+      slk = "0c97pp5iffhdzyma605x8q3rx1qq9pq2h6cai1kppaj92rz3ji9k";
+      slk_frak = "16ivsam1g18zlpw6pgidvzwb7h8rvw1s10nigs6yfwir8hjxsgki";
+      slv = "0644jlm55p0dg4zchgrashmbv36zb4x649ckmf2jkbss8bzx7wsf";
+      snd = "1i2mfi4414l3v9nznjy7959y2jcr8ymvf6w8zpyrw6nad4d1aak7";
+      spa = "15kwvr7cpcnlxm1ja1yyc022dmsd04gmk7h1p0df12aicsscn3qb";
+      spa_old = "1jq80c4mi3rmwnfhb3mbaaq0ci101mgbibkji9ala4l5dkcwjra3";
+      sqi = "19cvvixhz9906p4c9i2grpr386rbp5alp4fp14xm9nd81bmq4701";
+      srp = "1jd25n13h6vxsa3gzbj6q6mdh02rjl4qrd1bffr5psp33asqvw0l";
+      srp_latn = "1k7577mn3z0bm5ma9d8l14sn5wpvw50hq1nxwbc36yn3a5b3mhiz";
+      sun = "0lvlaw3jfvr7b5v09669kq8mm19jdsk9g5h09jsa2gr6fvsq11pa";
+      swa = "0qy9qc5pa1dzzqrh1z40gk845z1r4d2smywnzydknbb3n240lhz0";
+      swe = "1y56r7bgzw0pqkdylbah07r1f0v03sblkggiql8x5200rhaxvqi4";
+      syr = "1vfj5fsiv170jghryrxwyz0i9mdsaki1kglxrklkb2caal9kwy38";
+      tam = "0rhhdbnp0a2hpg00vpc0xyxcl2w36i1kn63mrvwx1f9q7m3y1fmf";
+      tat = "0a74rp8pyp4yivv2xcy2m8xgwch8scr3wmk1fzniwzf43fsrqp76";
+      tel = "0gcq8hxhxvilyh7x7kiikq07hllqysc8sfyr88gvpj4xi092h2bx";
+      tgk = "1458gk0k6gk49n8lr6fj7l7cwkhxn0lrhybzq10zl1ly7yzjhf67";
+      tgl = "12yscwckdy3l21mvsrj1021gxw2isjrg369r08rsf7lh96wn4wkn";
+      tha = "01f0j7gsc5slxaaql1gqbhk4wlwaxc29dlmfxwjzikxc46gjl0w8";
+      tir = "1q6w48b1jchv55713pq20inzjjdymh32fw8wxfaj1qi7bjqfb9fk";
+      ton = "06g60ga8rys8jaimqrvd4svh40qs1nz4bszdnf2hdv05ibryibdq";
+      tur = "0g9g1wvibp61qbriy8ys948yfkl88xk9g8f93bnq8w8dx029b6s8";
+      uig = "09sajx21lw3a3ph62dyqr10pjaq2mij10sdhkhvvjiydk34dn548";
+      ukr = "14q8ls8gkrg7c9pc6qzm6yf5ady3i3303vs1hz4d2idcl6yry334";
+      urd = "15vszhqraxqdcng1069p6i4xq3ck3904q207nkbap6dfpcpjig40";
+      uzb = "03hyw0vavmjirqs4wkd5r85g91w2avsyl14z624fhm3gc66pqg7n";
+      uzb_cyrl = "1433lrrp2lfgb1k0a4sc20b35b2jcl8f1z92vm2936y7w04xpaq7";
+      vie = "02k40d3wji74d1jgvkr3zrn9gpzlmp0lqhrrdmc48r2sgvnrnk8n";
+      yid = "0xnbvi04xv1qapqg72wa3bjwbw51pkdnyncjpjp37vn6dzh04l0z";
+      yor = "07w3aci52ng6i6nyp97q5zb2dqlj08w6im90y1h691qah1x44zlv";
+    };
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/tesseract/tesseract3.nix b/nixpkgs/pkgs/applications/graphics/tesseract/tesseract3.nix
new file mode 100644
index 000000000000..157c0b9742bf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/tesseract/tesseract3.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig
+, leptonica, libpng, libtiff, icu, pango, opencl-headers }:
+
+stdenv.mkDerivation rec {
+  pname = "tesseract";
+  version = "3.05.00";
+
+  src = fetchFromGitHub {
+    owner = "tesseract-ocr";
+    repo = "tesseract";
+    rev = version;
+    sha256 = "11wrpcfl118wxsv2c3w2scznwb48c4547qml42s2bpdz079g8y30";
+  };
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ pkgconfig autoreconfHook ];
+  buildInputs = [ leptonica libpng libtiff icu pango opencl-headers ];
+
+  LIBLEPT_HEADERSDIR = "${leptonica}/include";
+
+  meta = {
+    description = "OCR engine";
+    homepage = https://github.com/tesseract-ocr/tesseract;
+    license = stdenv.lib.licenses.asl20;
+    maintainers = with stdenv.lib.maintainers; [ viric earvstedt ];
+    platforms = with stdenv.lib.platforms; linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/tesseract/tesseract4.nix b/nixpkgs/pkgs/applications/graphics/tesseract/tesseract4.nix
new file mode 100644
index 000000000000..548f58a50fb1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/tesseract/tesseract4.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, autoconf-archive, pkgconfig
+, leptonica, libpng, libtiff, icu, pango, opencl-headers }:
+
+stdenv.mkDerivation rec {
+  pname = "tesseract";
+  version = "4.1.0";
+
+  src = fetchFromGitHub {
+    owner = "tesseract-ocr";
+    repo = "tesseract";
+    rev = version;
+    sha256 = "06i7abxy2ifmdx1fak81cx0kns85n8hvp0339jk6242fhshibljx";
+  };
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ pkgconfig autoreconfHook autoconf-archive ];
+  buildInputs = [ leptonica libpng libtiff icu pango opencl-headers ];
+
+  meta = {
+    description = "OCR engine";
+    homepage = https://github.com/tesseract-ocr/tesseract;
+    license = stdenv.lib.licenses.asl20;
+    maintainers = with stdenv.lib.maintainers; [ viric earvstedt ];
+    platforms = with stdenv.lib.platforms; linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/tesseract/wrapper.nix b/nixpkgs/pkgs/applications/graphics/tesseract/wrapper.nix
new file mode 100644
index 000000000000..365d68a9ee76
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/tesseract/wrapper.nix
@@ -0,0 +1,58 @@
+{ stdenv, makeWrapper, tesseractBase, languages
+
+# A list of languages like [ "eng" "spa" … ] or `null` for all available languages
+, enableLanguages ? null
+
+# A list of files or a directory containing files
+, tessdata ? (if enableLanguages == null then languages.all
+              else map (lang: languages.${lang}) enableLanguages)
+
+# This argument is obsolete
+, enableLanguagesHash ? null
+}:
+
+let
+  passthru = { inherit tesseractBase languages tessdata; };
+
+  tesseractWithData = tesseractBase.overrideAttrs (_: {
+    inherit tesseractBase tessdata;
+
+    buildInputs = [ makeWrapper ];
+
+    buildCommand = ''
+      makeWrapper {$tesseractBase,$out}/bin/tesseract --set-default TESSDATA_PREFIX $out/share/tessdata
+
+      # Recursively link include, share
+      cp -rs --no-preserve=mode $tesseractBase/{include,share} $out
+
+      cp -r --no-preserve=mode $tesseractBase/lib $out
+      # Fixup the store paths in lib so that the tessdata from this derivation is used.
+      if (( ''${#tesseractBase} != ''${#out} )); then
+        echo "Can't replace store paths due to differing lengths"
+        exit 1
+      fi
+      find $out/lib -type f -exec sed -i "s|$tesseractBase|$out|g" {} \;
+
+      if [[ -d "$tessdata" ]]; then
+        ln -s $tessdata/* $out/share/tessdata
+      else
+        for lang in $tessdata; do
+          ln -s $lang $out/share/tessdata/''${lang#/nix/store*-}
+        done
+      fi
+
+      if [[ ! -e $out/share/tessdata/eng.traineddata ]]; then
+         # This is a bug in Tesseract's internal tessdata discovery mechanism
+         echo "eng.traineddata must be present in tessdata for Tesseract to work"
+         exit 1
+      fi
+    '';
+  });
+
+  tesseract = (if enableLanguages == [] then tesseractBase else tesseractWithData) // passthru;
+in
+  if enableLanguagesHash == null then
+    tesseract
+  else
+    stdenv.lib.warn "Argument `enableLanguagesHash` is obsolete and can be removed."
+    tesseract
diff --git a/nixpkgs/pkgs/applications/graphics/timelapse-deflicker/default.nix b/nixpkgs/pkgs/applications/graphics/timelapse-deflicker/default.nix
new file mode 100644
index 000000000000..8355545e8dd6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/timelapse-deflicker/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, makeWrapper, perl, perlPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "timelapse-deflicker";
+  version = "0.1.0";
+
+  src = fetchFromGitHub {
+    owner = "cyberang3l";
+    repo = "timelapse-deflicker";
+    rev = "v${version}";
+    sha256 = "0bbfnrdycrpyz7rqrql5ib9qszny7z5xpqp65c1mxqd2876gv960";
+  };
+
+  installPhase = ''
+    install -m755 -D timelapse-deflicker.pl $out/bin/timelapse-deflicker
+    wrapProgram $out/bin/timelapse-deflicker --set PERL5LIB $PERL5LIB
+  '';
+
+  buildInputs = with perlPackages; [
+    makeWrapper perl
+    PerlMagick TermProgressBar ImageExifTool
+    FileType ClassMethodMaker
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Simple script to deflicker images taken for timelapses";
+    homepage = https://github.com/cyberang3l/timelapse-deflicker;
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ valeriangalliat ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/ufraw/default.nix b/nixpkgs/pkgs/applications/graphics/ufraw/default.nix
new file mode 100644
index 000000000000..131d83f0d58e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/ufraw/default.nix
@@ -0,0 +1,86 @@
+{ stdenv
+, fetchFromGitHub
+
+, autoconf
+, automake
+, autoreconfHook
+, bzip2
+, cfitsio
+, exiv2
+, gettext
+, gimp ? null
+, gtk2
+, gtkimageview
+, lcms2
+, lensfun
+, libjpeg
+, libtiff
+, perl
+, pkgconfig
+, zlib
+
+, withGimpPlugin ? true
+}:
+
+assert withGimpPlugin -> gimp != null;
+
+stdenv.mkDerivation {
+  pname = "ufraw";
+  version = "unstable-2019-06-12";
+
+  # The original ufraw repo is unmaintained and broken;
+  # this is a fork that collects patches
+  src = fetchFromGitHub {
+    owner = "sergiomb2";
+    repo = "ufraw";
+    rev = "c65b4237dcb430fb274e4778afaf5df9a18e04e6";
+    sha256 = "02icn67bsinvgliy62qa6v7gmwgp2sh15jvm8iiz3c7g1h74f0b7";
+  };
+
+  outputs = [ "out" ] ++ stdenv.lib.optional withGimpPlugin "gimpPlugin";
+
+  nativeBuildInputs = [ autoconf automake autoreconfHook gettext perl pkgconfig ];
+
+  buildInputs = [
+    bzip2
+    cfitsio
+    exiv2
+    gtk2
+    gtkimageview
+    lcms2
+    lensfun
+    libjpeg
+    libtiff
+    zlib
+  ] ++ stdenv.lib.optional withGimpPlugin gimp;
+
+  configureFlags = [
+    "--enable-contrast"
+    "--enable-dst-correction"
+  ] ++ stdenv.lib.optional withGimpPlugin "--with-gimp";
+
+  postInstall = stdenv.lib.optionalString withGimpPlugin ''
+    moveToOutput "lib/gimp" "$gimpPlugin"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/sergiomb2/ufraw;
+
+    description = "Utility to read and manipulate raw images from digital cameras";
+
+    longDescription =
+      '' The Unidentified Flying Raw (UFRaw) is a utility to read and
+         manipulate raw images from digital cameras.  It can be used on its
+         own or as a Gimp plug-in.  It reads raw images using Dave Coffin's
+         raw conversion utility - DCRaw.  UFRaw supports color management
+         workflow based on Little CMS, allowing the user to apply ICC color
+         profiles.  For Nikon users UFRaw has the advantage that it can read
+         the camera's tone curves.
+      '';
+
+    license = licenses.gpl2Plus;
+
+    maintainers = with maintainers; [ gloaming ];
+    platforms   = with platforms; all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/unigine-valley/default.nix b/nixpkgs/pkgs/applications/graphics/unigine-valley/default.nix
new file mode 100644
index 000000000000..09abfc60a528
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/unigine-valley/default.nix
@@ -0,0 +1,115 @@
+{ stdenv, fetchurl
+
+# Build-time dependencies
+, makeWrapper
+, file
+
+# Runtime dependencies
+, fontconfig
+, freetype
+, libX11
+, libXext
+, libXinerama
+, libXrandr
+, libXrender
+, libGL
+, openal}:
+
+let
+  version = "1.0";
+
+  arch = if stdenv.hostPlatform.system == "x86_64-linux" then
+    "x64"
+  else if stdenv.hostPlatform.system == "i686-linux" then
+    "x86"
+  else
+    throw "Unsupported platform ${stdenv.hostPlatform.system}";
+
+in
+  stdenv.mkDerivation rec {
+    pname = "unigine-valley";
+    inherit version;
+
+    src = fetchurl {
+      url = "http://assets.unigine.com/d/Unigine_Valley-${version}.run";
+      sha256 = "5f0c8bd2431118551182babbf5f1c20fb14e7a40789697240dcaf546443660f4";
+    };
+
+    sourceRoot = "Unigine_Valley-${version}";
+    instPath = "lib/unigine/valley";
+
+    buildInputs = [file makeWrapper];
+
+    libPath = stdenv.lib.makeLibraryPath [
+      stdenv.cc.cc  # libstdc++.so.6
+      fontconfig
+      freetype
+      libX11
+      libXext
+      libXinerama
+      libXrandr
+      libXrender
+      libGL
+      openal
+    ];
+
+    unpackPhase = ''
+      runHook preUnpack
+
+      cp $src extractor.run
+      chmod +x extractor.run
+      ./extractor.run --target $sourceRoot
+
+      runHook postUnpack
+    '';
+
+    patchPhase = ''
+      runHook prePatch
+
+      # Patch ELF files.
+      elfs=$(find bin -type f | xargs file | grep ELF | cut -d ':' -f 1)
+      for elf in $elfs; do
+        patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2 $elf || true
+      done
+
+      runHook postPatch
+    '';
+
+    installPhase = ''
+      runHook preInstall
+
+      instdir=$out/${instPath}
+
+      # Install executables and libraries
+      mkdir -p $instdir/bin
+      install -m 0755 bin/browser_${arch} $instdir/bin
+      install -m 0755 bin/libApp{Stereo,Surround,Wall}_${arch}.so $instdir/bin
+      install -m 0755 bin/libGPUMonitor_${arch}.so $instdir/bin
+      install -m 0755 bin/libQt{Core,Gui,Network,WebKit,Xml}Unigine_${arch}.so.4 $instdir/bin
+      install -m 0755 bin/libUnigine_${arch}.so $instdir/bin
+      install -m 0755 bin/valley_${arch} $instdir/bin
+      install -m 0755 valley $instdir
+
+      # Install other files
+      cp -R data documentation $instdir
+
+      # Install and wrap executable
+      mkdir -p $out/bin
+      install -m 0755 valley $out/bin/valley
+      wrapProgram $out/bin/valley \
+        --run "cd $instdir" \
+        --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib:$instdir/bin:$libPath
+
+      runHook postInstall
+    '';
+
+    stripDebugList = ["${instPath}/bin"];
+
+    meta = {
+      description = "The Unigine Valley GPU benchmarking tool";
+      homepage = http://unigine.com/products/benchmarks/valley/;
+      license = stdenv.lib.licenses.unfree; # see also: $out/$instPath/documentation/License.pdf
+      maintainers = [ stdenv.lib.maintainers.kierdavis ];
+      platforms = ["x86_64-linux" "i686-linux"];
+    };
+  }
diff --git a/nixpkgs/pkgs/applications/graphics/viewnior/default.nix b/nixpkgs/pkgs/applications/graphics/viewnior/default.nix
new file mode 100644
index 000000000000..4f5fb12faa62
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/viewnior/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, gtk2, libpng, exiv2, lcms
+, intltool, gettext, shared-mime-info, glib, gdk-pixbuf, perl}:
+
+stdenv.mkDerivation rec {
+  pname = "viewnior";
+  version = "1.6";
+
+  src = fetchFromGitHub {
+    owner = "xsisqox";
+    repo = "Viewnior";
+    rev = "${pname}-${version}";
+    sha256 = "06ppv3r85l3id4ij6h4y5fgm3nib2587fdrdv9fccyi75zk7fs0p";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs =
+    [ pkgconfig gtk2 libpng exiv2 lcms intltool gettext
+      shared-mime-info glib gdk-pixbuf perl
+    ];
+
+  preFixup = ''
+    rm $out/share/icons/*/icon-theme.cache
+  '';
+
+  meta = {
+    description = "Fast and simple image viewer";
+    longDescription =
+      '' Viewnior is insipred by big projects like Eye of Gnome, because of it's
+         usability and richness,and by GPicView, because of it's lightweight design and
+         minimal interface. So here comes Viewnior - small and light, with no compromise
+         with the quality of it's functions. The program is made with better integration
+         in mind (follows Gnome HIG2).
+      '';
+
+    license = stdenv.lib.licenses.gpl3;
+
+    homepage = http://siyanpanayotov.com/project/viewnior/;
+
+    maintainers = [ stdenv.lib.maintainers.smironov ];
+
+    platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/vimiv/default.nix b/nixpkgs/pkgs/applications/graphics/vimiv/default.nix
new file mode 100644
index 000000000000..5fc7e309f4df
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/vimiv/default.nix
@@ -0,0 +1,73 @@
+{ lib, python3Packages, fetchFromGitHub, imagemagick, librsvg, gtk3, jhead
+, hicolor-icon-theme, gnome3
+
+# Test requirements
+, dbus, xvfb_run, xdotool
+}:
+
+python3Packages.buildPythonApplication rec {
+  pname = "vimiv";
+  version = "0.7.3";
+
+  src = fetchFromGitHub {
+    owner = "karlch";
+    repo = "vimiv";
+    rev = "v${version}";
+    sha256 = "18dn81n8hcrqhrqfida34qz7a0ar9rz2rrmzsvyp54zc6nyvv1cn";
+  };
+
+  testimages = fetchFromGitHub {
+    owner = "karlch";
+    repo = "vimiv";
+    rev = "6f4d1372b27f2065c56eafdb521d230d9bb8f4e2";
+    sha256 = "0a3aybzpms0381dz9japhm4c7j5klhmw91prcac6zaww6x34nmxb";
+  };
+
+  postPatch = ''
+    patchShebangs scripts/install_icons.sh
+    sed -i -e 's,/usr,,g' -e '/setup\.py/d' Makefile scripts/install_icons.sh
+
+    sed -i \
+      -e 's,/etc/vimiv/\(vimivrc\|keys\.conf\),'"$out"'&,g' \
+      man/* vimiv/parser.py
+
+    sed -i \
+      -e 's!"mogrify"!"${imagemagick}/bin/mogrify"!g' \
+      -e '/cmd *=/s!"jhead"!"${jhead}/bin/jhead"!g' \
+      vimiv/imageactions.py
+  '';
+
+  checkInputs = [ python3Packages.nose dbus.daemon xvfb_run xdotool ];
+  buildInputs = [ hicolor-icon-theme gnome3.adwaita-icon-theme librsvg ];
+  propagatedBuildInputs = with python3Packages; [ pillow pygobject3 gtk3 ];
+
+  makeWrapperArgs = [
+    "--prefix GI_TYPELIB_PATH : \"$GI_TYPELIB_PATH\""
+    "--suffix XDG_DATA_DIRS : \"$XDG_ICON_DIRS:$out/share\""
+    "--set GDK_PIXBUF_MODULE_FILE \"$GDK_PIXBUF_MODULE_FILE\""
+  ];
+
+  postCheck = ''
+    # Some tests assume that the directory only contains one vimiv directory
+    rm -rf vimiv.egg-info vimiv.desktop
+
+    # Re-use the wrapper args from the main program
+    makeWrapper "$SHELL" run-tests $makeWrapperArgs
+
+    cp -Rd --no-preserve=mode "$testimages/testimages" vimiv/testimages
+    HOME="$(mktemp -d)" PATH="$out/bin:$PATH" \
+      xvfb-run -s '-screen 0 800x600x24' dbus-run-session \
+      --config-file=${dbus.daemon}/share/dbus-1/session.conf \
+      ./run-tests -c 'python tests/main_test.py && nosetests -vx'
+  '';
+
+  postInstall = "make DESTDIR=\"$out\" install";
+
+  meta = {
+    homepage = https://github.com/karlch/vimiv;
+    description = "An image viewer with Vim-like keybindings";
+    license = lib.licenses.mit;
+    platforms = lib.platforms.linux;
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/wings/default.nix b/nixpkgs/pkgs/applications/graphics/wings/default.nix
new file mode 100644
index 000000000000..8d6eca7ef32c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/wings/default.nix
@@ -0,0 +1,45 @@
+{ fetchurl, stdenv, erlang, cl, libGL, libGLU, runtimeShell }:
+
+stdenv.mkDerivation rec {
+  name = "wings-2.2.4";
+  src = fetchurl {
+    url = "mirror://sourceforge/wings/${name}.tar.bz2";
+    sha256 = "1xcmifs4vq2810pqqvsjsm8z3lz24ys4c05xkh82nyppip2s89a3";
+  };
+
+  ERL_LIBS = "${cl}/lib/erlang/lib";
+
+  patchPhase = ''
+    sed -i 's,-Werror ,,' e3d/Makefile
+    sed -i 's,../../wings/,../,' icons/Makefile
+    find plugins_src -mindepth 2 -type f -name "*.[eh]rl" -exec sed -i 's,wings/src/,../../src/,' {} \;
+    find plugins_src -mindepth 2 -type f -name "*.[eh]rl" -exec sed -i 's,wings/e3d/,../../e3d/,' {} \;
+    find plugins_src -mindepth 2 -type f -name "*.[eh]rl" -exec sed -i 's,wings/intl_tools/,../../intl_tools/,' {} \;
+    find . -type f -name "*.[eh]rl" -exec sed -i 's,wings/src/,../src/,' {} \;
+    find . -type f -name "*.[eh]rl" -exec sed -i 's,wings/e3d/,../e3d/,' {} \;
+    find . -type f -name "*.[eh]rl" -exec sed -i 's,wings/intl_tools/,../intl_tools/,' {} \;
+  '';
+
+  buildInputs = [ erlang cl libGL libGLU ];
+
+  # I did not test the *cl* part. I added the -pa just by imitation.
+  installPhase = ''
+    mkdir -p $out/bin $out/lib/${name}/ebin
+    cp ebin/* $out/lib/${name}/ebin
+    cp -R textures shaders plugins $out/lib/$name
+    cat << EOF > $out/bin/wings
+    #!${runtimeShell}
+    ${erlang}/bin/erl \
+      -pa $out/lib/${name}/ebin -run wings_start start_halt "$@"
+    EOF
+    chmod +x $out/bin/wings
+  '';
+
+  meta = {
+    homepage = http://www.wings3d.com/;
+    description = "Subdivision modeler inspired by Nendo and Mirai from Izware";
+    license = stdenv.lib.licenses.tcltk;
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/write_stylus/default.nix b/nixpkgs/pkgs/applications/graphics/write_stylus/default.nix
new file mode 100644
index 000000000000..232eeeb01153
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/write_stylus/default.nix
@@ -0,0 +1,65 @@
+{ stdenv, lib, qtbase, qtsvg, libglvnd, fetchurl, makeDesktopItem }:
+stdenv.mkDerivation rec {
+  pname = "write_stylus";
+  version = "209";
+
+  desktopItem = makeDesktopItem {
+    name = "Write";
+    exec = "Write";
+    comment = "A word processor for handwriting";
+    icon = "write_stylus";
+    desktopName = "Write";
+    genericName = "Write";
+    categories = "Office;Graphics";
+  };
+
+  src = fetchurl {
+    url = "http://www.styluslabs.com/write/write${version}.tar.gz";
+    sha256 = "1p6glp4vdpwl8hmhypayc4cvs3j9jfmjfhhrgqm2xkgl5bfbv2qd";
+  };
+
+  # taken from: https://www.iconfinder.com/icons/50835/edit_pencil_write_icon
+  # license: Free for commercial use
+  icon = fetchurl {
+    url = "https://oyra.eu/write/icon.tar.gz";
+    sha256 = "1zd98g63apwi17qc1hm1g14maain5d18g4afadxm30qjz2s0mvs8";
+  };
+
+  sourceRoot = ".";
+
+  dontBuild = true;
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -R Write $out/
+    # symlink the binary to bin/
+    ln -s $out/Write/Write $out/bin/Write
+
+    # untar icons
+    tar -xzf ${icon} *.tar.gz -C $out/
+
+    mkdir -p $out/share/applications
+    ln -s ${desktopItem}/share/applications/* $out/share/applications/
+  '';
+  preFixup = let
+    libPath = lib.makeLibraryPath [
+      qtbase            # libQt5PrintSupport.so.5
+      qtsvg             # libQt5Svg.so.5
+      stdenv.cc.cc.lib  # libstdc++.so.6
+      libglvnd          # ibGL.so.1
+    ];
+  in ''
+    patchelf \
+      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+      --set-rpath "${libPath}" \
+      $out/Write/Write
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.styluslabs.com/;
+    description = "Write is a word processor for handwriting.";
+    platforms = platforms.linux;
+    license = stdenv.lib.licenses.unfree;
+    maintainers = with maintainers; [ oyren ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/xaos/default.nix b/nixpkgs/pkgs/applications/graphics/xaos/default.nix
new file mode 100644
index 000000000000..e80362c386b9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/xaos/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, aalib, gsl, libpng, libX11, xorgproto, libXext
+, libXt, zlib, gettext, intltool, perl }:
+
+stdenv.mkDerivation rec {
+  pname = "xaos";
+  version = "3.6";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/xaos/${pname}-${version}.tar.gz";
+    sha256 = "15cd1cx1dyygw6g2nhjqq3bsfdj8sj8m4va9n75i0f3ryww3x7wq";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  buildInputs = [
+    aalib gsl libpng libX11 xorgproto libXext
+    libXt zlib gettext intltool perl
+  ];
+
+  preConfigure = ''
+    sed -e s@/usr/@"$out/"@g -i configure $(find . -name 'Makefile*')
+    mkdir -p $out/share/locale
+  '';
+
+  meta = {
+    homepage = http://xaos.sourceforge.net/;
+    description = "Fractal viewer";
+    license = stdenv.lib.licenses.gpl2Plus;
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/xara/debian-patches.nix b/nixpkgs/pkgs/applications/graphics/xara/debian-patches.nix
new file mode 100644
index 000000000000..dd3061461868
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/xara/debian-patches.nix
@@ -0,0 +1,30 @@
+# Generated by debian-patches.sh from debian-patches.txt
+let
+  prefix = "http://patch-tracker.debian.org/patch/series/dl/xaralx/0.7r1785-5";
+in
+[
+  {
+    url = "${prefix}/30_gtk_wxwidgets_symbol_clash";
+    sha256 = "1rc9dh9mnp93mad96dkp7idyhhcw7h6w0g5s92mqgzj79hqgaziz";
+  }
+  {
+    url = "${prefix}/40_algorithm_include";
+    sha256 = "03jhl1qnxj7nl8malf6v1y24aldfz87x1p2jxp04mrr35nzvyyc0";
+  }
+  {
+    url = "${prefix}/50_update_imagemagick_version_parser";
+    sha256 = "1nilsqghlr649sc14n1aqkhdx7f66rq91gqccdpi17jwijs27497";
+  }
+  {
+    url = "${prefix}/remove-icon-suffix";
+    sha256 = "160zmkgwlsanqivnip89558yvd9zvqp8ks2wbyr2aigl2rafin22";
+  }
+  {
+    url = "${prefix}/45_fix_gcc4";
+    sha256 = "06zsj0z9v5n557gj8337v6xd26clbvm4dc0qhvpvzbisq81l9jyi";
+  }
+  {
+    url = "${prefix}/55_fix_contstuctor_call";
+    sha256 = "0b14glrcwhv0ja960h56n5jm4f9563ladap2pgaywihq485ql1c1";
+  }
+]
diff --git a/nixpkgs/pkgs/applications/graphics/xara/debian-patches.txt b/nixpkgs/pkgs/applications/graphics/xara/debian-patches.txt
new file mode 100644
index 000000000000..5c95d401a323
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/xara/debian-patches.txt
@@ -0,0 +1,7 @@
+xaralx/0.7r1785-5
+30_gtk_wxwidgets_symbol_clash
+40_algorithm_include
+50_update_imagemagick_version_parser
+remove-icon-suffix
+45_fix_gcc4
+55_fix_contstuctor_call
diff --git a/nixpkgs/pkgs/applications/graphics/xara/default.nix b/nixpkgs/pkgs/applications/graphics/xara/default.nix
new file mode 100644
index 000000000000..56388a8a2555
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/xara/default.nix
@@ -0,0 +1,22 @@
+{stdenv, fetchurl, automake, gettext, freetype, libxml2, pango, pkgconfig
+, wxGTK, gtk2, perl, zip}:
+
+stdenv.mkDerivation {
+  name = "xaralx-0.7r1785";
+
+  src = fetchurl {
+    url = http://downloads2.xara.com/opensource/XaraLX-0.7r1785.tar.bz2;
+    sha256 = "05xbzq1i1vw2mdsv7zjqfpxfv3g1j0g5kks0gq6sh373xd6y8lyh";
+  };
+
+  nativeBuildInputs = [ automake pkgconfig gettext perl zip ];
+  buildInputs = [ wxGTK gtk2 libxml2 freetype pango ];
+
+  configureFlags = [ "--disable-svnversion" ];
+
+  patches = map fetchurl (import ./debian-patches.nix);
+
+  prePatch = "patchShebangs Scripts";
+
+  meta.broken = true;
+}
diff --git a/nixpkgs/pkgs/applications/graphics/xfig/default.nix b/nixpkgs/pkgs/applications/graphics/xfig/default.nix
new file mode 100644
index 000000000000..fe5a13703329
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/xfig/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchurl, xlibsWrapper, makeWrapper, libXpm
+, libXmu, libXi, libXp, Xaw3d, fig2dev
+}:
+
+let
+  version = "3.2.7a";
+
+in stdenv.mkDerivation {
+  pname = "xfig";
+  inherit version;
+
+  src = fetchurl {
+    url = "mirror://sourceforge/mcj/xfig-${version}.tar.xz";
+    sha256 = "096zgp0bqnxhgxbrv2jjylrjz3pr4da0xxznlk2z7ffxr5pri2fa";
+  };
+
+  postPatch = ''
+    sed -i 's:"fig2dev":"${fig2dev}/bin/fig2dev":' src/main.c
+  '';
+
+  postInstall = ''
+    mkdir -p $out/share/X11/app-defaults
+    cp app-defaults/* $out/share/X11/app-defaults
+
+    wrapProgram $out/bin/xfig \
+      --set XAPPLRESDIR $out/share/X11/app-defaults
+  '';
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  buildInputs = [ xlibsWrapper libXpm libXmu libXi libXp Xaw3d ];
+
+  meta = with stdenv.lib; {
+    description = "An interactive drawing tool for X11";
+    longDescription = ''
+      Note that you need to have the <literal>netpbm</literal> tools
+      in your path to export bitmaps.
+    '';
+    inherit (fig2dev.meta) license homepage platforms;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/xfractint/default.nix b/nixpkgs/pkgs/applications/graphics/xfractint/default.nix
new file mode 100644
index 000000000000..ae4765fc9e76
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/xfractint/default.nix
@@ -0,0 +1,29 @@
+{stdenv, fetchurl, libX11, libXft}:
+stdenv.mkDerivation rec {
+  pname = "xfractint";
+  version = "20.04p14";
+  # or fetchFromGitHub(owner,repo,rev) or fetchgit(rev)
+  src = fetchurl {
+    url = "https://www.fractint.net/ftp/current/linux/xfractint-${version}.tar.gz";
+    sha256 = "0jdqr639z862qrswwk5srmv4fj5d7rl8kcscpn6mlkx4jvjmca0f";
+  };
+
+  buildInputs = [libX11 libXft];
+
+  configurePhase = ''
+    sed -e 's@/usr/bin/@@' -i Makefile
+  '';
+
+  makeFlags = ["PREFIX=$(out)"];
+
+  meta = {
+    inherit version;
+    description = "";
+    # Code cannot be used in commercial programs
+    # Looks like the definition hinges on the price, not license
+    license = stdenv.lib.licenses.unfree;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    homepage = https://www.fractint.net/;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/xournal/default.nix b/nixpkgs/pkgs/applications/graphics/xournal/default.nix
new file mode 100644
index 000000000000..cd9d068b8acf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/xournal/default.nix
@@ -0,0 +1,65 @@
+{ stdenv, fetchurl, makeDesktopItem
+, ghostscript, atk, gtk2, glib, fontconfig, freetype
+, libgnomecanvas, libgnomeprint, libgnomeprintui
+, pango, libX11, xorgproto, zlib, poppler
+, autoconf, automake, libtool, pkgconfig}:
+
+let
+  isGdkQuartzBackend = (gtk2.gdktarget == "quartz");
+in
+
+stdenv.mkDerivation rec {
+  version = "0.4.8.2016";
+  name = "xournal-" + version;
+  src = fetchurl {
+    url = "mirror://sourceforge/xournal/${name}.tar.gz";
+    sha256 = "09i88v3wacmx7f96dmq0l3afpyv95lh6jrx16xzm0jd1szdrhn5j";
+  };
+
+  buildInputs = [
+    ghostscript atk gtk2 glib fontconfig freetype
+    libgnomecanvas
+    pango libX11 xorgproto zlib poppler
+  ] ++ stdenv.lib.optionals (!stdenv.isDarwin) [
+    libgnomeprint libgnomeprintui
+  ];
+
+  nativeBuildInputs = [ autoconf automake libtool pkgconfig ];
+
+  NIX_LDFLAGS = [ "-lz" ]
+    ++ stdenv.lib.optionals (!isGdkQuartzBackend) [ "-lX11" ];
+
+  desktopItem = makeDesktopItem {
+    name = name;
+    exec = "xournal";
+    icon = "xournal";
+    desktopName = "Xournal";
+    comment = meta.description;
+    categories = "Office;Graphics;";
+    mimeType = "application/pdf;application/x-xoj";
+    genericName = "PDF Editor";
+  };
+
+  postInstall=''
+      mkdir --parents $out/share/mime/packages
+      cat << EOF > $out/share/mime/packages/xournal.xml
+      <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
+         <mime-type type="application/x-xoj">
+          <comment>Xournal Document</comment>
+          <glob pattern="*.xoj"/>
+         </mime-type>
+      </mime-info>
+      EOF
+      cp --recursive ${desktopItem}/share/applications $out/share
+      mkdir --parents $out/share/icons
+      cp $out/share/xournal/pixmaps/xournal.png $out/share/icons
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://xournal.sourceforge.net/;
+    description = "Note-taking application (supposes stylus)";
+    maintainers = [ maintainers.guibert ];
+    license = licenses.gpl2;
+    platforms = with platforms; linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/xournalpp/default.nix b/nixpkgs/pkgs/applications/graphics/xournalpp/default.nix
new file mode 100644
index 000000000000..41539f32b071
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/xournalpp/default.nix
@@ -0,0 +1,63 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+
+, cmake
+, gettext
+, wrapGAppsHook
+, pkgconfig
+
+, glib
+, gsettings-desktop-schemas
+, gtk3
+, hicolor-icon-theme
+, libsndfile
+, libxml2
+, libzip
+, pcre
+, poppler
+, portaudio
+, zlib
+# plugins
+, withLua ? true, lua
+}:
+
+stdenv.mkDerivation rec {
+  pname = "xournalpp";
+  version = "1.0.12";
+
+  src = fetchFromGitHub {
+    owner = "xournalpp";
+    repo = "xournalpp";
+    rev = version;
+    sha256 = "0yg70hsx58s3wb5kzccivrqa7kvmdapygxmif1j64hddah2rqcn9";
+  };
+
+  nativeBuildInputs = [ cmake gettext pkgconfig wrapGAppsHook ];
+  buildInputs =
+    [ glib
+      gsettings-desktop-schemas
+      gtk3
+      hicolor-icon-theme
+      libsndfile
+      libxml2
+      libzip
+      pcre
+      poppler
+      portaudio
+      zlib
+    ]
+    ++ lib.optional withLua lua;
+
+  hardeningDisable = [ "format" ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Xournal++ is a handwriting Notetaking software with PDF annotation support";
+    homepage    = https://github.com/xournalpp/xournalpp;
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ andrew-d ];
+    platforms   = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/xzgv/default.nix b/nixpkgs/pkgs/applications/graphics/xzgv/default.nix
new file mode 100644
index 000000000000..de3f3a78988b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/xzgv/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, gtk2, libexif, pkgconfig, texinfo }:
+
+stdenv.mkDerivation rec {
+  pname = "xzgv";
+  version = "0.9.2";
+  src = fetchurl {
+    url = "mirror://sourceforge/xzgv/xzgv-${version}.tar.gz";
+    sha256 = "17l1xr9v07ggwga3vn0z1i4lnwjrr20rr8z1kjbw71aaijxl18i5";
+  };
+  nativeBuildInputs = [ pkgconfig texinfo ];
+  buildInputs = [ gtk2 libexif ];
+  postPatch = ''
+    substituteInPlace config.mk \
+      --replace /usr/local $out
+    substituteInPlace Makefile \
+      --replace "all: src man" "all: src man info"
+  '';
+  preInstall = ''
+    mkdir -p $out/share/{app-install/desktop,applications,info,pixmaps}
+  '';
+  meta = with stdenv.lib; {
+    homepage = https://sourceforge.net/projects/xzgv/;
+    description = "Picture viewer for X with a thumbnail-based selector";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.womfoo ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/yacreader/default.nix b/nixpkgs/pkgs/applications/graphics/yacreader/default.nix
new file mode 100644
index 000000000000..e545dd5a7230
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/yacreader/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, qmake, poppler, pkgconfig, libunarr, libGLU
+, qtdeclarative, qtgraphicaleffects, qtmultimedia, qtquickcontrols, qtscript
+}:
+
+stdenv.mkDerivation rec {
+  pname = "yacreader";
+  version = "9.5.0";
+
+  src = fetchurl {
+    url = "https://github.com/YACReader/yacreader/releases/download/${version}/${pname}-${version}-src.tar.xz";
+    sha256 = "0cv5y76kjvsqsv4fp99j8np5pm4m76868i1nn40q6hy573dmxwm6";
+  };
+
+  nativeBuildInputs = [ qmake pkgconfig ];
+  buildInputs = [ poppler libunarr libGLU qtmultimedia qtscript ];
+  propagatedBuildInputs = [ qtquickcontrols qtgraphicaleffects qtdeclarative ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "A comic reader for cross-platform reading and managing your digital comic collection";
+    homepage = http://www.yacreader.com;
+    license = stdenv.lib.licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/yed/default.nix b/nixpkgs/pkgs/applications/graphics/yed/default.nix
new file mode 100644
index 000000000000..0038d41475fb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/yed/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchzip, makeWrapper, unzip, jre }:
+
+stdenv.mkDerivation rec {
+  pname = "yEd";
+  version = "3.19";
+
+  src = fetchzip {
+    url = "https://www.yworks.com/resources/yed/demo/${pname}-${version}.zip";
+    sha256 = "0l70pc7wl2ghfkjab9w2mbx7crwha7xwkrpmspsi5c6q56dw7s33";
+  };
+
+  nativeBuildInputs = [ makeWrapper unzip ];
+
+  installPhase = ''
+    mkdir -p $out/yed
+    cp -r * $out/yed
+    mkdir -p $out/bin
+
+    makeWrapper ${jre}/bin/java $out/bin/yed \
+      --add-flags "-jar $out/yed/yed.jar --"
+  '';
+
+  meta = with stdenv.lib; {
+    license = licenses.unfree;
+    homepage = http://www.yworks.com/en/products/yfiles/yed/;
+    description = "A powerful desktop application that can be used to quickly and effectively generate high-quality diagrams";
+    platforms = jre.meta.platforms;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/zgrviewer/default.nix b/nixpkgs/pkgs/applications/graphics/zgrviewer/default.nix
new file mode 100644
index 000000000000..db07b9e1db4e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/zgrviewer/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, jre, unzip, runtimeShell }:
+stdenv.mkDerivation rec {
+  version = "0.9.0";
+  pname = "zgrviewer";
+  src = fetchurl {
+    url = "mirror://sourceforge/zvtm/${pname}/${version}/${pname}-${version}.zip";
+    sha256 = "1yg2rck81sqqrgfi5kn6c1bz42dr7d0zqpcsdjhicssi1y159f23";
+  };
+  buildInputs = [jre unzip];
+  buildPhase = "";
+  installPhase = ''
+    mkdir -p "$out"/{bin,share/java/zvtm/plugins,share/doc/zvtm}
+
+    cp overview.html *.license.* "$out/share/doc/zvtm"
+
+    cp -r target/* "$out/share/java/zvtm/"
+
+    echo '#!${runtimeShell}' > "$out/bin/zgrviewer"
+    echo "${jre}/lib/openjdk/jre/bin/java -jar '$out/share/java/zvtm/zgrviewer-${version}.jar' \"\$@\"" >> "$out/bin/zgrviewer"
+    chmod a+x "$out/bin/zgrviewer"
+  '';
+  meta = {
+    # Quicker to unpack locally than load Hydra
+    hydraPlatforms = [];
+    maintainers = with stdenv.lib.maintainers; [raskin];
+    license = stdenv.lib.licenses.lgpl21Plus;
+    description = "GraphViz graph viewer/navigator";
+    platforms = with stdenv.lib.platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/zgv/default.nix b/nixpkgs/pkgs/applications/graphics/zgv/default.nix
new file mode 100644
index 000000000000..8ef705f7ef4b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/zgv/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, fetchpatch, pkgconfig, SDL, SDL_image, libjpeg, libpng, libtiff }:
+
+stdenv.mkDerivation rec {
+  pname = "zgv";
+  version = "5.9";
+  src = fetchurl {
+    url = "https://www.svgalib.org/rus/zgv/${pname}-${version}.tar.gz";
+    sha256 = "1fk4i9x0cpnpn3llam0zy2pkmhlr2hy3iaxhxg07v9sizd4dircj";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ SDL SDL_image libjpeg libpng libtiff ];
+
+  hardeningDisable = [ "format" ];
+
+  makeFlags = [
+    "BACKEND=SDL"
+  ];
+
+  patches = [
+    (fetchpatch {
+    url = https://foss.aueb.gr/mirrors/linux/gentoo/media-gfx/zgv/files/zgv-5.9-libpng15.patch;
+    sha256 = "1blw9n04c28bnwcmcn64si4f5zpg42s8yn345js88fyzi9zm19xw";
+    })
+    ./switch.patch
+  ];
+
+  patchFlags = "-p0";
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp src/zgv $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.svgalib.org/rus/zgv/;
+    description = "Picture viewer with a thumbnail-based selector";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.vrthra ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/graphics/zgv/switch.patch b/nixpkgs/pkgs/applications/graphics/zgv/switch.patch
new file mode 100644
index 000000000000..0b5ad092d72d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/graphics/zgv/switch.patch
@@ -0,0 +1,14 @@
+GCC complains
+
+diff -ur src/zgv_io.c src/zgv_io.c
+--- src/zgv_io.c	2005-01-20 15:07:46.000000000 -0800
++++ src/zgv_io.c	2016-06-29 10:19:40.169897611 -0700
+@@ -645,7 +645,7 @@
+         case SDLK_INSERT:	return(RK_INSERT);
+         case SDLK_DELETE:	return(RK_DELETE);
+         case SDLK_RETURN:	return(RK_ENTER);
+-        default:
++        default: ;
+           /* stop complaints */
+         }
+