Change:
I'm going to be putting this aside for a bit but it still needs some work, so I'm posting this here till I have a PR ready. At the moment this appears to generate a functional gscan2pdf derivation, however I would like to find a way to allow at least part, if not all of the (graphical) tests to be run. I also intend to merge the perl packages into perl packages properly instead of leaving them like this, and I need to look into whether they have any extra things I should configure, currently this is somewhat modified output of nix-generate-from-cpan. Also I don't know if this should go into tools/graphics, or into perlPackages, or what. Though I'm leaning towards the former. Also please send suggestions on how to improve the script in general. If anyone wants to pick this up, please do.
Any progress on this?

Discussion:
<ins> { stdenv, fetchurl, perlPackages, makeWrapper, wrapGAppsHook, librsvg, sane-backends, sane-frontends, imagemagick, libtiff, djvulibre, poppler_utils, ghostscript, unpaper, xvfb_run, hicolor-icon-theme, liberation_ttf, file, pdftk }: with stdenv.lib; perlPackages.buildPerlPackage rec { name = "gscan2pdf-${version}"; version = "2.3.0"; src = fetchurl { url = "mirror://sourceforge/gscan2pdf/${version}/${name}.tar.xz"; sha256 = "0mcsmly0j9pmyzh6py8r6sfa30hc6gv300hqq3dxj4hv653vhkk9"; }; 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" ''; enableParallelBuilding = true; installTargets = [ "install" ]; outputs = [ "out" "man" ]; checkInputs = [ xvfb_run hicolor-icon-theme imagemagick libtiff djvulibre poppler_utils ghostscript file pdftk unpaper ]; 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 = [ maintainers.pacien ]; }; } </ins>

grobi = callPackage ../tools/X11/grobi { }; <ins> gscan2pdf = callPackage ../applications/graphics/gscan2pdf { }; </ins> gti = callPackage ../tools/misc/gti { }; hdate = callPackage ../applications/misc/hdate { };

propagatedBuildInputs = [ ExtUtilsDepends ExtUtilsPkgConfig ]; }; <ins> CairoGObject = buildPerlPackage rec { name = "Cairo-GObject-1.004"; src = fetchurl { url = "mirror://cpan/authors/id/X/XA/XAOC/${name}.tar.gz"; sha256 = "1m896j0xdfhldsx8abf10cc16ll1fm9wbav42dpzal9fh07d9f9v"; }; buildInputs = [ pkgs.cairo Cairo Glib ExtUtilsDepends ExtUtilsPkgConfig ]; meta = { description = "Integrate Cairo into the Glib type system"; license = stdenv.lib.licenses.lgpl21Plus; }; }; </ins> cam_pdf = buildPerlModule rec { name = "CAM-PDF-1.60"; src = fetchurl {

}; }; <ins> FilesysDf = buildPerlPackage rec { name = "Filesys-Df-0.92"; src = fetchurl { url = "mirror://cpan/authors/id/I/IG/IGUTHRIE/${name}.tar.gz"; sha256 = "fe89cbb427e0e05f1cd97c2dd6d3866ac6b21bc7a85734ede159bdc35479552a"; }; meta = { description = "Perl extension for filesystem disk space information."; license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; }; }; </ins> FilesysNotifySimple = buildPerlPackage { name = "Filesys-Notify-Simple-0.13"; src = fetchurl {

propagatedBuildInputs = [ ExtUtilsDepends ExtUtilsPkgConfig ]; }; <ins> GlibObjectIntrospection = buildPerlPackage rec { name = "Glib-Object-Introspection-0.046"; src = fetchurl { url = "mirror://cpan/authors/id/X/XA/XAOC/${name}.tar.gz"; sha256 = "1d3gl943p27gd42kxc1i9sp5z55gpgcslz1jvx7cxd6mflhdlck6"; }; buildInputs = [ Glib ExtUtilsDepends ExtUtilsPkgConfig ]; propagatedBuildInputs = [ pkgs.gobject-introspection ]; meta = { description = "Dynamically create Perl language bindings"; license = stdenv.lib.licenses.lgpl2Plus; }; }; </ins> Gnome2 = buildPerlPackage rec { name = "Gnome2-1.047"; src = fetchurl {

}; }; <ins> GooCanvas2 = buildPerlPackage rec { name = "GooCanvas2-0.06"; src = fetchurl { url = "mirror://cpan/authors/id/P/PE/PERLMAX/${name}.tar.gz"; sha256 = "0l1vsvyv9hjxhsxrahq4h64axh7qmk50kiz2spa3s1hr7s3qfk72"; }; buildInputs = [ pkgs.gtk3 GlibObjectIntrospection Glib ]; propagatedBuildInputs = [ pkgs.goocanvas2 ]; meta = { description = "Perl binding for GooCanvas2 widget using Glib::Object::Introspection"; license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; }; }; </ins> GoogleProtocolBuffers = buildPerlPackage rec { name = "Google-ProtocolBuffers-0.12"; src = fetchurl {

}; }; <ins> Gtk3 = buildPerlPackage rec { name = "Gtk3-0.034"; src = fetchurl { url = "mirror://cpan/authors/id/X/XA/XAOC/${name}.tar.gz"; sha256 = "0baxyhlzdf7avka40h1niiir8vz4nilqkiwh876i0hv0f8xj3nqa"; }; buildInputs = [ Cairo CairoGObject Glib GlibObjectIntrospection ]; propagatedBuildInputs = [ pkgs.gtk3 ]; meta = { description = "Perl interface to the 3.x series of the gtk+ toolkit"; license = stdenv.lib.licenses.lgpl21Plus; }; }; Gtk3SimpleList = buildPerlPackage rec { name = "Gtk3-SimpleList-0.18"; src = fetchurl { url = "mirror://cpan/authors/id/T/TV/TVIGNAUD/${name}.tar.gz"; sha256 = "09azmc7miyvw7q21rz8cxw16zbd5i1j5hpakxy376f5vmhqqjyhp"; }; buildInputs = [ Gtk3 Glib GlibObjectIntrospection Cairo CairoGObject ]; meta = { description = "A simple interface to Gtk3's complex MVC list widget"; license = stdenv.lib.licenses.lgpl21Plus; }; }; </ins> Guard = buildPerlPackage rec { name = "Guard-1.023"; src = fetchurl {

}; }; <ins> ImageSane = buildPerlPackage rec { name = "Image-Sane-0.14"; src = fetchurl { url = "mirror://cpan/authors/id/R/RA/RATCLIFFE/${name}.tar.gz"; sha256 = "a4b027c9b7650291f1acb0eb93861a7fc45aef4e08f6726843f174fa113c8ba5"; }; buildInputs = [ pkgs.sane-backends ExtUtilsDepends ExtUtilsPkgConfig TestRequires TryTiny ]; propagatedBuildInputs = [ ExceptionClass Readonly ]; meta = { description = "Perl extension for the SANE (Scanner Access Now Easy) Project"; license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; }; }; </ins> ImageScale = buildPerlPackage rec { name = "Image-Scale-0.14"; src = fetchurl {