nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 pname,
3 program,
4 src,
5 year,
6 version,
7 desktopName,
8 longDescription,
9 broken ? false,
10 buildFHSEnv,
11 extraBuildInputs ? [ ],
12 jdk,
13 stdenv,
14 lib,
15 dpkg,
16 makeDesktopItem,
17 copyDesktopItems,
18 autoPatchelfHook,
19 sane-backends,
20 cups,
21}:
22let
23 thisPackage = stdenv.mkDerivation rec {
24 inherit pname src version;
25 strictDeps = true;
26
27 buildInputs = [
28 sane-backends # for libsane.so.1
29 ]
30 ++ extraBuildInputs;
31
32 nativeBuildInputs = [
33 autoPatchelfHook
34 dpkg
35 copyDesktopItems
36 ];
37
38 desktopItems = [
39 (makeDesktopItem {
40 name = "${pname}";
41 desktopName = desktopName;
42 genericName = "View and edit PDF files";
43 exec = "${pname} %f";
44 icon = "${pname}";
45 comment = "Views and edits PDF files";
46 mimeTypes = [ "application/pdf" ];
47 categories = [ "Office" ];
48 })
49 ];
50
51 dontBuild = true;
52
53 postPatch = ''
54 substituteInPlace opt/${program}${year}/${program}${year} --replace "# INSTALL4J_JAVA_HOME_OVERRIDE=" "INSTALL4J_JAVA_HOME_OVERRIDE=${jdk.out}"
55 substituteInPlace opt/${program}${year}/updater --replace "# INSTALL4J_JAVA_HOME_OVERRIDE=" "INSTALL4J_JAVA_HOME_OVERRIDE=${jdk.out}"
56 '';
57
58 installPhase = ''
59 runHook preInstall
60
61 mkdir -p $out/{bin,share/pixmaps}
62 rm -rf opt/${program}${year}/jre
63 cp -r opt/${program}${year} $out/share/
64 ln -s $out/share/${program}${year}/.install4j/${program}${year}.png $out/share/pixmaps/${pname}.png
65 ln -s $out/share/${program}${year}/${program}${year} $out/bin/
66
67 runHook postInstall
68 '';
69 };
70
71in
72# Package with cups in FHS sandbox, because JAVA bin expects "/usr/bin/lpr" for printing.
73buildFHSEnv {
74 inherit pname version;
75
76 targetPkgs = pkgs: [
77 cups
78 thisPackage
79 ];
80
81 runScript = "${program}${year}";
82
83 # link desktop item and icon into FHS user environment
84 extraInstallCommands = ''
85 mkdir -p "$out/share/applications"
86 mkdir -p "$out/share/pixmaps"
87 ln -s ${thisPackage}/share/applications/*.desktop "$out/share/applications/"
88 ln -s ${thisPackage}/share/pixmaps/*.png "$out/share/pixmaps/"
89 '';
90
91 meta = {
92 inherit broken;
93 homepage = "https://www.qoppa.com/${pname}/";
94 description = "Easy to use, full-featured PDF editing software";
95 longDescription = longDescription;
96 sourceProvenance = with lib.sourceTypes; [
97 binaryBytecode
98 binaryNativeCode
99 ];
100 license = lib.licenses.unfree;
101 platforms = lib.platforms.linux;
102 mainProgram = pname;
103 maintainers = with lib.maintainers; [ pwoelfel ];
104 };
105}