diff --git a/pkgs/tools/typesetting/ps2eps/default.nix b/pkgs/tools/typesetting/ps2eps/default.nix new file mode 100644 index 000000000000..c8f558889c60 --- /dev/null +++ b/pkgs/tools/typesetting/ps2eps/default.nix @@ -0,0 +1,68 @@ +{ lib +, fetchFromGitHub +, perlPackages +, substituteAll +, ghostscript +, installShellFiles +}: + + +perlPackages.buildPerlPackage rec { + pname = "ps2eps"; + version = "1.70"; + + src = fetchFromGitHub { + owner = "roland-bless"; + repo = pname; + rev = "v${version}"; + hash = "sha256-SPLwsGKLVhANoqSQ/GJ938cYjbjMbUOXkNn9so3aJTA="; + }; + patches = [ + (substituteAll { + src = ./hardcode-deps.patch; + gs = "${ghostscript}/bin/gs"; + # bbox cannot be substituted here because substituteAll doesn't know what + # will be the $out path of the main derivation + }) + ]; + + nativeBuildInputs = [ + installShellFiles + ]; + + configurePhase = "true"; + + buildPhase = '' + runHook preBuild + + make -C src/C bbox + patchShebangs src/perl/ps2eps + substituteInPlace src/perl/ps2eps \ + --replace @bbox@ $out/bin/bbox + + runHook postBuild + ''; + + # Override buildPerlPackage's outputs setting + outputs = ["out" "man"]; + installPhase = '' + runHook preInstall + + installManPage \ + doc/ps2eps.1 \ + doc/bbox.1 + + install -D src/perl/ps2eps $out/bin/ps2eps + install -D src/C/bbox $out/bin/bbox + + runHook postInstall + ''; + + meta = with lib; { + inherit (src.meta) homepage; + description = "Calculate correct bounding boxes for PostScript and PDF files"; + license = licenses.gpl2Plus; + platforms = platforms.unix; + maintainers = [ maintainers.doronbehar ]; + }; +} diff --git a/pkgs/tools/typesetting/ps2eps/hardcode-deps.patch b/pkgs/tools/typesetting/ps2eps/hardcode-deps.patch new file mode 100644 index 000000000000..b8846ab61d07 --- /dev/null +++ b/pkgs/tools/typesetting/ps2eps/hardcode-deps.patch @@ -0,0 +1,26 @@ +diff --git i/src/perl/ps2eps w/src/perl/ps2eps +index 1122a81..31d6a9a 100755 +--- i/src/perl/ps2eps ++++ w/src/perl/ps2eps +@@ -43,19 +43,13 @@ Getopt::Long::Configure("no_ignore_case"); + + $prgname= "ps2eps"; + +-if (! -d "/usr/bin") +-{ # we assume that we are running under native windows +- $ghostscriptname = "gswin32c"; +- $NULLDEV = "nul"; +-} +-else + { # Unix or cygwin +- $ghostscriptname = "gs"; ++ $ghostscriptname = "@gs@"; + $NULLDEV = "/dev/null 2>&1"; + } + + $bboxver=`bbox >$NULLDEV -V`; +-$bboxname= ($?== -1) ? "" : "bbox"; ++$bboxname= ($?== -1) ? "" : "@bbox@"; + $version= '$Id: ps2eps,v 1.70 2018-01-09 18:00:00 bless Exp $'; #' + $insertPScode= 1; # Insert surrounding Postscript code + $infhandle = STDIN; # Standard input is the default input file diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6d69f89767c8..fd28ad87d32b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -33080,6 +33080,8 @@ with pkgs; ps2client = callPackage ../applications/networking/ps2client { }; + ps2eps = callPackage ../tools/typesetting/ps2eps { }; + psi = libsForQt5.callPackage ../applications/networking/instant-messengers/psi { }; psi-plus = libsForQt5.callPackage ../applications/networking/instant-messengers/psi-plus { };