about summary refs log tree commit diff
path: root/pkgs/applications/misc/pdfstudio
diff options
context:
space:
mode:
authorPhilipp Woelfel <philipp.woelfel@gmail.com>2022-01-24 16:30:39 -0700
committerGitHub <noreply@github.com>2022-01-25 00:30:39 +0100
commite79bb564af849cab074452a9ed24208e0002c716 (patch)
treec2c1c4ab3df253329ec89b15c83f935f3a18d0a4 /pkgs/applications/misc/pdfstudio
parent7f9c0d168325b925881622accd8e9dadb343876b (diff)
pdfstudio: merge with package pdfstudioviewer (#156274)
* pdfstudio: merge with pdfstudioviewer and use FHS sandbox to fix printing

Co-authored-by: Ivv <41924494+IvarWithoutBones@users.noreply.github.com>
Diffstat (limited to 'pkgs/applications/misc/pdfstudio')
-rw-r--r--pkgs/applications/misc/pdfstudio/common.nix98
-rw-r--r--pkgs/applications/misc/pdfstudio/default.nix113
2 files changed, 132 insertions, 79 deletions
diff --git a/pkgs/applications/misc/pdfstudio/common.nix b/pkgs/applications/misc/pdfstudio/common.nix
new file mode 100644
index 0000000000000..7240e8a026e2e
--- /dev/null
+++ b/pkgs/applications/misc/pdfstudio/common.nix
@@ -0,0 +1,98 @@
+{ pname
+, src
+, year
+, version
+, desktopName
+, longDescription
+, buildFHSUserEnv
+, extraBuildInputs ? []
+, stdenv
+, lib
+, dpkg
+, makeDesktopItem
+, copyDesktopItems
+, autoPatchelfHook
+, sane-backends
+, cups
+, jdk11
+}:
+let
+  thisPackage = stdenv.mkDerivation rec {
+    inherit pname src version;
+    strictDeps = true;
+
+    buildInputs = [
+      sane-backends #for libsane.so.1
+      jdk11
+    ] ++ extraBuildInputs;
+
+    nativeBuildInputs = [
+      autoPatchelfHook
+      dpkg
+      copyDesktopItems
+    ];
+
+    desktopItems = [
+      (makeDesktopItem {
+        name = "${pname}${year}";
+        desktopName = desktopName;
+        genericName = "View and edit PDF files";
+        exec = "${pname} %f";
+        icon = "${pname}${year}";
+        comment = "Views and edits PDF files";
+        mimeType = "application/pdf";
+        categories = "Office";
+        type = "Application";
+        terminal = false;
+      })
+    ];
+
+    unpackCmd = "dpkg-deb -x $src ./${pname}-${version}";
+    dontBuild = true;
+
+    postPatch = ''
+      substituteInPlace opt/${pname}${year}/${pname}${year} --replace "# INSTALL4J_JAVA_HOME_OVERRIDE=" "INSTALL4J_JAVA_HOME_OVERRIDE=${jdk11.out}"
+      substituteInPlace opt/${pname}${year}/updater --replace "# INSTALL4J_JAVA_HOME_OVERRIDE=" "INSTALL4J_JAVA_HOME_OVERRIDE=${jdk11.out}"
+    '';
+
+    installPhase = ''
+      runHook preInstall
+
+      mkdir -p $out/{bin,share/pixmaps}
+      rm -rf opt/${pname}${year}/jre
+      cp -r opt/${pname}${year} $out/share/
+      ln -s $out/share/${pname}${year}/.install4j/${pname}${year}.png  $out/share/pixmaps/
+      ln -s $out/share/${pname}${year}/${pname}${year} $out/bin/${pname}
+
+      runHook postInstall
+    '';
+  };
+
+in
+# Package with cups in FHS sandbox, because JAVA bin expects "/usr/bin/lpr" for printing.
+buildFHSUserEnv {
+  name = pname;
+  targetPkgs = pkgs: [
+    cups
+    thisPackage
+  ];
+  runScript = pname;
+
+  # link desktop item and icon into FHS user environment
+  extraInstallCommands = ''
+    mkdir -p "$out/share/applications"
+    mkdir -p "$out/share/pixmaps"
+    ln -s ${thisPackage}/share/applications/*.desktop "$out/share/applications/"
+    ln -s ${thisPackage}/share/pixmaps/*.png "$out/share/pixmaps/"
+  '';
+
+  meta = with lib; {
+    homepage = "https://www.qoppa.com/${pname}/";
+    description = "An easy to use, full-featured PDF editing software";
+    longDescription = longDescription;
+    license = licenses.unfree;
+    platforms = platforms.linux;
+    mainProgram = pname;
+    maintainers = [ maintainers.pwoelfel ];
+  };
+}
diff --git a/pkgs/applications/misc/pdfstudio/default.nix b/pkgs/applications/misc/pdfstudio/default.nix
index 6b93cfb19c52d..18e8136eb7b41 100644
--- a/pkgs/applications/misc/pdfstudio/default.nix
+++ b/pkgs/applications/misc/pdfstudio/default.nix
@@ -1,87 +1,42 @@
-{ stdenv
-, lib
+{ program ? "pdfstudioviewer"
 , fetchurl
 , libgccjit
-, dpkg
-, makeDesktopItem
-, copyDesktopItems
-, autoPatchelfHook
-, sane-backends
-, jdk11
+, callPackage
 }:
 
-# See also package 'pdfstudioviewer'
-# Differences are ${pname}, Download directory name (PDFStudio / PDFStudioViewer),
-# sha256, and libgccjit (not needed for PDFStudioViewer)
-let year = "2021";
-in
-stdenv.mkDerivation rec {
-  pname = "pdfstudio";
-  version = "${year}.1.2";
-  strictDeps = true;
-
-  src = fetchurl {
-    url = "https://download.qoppa.com/${pname}/v${year}/PDFStudio_v${
+{
+  pdfstudio = callPackage ./common.nix rec {
+    pname = program;
+    year = "2021";
+    version = "${year}.1.2";
+    desktopName = "PDF Studio";
+    longDescription = ''
+      PDF Studio is an easy to use, full-featured PDF editing software. This is the standard/pro edition, which requires a license. For the free PDF Studio Viewer see the package pdfstudioviewer.
+    '';
+    extraBuildInputs = [
+      libgccjit #for libstdc++.so.6 and libgomp.so.1
+    ];
+    src = fetchurl {
+      url = "https://download.qoppa.com/${pname}/v${year}/PDFStudio_v${
         builtins.replaceStrings [ "." ] [ "_" ] version
-      }_linux64.deb";
-    sha256 = "1188ll2qz58rr2slavqxisbz4q3fdzidpasb1p33926z0ym3rk45";
+        }_linux64.deb";
+      sha256 = "1188ll2qz58rr2slavqxisbz4q3fdzidpasb1p33926z0ym3rk45";
+    };
   };
 
-  buildInputs = [
-    libgccjit #for libstdc++.so.6 and libgomp.so.1
-    sane-backends #for libsane.so.1
-    jdk11
-  ];
-
-  nativeBuildInputs = [
-    autoPatchelfHook
-    dpkg
-    copyDesktopItems
-  ];
-
-  desktopItems = [
-    (makeDesktopItem {
-      name = "${pname}${year}";
-      desktopName = "PDF Studio";
-      genericName = "View and edit PDF files";
-      exec = "${pname} %f";
-      icon = "${pname}${year}";
-      comment = "Views and edits PDF files";
-      mimeType = "application/pdf";
-      categories = "Office";
-      type = "Application";
-      terminal = false;
-    })
-  ];
-
-  unpackPhase = "dpkg-deb -x $src .";
-  dontBuild = true;
-
-  postPatch = ''
-    substituteInPlace opt/${pname}${year}/${pname}${year} --replace "# INSTALL4J_JAVA_HOME_OVERRIDE=" "INSTALL4J_JAVA_HOME_OVERRIDE=${jdk11.out}"
-    substituteInPlace opt/${pname}${year}/updater --replace "# INSTALL4J_JAVA_HOME_OVERRIDE=" "INSTALL4J_JAVA_HOME_OVERRIDE=${jdk11.out}"
-  '';
-
-  installPhase = ''
-    runHook preInstall
-
-    mkdir -p $out/bin
-    mkdir -p $out/share
-    mkdir -p $out/share/pixmaps
-    cp -r opt/${pname}${year} $out/share/
-    rm -rf $out/share/${pname}${year}/jre
-    ln -s $out/share/${pname}${year}/.install4j/${pname}${year}.png  $out/share/pixmaps/
-    ln -s $out/share/${pname}${year}/${pname}${year} $out/bin/${pname}
-
-    runHook postInstall
-  '';
-
-  meta = with lib; {
-    homepage = "https://www.qoppa.com/pdfstudio/";
-    description = "An easy to use, full-featured PDF editing software";
-    license = licenses.unfree;
-    platforms = platforms.linux;
-    mainProgram = pname;
-    maintainers = [ maintainers.pwoelfel ];
+  pdfstudioviewer = callPackage ./common.nix rec {
+    pname = program;
+    year = "2021";
+    version = "${year}.1.2";
+    desktopName = "PDF Studio Viewer";
+    longDescription = ''
+      PDF Studio Viewer is an easy to use, full-featured PDF editing software. This is the free edition. For the standard/pro edition, see the package pdfstudio.
+    '';
+    src = fetchurl {
+      url = "https://download.qoppa.com/${pname}/v${year}/PDFStudioViewer_v${
+          builtins.replaceStrings [ "." ] [ "_" ] version
+        }_linux64.deb";
+      sha256 = "128k3fm8m8zdykx4s30g5m2zl7cgmvs4qinf1w525zh84v56agz6";
+    };
   };
-}
+}.${program}