@@ -1,67 +1,140 @@
1−{ stdenv, fetchurl, buildFHSUserEnv, makeDesktopItem, runCommand, bash, wrapGAppsHook, gsettings-desktop-schemas, gtk3, gnome3 }:
2−
3−let
4−version = "5.0.60";
5−meta = with stdenv.lib; {
6− homepage = https://www.zotero.org;
7− description = "Collect, organize, cite, and share your research sources";
8− license = licenses.agpl3;
9− platforms = platforms.linux;
10−};
11−
12−zoteroSrc = stdenv.mkDerivation rec {
13− inherit version;
14− name = "zotero-${version}-pkg";
1+{ stdenv, fetchurl, wrapGAppsHook, makeDesktopItem
2+, atk
3+, cairo
4+, curl
5+, cups
6+, dbus-glib
7+, dbus
8+, fontconfig
9+, freetype
10+, gdk_pixbuf
11+, glib
12+, glibc
13+, gtk3
14+, libX11
15+, libXScrnSaver
16+, libxcb
17+, libXcomposite
18+, libXcursor
19+, libXdamage
20+, libXext
21+, libXfixes
22+, libXi
23+, libXinerama
24+, libXrender
25+, libXt
26+, libnotify
27+, gnome3
28+, libGLU_combined
29+, nspr
30+, nss
31+, pango
32+, coreutils
33+, gnused
34+, gsettings-desktop-schemas
35+}:
1536
37+stdenv.mkDerivation rec {
38+ name = "zotero-${version}";
39+ version = "5.0.60";
40+
1641 src = fetchurl {
1742 url = "https://download.zotero.org/client/release/${version}/Zotero-${version}_linux-x86_64.tar.bz2";
1843 sha256 = "0753xk95shhxma4dvdxrj2q6y81z8lianxg7jnab9m17fb67jy2d";
1944 };
20−
45+
2146 buildInputs= [ wrapGAppsHook gsettings-desktop-schemas gtk3 gnome3.adwaita-icon-theme gnome3.dconf ];
22− phases = [ "unpackPhase" "installPhase" "fixupPhase"];
2347
24− installPhase = ''
25− mkdir -p $out/data
26− cp -r * $out/data
27− mkdir $out/bin
28− ln -s $out/data/zotero $out/bin/zotero
48+ phases = [ "unpackPhase" "patchPhase" "installPhase" "fixupPhase" ];
49+
50+ dontStrip = true;
51+ dontPatchELF = true;
52+
53+ libPath = stdenv.lib.makeLibraryPath
54+ [ stdenv.cc.cc
55+ atk
56+ cairo
57+ curl
58+ cups
59+ dbus-glib
60+ dbus
61+ fontconfig
62+ freetype
63+ gdk_pixbuf
64+ glib
65+ glibc
66+ gtk3
67+ libX11
68+ libXScrnSaver
69+ libXcomposite
70+ libXcursor
71+ libxcb
72+ libXdamage
73+ libXext
74+ libXfixes
75+ libXi
76+ libXinerama
77+ libXrender
78+ libXt
79+ libnotify
80+ libGLU_combined
81+ nspr
82+ nss
83+ pango
84+ ] + ":" + stdenv.lib.makeSearchPathOutput "lib" "lib64" [
85+ stdenv.cc.cc
86+ ];
87+
88+ patchPhase = ''
89+ sed -i '/pref("app.update.enabled", true);/c\pref("app.update.enabled", false);' defaults/preferences/prefs.js
2990 '';
30−};
3191
32−fhsEnv = buildFHSUserEnv {
33− name = "zotero-fhs-env";
34− targetPkgs = pkgs: with pkgs; with xorg; [
35− gtk3 dbus-glib glib
36− libXt nss
37− libX11
38− ];
39−};
92+ desktopItem = makeDesktopItem rec {
93+ name = "zotero-${version}";
94+ exec = "zotero -url %U";
95+ icon = "zotero";
96+ type = "Application";
97+ comment = meta.description;
98+ desktopName = "Zotero";
99+ genericName = "Reference Management";
100+ categories = "Office;Database;";
101+ startupNotify = "true";
102+ mimeType = "text/plain";
103+ };
40104
41−desktopItem = makeDesktopItem rec {
42− name = "zotero-${version}";
43− exec = "zotero -url %U";
44− icon = "zotero";
45− type = "Application";
46− comment = meta.description;
47− desktopName = "Zotero";
48− genericName = "Reference Management";
49− categories = "Office;Database;";
50− startupNotify = "true";
51−};
105+ installPhase =
106+ ''
107+ mkdir -p "$prefix/usr/lib/zotero-bin-${version}"
108+ cp -r * "$prefix/usr/lib/zotero-bin-${version}"
109+ mkdir -p "$out/bin"
110+ ln -s "$prefix/usr/lib/zotero-bin-${version}/zotero" "$out/bin/"
52111
53−in runCommand "zotero-${version}" { inherit meta; } ''
54− mkdir -p $out/bin $out/share/applications
55− cat >$out/bin/zotero <<EOF
56−#!${bash}/bin/bash
57−${fhsEnv}/bin/zotero-fhs-env ${zoteroSrc}/bin/zotero
58−EOF
59− chmod +x $out/bin/zotero
112+ # install desktop file and icons.
113+ mkdir -p $out/share/applications
114+ cp ${desktopItem}/share/applications/* $out/share/applications/
115+ for size in 16 32 48 256; do
116+ install -Dm444 chrome/icons/default/default$size.png \
117+ $out/share/icons/hicolor/''${size}x''${size}/apps/zotero.png
118+ done
60119
61− cp ${desktopItem}/share/applications/* $out/share/applications/
120+ for executable in \
121+ zotero-bin plugin-container \
122+ updater minidump-analyzer
123+ do
124+ if [ -e "$out/usr/lib/zotero-bin-${version}/$executable" ]; then
125+ patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
126+ "$out/usr/lib/zotero-bin-${version}/$executable"
127+ fi
128+ done
129+ find . -executable -type f -exec \
130+ patchelf --set-rpath "$libPath" \
131+ "$out/usr/lib/zotero-bin-${version}/{}" \;
132+ '';
62133
63− for size in 16 32 48 256; do
64− install -Dm444 ${zoteroSrc}/data/chrome/icons/default/default$size.png \
65− $out/share/icons/hicolor/''${size}x''${size}/apps/zotero.png
66− done
67−''
134+ meta = with stdenv.lib; {
135+ homepage = https://www.zotero.org;
136+ description = "Collect, organize, cite, and share your research sources";
137+ license = licenses.agpl3;
138+ platforms = platforms.linux;
139+ };
140+}