Skip to content

Commit

Permalink
Adding pdfForts.nix for NixOS
Browse files Browse the repository at this point in the history
  • Loading branch information
sjau committed Aug 27, 2017
1 parent 6e16023 commit b39c516
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Each of the script has other prerequisites. Most of them require one or more of
- tesseract & tesseract language package(s)
- sed

if you're using Nixos, just use the pdfForts.nix file instead.


addPasswdPDF
Expand Down
70 changes: 70 additions & 0 deletions pdfForts.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{stdenv, fetchgit, kate, gnome3, pdftk, imagemagick, zip, unzip, libreoffice, unoconv, tesseract, recode, cuneiform, poppler_utils, ghostscript }:
stdenv.mkDerivation {
name = "pdfForts-git";
# Switch between local testing and using proper git repo
src = fetchgit {
url = https://github.com/sjau/pdfForts.git;
rev = "6e160232c2c139f2d66c5d0e8ffb94258fdc532d";
sha256 = "1q3d7l0kjs2jqv6xmdxckvx63jz6ns55c8md4q92f7ci7qig191z";
};
# src = /home/hyper/Desktop/git-repos/pdfForts;
installPhase = ''
mkdir -p $out/bin
cp -n **/*.sh $out/bin
rm $out/bin/vars.sh
# NixOS does currently not provide Kate, so Zenity is chosen over Kate
for i in $out/bin/*; do
substituteInPlace $i \
--replace /usr/bin/pdfForts/common.sh $out/lib/pdfForts/common.sh \
--replace /usr/share/kservices5/ServiceMenus/pdfForts/ $out/share/kservices5/ServiceMenus/pdfForts/ \
--replace kate ${kate}/bin/kate \
--replace zenity ${gnome3.zenity}/bin/zenity \
--replace pdftk ${pdftk}/bin/pdftk \
--replace " convert " " ${imagemagick}/bin/convert " \
--replace " zip " " ${zip}/bin/zip " \
--replace unzip ${unzip}/bin/unzip \
--replace libreoffice ${libreoffice}/bin/libreoffice \
--replace unoconv ${unoconv}/bin/unoconv \
--replace tesseract ${tesseract}/bin/tesseract \
--replace recode ${recode}/bin/recode \
--replace cuneiform ${cuneiform}/bin/cuneiform \
--replace pdftotext ${poppler_utils}/bin/pdftotext \
--replace "gs -sDEVICE" " ${ghostscript}/bin/gs -sDEVICE"
done
mkdir -p $out/lib/pdfForts
cp common.sh $out/lib/pdfForts/
for i in $out/lib/pdfForts/*.sh; do
substituteInPlace $i \
--replace /usr/share/kservices5/ServiceMenus/pdfForts/ $out/share/kservices5/ServiceMenus/pdfForts/ \
--replace pdftk ${pdftk}/bin/pdftk \
--replace kate ${kate}/bin/kate \
--replace zenity ${gnome3.zenity}/bin/zenity
done
mkdir -p $out/share/kservices5/ServiceMenus/pdfForts/
cp **/*.desktop $out/share/kservices5/ServiceMenus/pdfForts/
# For testing point the .desktop entries to /run/current-system/sw/bin/ instead of:
# --replace /usr/bin/pdfForts/ $out/bin/
for i in $out/share/kservices5/ServiceMenus/pdfForts/*.desktop; do
substituteInPlace $i \
--replace /usr/bin/pdfForts/ /run/current-system/sw/bin/
done
# NixOS does not provide exactimage / hocr2pdf -> hence searchable pdf needs to be removed
rm $out/bin/searchablePDF.sh
rm $out/share/kservices5/ServiceMenus/pdfForts/searchablePDF.desktop
mkdir -p $out/share/pdfForts
cp **/*.conf $out/share/pdfForts/
cp **/*.odt $out/share/pdfForts/
for i in $out/share/pdfForts/*.conf; do
substituteInPlace $i \
--replace /usr/share/kservices5/ServiceMenus/pdfForts/ /run/current-system/sw/share/pdfForts/
done
'';
}


#watermarkPDF

0 comments on commit b39c516

Please sign in to comment.