1{
2 lib,
3 stdenv,
4 autoPatchelfHook,
5 makeDesktopItem,
6 makeWrapper,
7 copyDesktopItems,
8
9 # Dynamic Libraries
10 curl,
11 glib,
12 gst_all_1,
13 libGL,
14 libX11,
15 libXext,
16 libXmu,
17 libXrandr,
18 libXrender,
19
20 # For fixing up execution of /bin/ls, which is necessary for
21 # product unlocking.
22 coreutils,
23 libredirect,
24
25 # Extra utilities used by the SoftMaker applications.
26 gnugrep,
27 util-linux,
28 which,
29
30 pname,
31 version,
32 edition,
33 suiteName,
34 src,
35 archive,
36
37 ...
38}:
39
40let
41 desktopItems = import ./desktop_items.nix {
42 inherit makeDesktopItem pname suiteName;
43 };
44 shortEdition = builtins.substring 2 2 edition;
45in
46stdenv.mkDerivation {
47 inherit pname src;
48
49 version = if edition != "" then "${edition}.${version}" else version;
50
51 nativeBuildInputs = [
52 autoPatchelfHook
53 copyDesktopItems
54 makeWrapper
55 ];
56
57 buildInputs = [
58 curl
59 glib
60 gst_all_1.gstreamer
61 gst_all_1.gst-plugins-base
62 libGL
63 libX11
64 libXext
65 libXmu
66 libXrandr
67 libXrender
68 (lib.getLib stdenv.cc.cc)
69 ];
70
71 dontBuild = true;
72 dontConfigure = true;
73
74 unpackPhase = ''
75 runHook preUnpack
76
77 mkdir installer
78 tar -C installer -xf ${src}
79 mkdir ${pname}
80 tar -C ${pname} -xf installer/${archive}
81
82 runHook postUnpack
83 '';
84
85 installPhase =
86 let
87 # SoftMaker/FreeOffice collects some system information upon
88 # unlocking the product. But in doing so, it attempts to execute
89 # /bin/ls. If the execve syscall fails, the whole unlock
90 # procedure fails. This works around that by rewriting /bin/ls
91 # to the proper path.
92 #
93 # In addition, it expects some common utilities (which, whereis)
94 # to be in the path.
95 #
96 # SoftMaker Office restarts itself upon some operations, such
97 # changing the theme and unlocking. Unfortunately, we do not
98 # have control over its environment then and it will fail
99 # with an error.
100 extraWrapperArgs = ''
101 --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
102 --set NIX_REDIRECTS "/bin/ls=${coreutils}/bin/ls" \
103 --prefix PATH : "${
104 lib.makeBinPath [
105 coreutils
106 gnugrep
107 util-linux
108 which
109 ]
110 }"
111 '';
112 in
113 ''
114 runHook preInstall
115
116 mkdir -p $out/share
117 cp -r ${pname} $out/share/${pname}${edition}
118
119 # Wrap rather than symlinking, so that the programs can determine
120 # their resource path.
121 mkdir -p $out/bin
122 makeWrapper $out/share/${pname}${edition}/planmaker $out/bin/${pname}-planmaker \
123 ${extraWrapperArgs}
124 makeWrapper $out/share/${pname}${edition}/presentations $out/bin/${pname}-presentations \
125 ${extraWrapperArgs}
126 makeWrapper $out/share/${pname}${edition}/textmaker $out/bin/${pname}-textmaker \
127 ${extraWrapperArgs}
128
129 for size in 16 32 48 64 96 128 256 512 1024; do
130 mkdir -p $out/share/icons/hicolor/''${size}x''${size}/apps
131
132 for app in pml prl tml; do
133 ln -s $out/share/${pname}${edition}/icons/''${app}_''${size}.png \
134 $out/share/icons/hicolor/''${size}x''${size}/apps/${pname}-''${app}.png
135 done
136
137 mkdir -p $out/share/icons/hicolor/''${size}x''${size}/mimetypes
138
139 for mimetype in pmd prd tmd; do
140 ln -s $out/share/${pname}${edition}/icons/''${mimetype}_''${size}.png \
141 $out/share/icons/hicolor/''${size}x''${size}/mimetypes/application-x-''${mimetype}.png
142 done
143 done
144
145 # freeoffice 973 misses the 96x96 application icons, giving broken symbolic links
146 # remove broken symbolic links
147 find $out -xtype l -ls -exec rm {} \;
148
149 # Add mime types
150 install -D -t $out/share/mime/packages ${pname}/mime/softmaker-*office*${shortEdition}.xml
151
152 runHook postInstall
153 '';
154
155 desktopItems = builtins.attrValues desktopItems;
156
157 meta = {
158 description = "Office suite with a word processor, spreadsheet and presentation program";
159 homepage = "https://www.softmaker.com/";
160 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
161 license = lib.licenses.unfree;
162 maintainers = with lib.maintainers; [ liberodark ];
163 platforms = [ "x86_64-linux" ];
164 };
165}