summary refs log tree commit diff
path: root/pkgs/applications/office/zotero/default.nix
blob: 8e2f6bce0b14ebac824b6c39b2d1cc7c753d819b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ stdenv, fetchurl, buildFHSUserEnv, makeDesktopItem, runCommand, bash, wrapGAppsHook, gsettings-desktop-schemas, gtk3, gnome3 }:

let
version = "5.0.25";
meta = with stdenv.lib; {
  homepage = https://www.zotero.org;
  description = "Collect, organize, cite, and share your research sources";
  license = licenses.agpl3;
  platforms = platforms.linux;
};

zoteroSrc = stdenv.mkDerivation rec {
  inherit version;
  name = "zotero-${version}-pkg";

  src = fetchurl {
    url = "https://download.zotero.org/client/release/${version}/Zotero-${version}_linux-x86_64.tar.bz2";
    sha256 = "1y3q5582xp4inpz137x0r9iscs1g0cjlqcfjpzl3klsq3yas688k";
  };

  buildInputs= [ wrapGAppsHook gsettings-desktop-schemas gtk3 gnome3.adwaita-icon-theme gnome3.dconf ];
  phases = [ "unpackPhase" "installPhase" "fixupPhase"];

  installPhase = ''
    mkdir -p $out/data
    cp -r * $out/data
    mkdir $out/bin
    ln -s $out/data/zotero $out/bin/zotero
  '';
};

fhsEnv = buildFHSUserEnv {
  name = "zotero-fhs-env";
  targetPkgs = pkgs: with pkgs; with xlibs; [
    gtk3 dbus-glib
    libXt nss
  ];
};

desktopItem = makeDesktopItem rec {
  name = "zotero-${version}";
  exec = "zotero -url %U";
  icon = "zotero";
  type = "Application";
  comment = meta.description;
  desktopName = "Zotero";
  genericName = "Reference Management";
  categories = "Office;Database;";
  startupNotify = "true";
};

in runCommand "zotero-${version}" { inherit meta; } ''
  mkdir -p $out/bin $out/share/applications
  cat >$out/bin/zotero <<EOF
#!${bash}/bin/bash
${fhsEnv}/bin/zotero-fhs-env ${zoteroSrc}/bin/zotero
EOF
  chmod +x $out/bin/zotero

  cp ${desktopItem}/share/applications/* $out/share/applications/

  for size in 16 32 48 256; do
    install -Dm444 ${zoteroSrc}/data/chrome/icons/default/default$size.png \
      $out/share/icons/hicolor/''${size}x''${size}/apps/zotero.png
  done
''