summary refs log tree commit diff
path: root/pkgs/applications/networking/super-productivity/default.nix
blob: 7a70375e42c9d7d7afc8ca48cb5e53fd552bb04c (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{ stdenv, fetchurl, dpkg, makeWrapper
, alsaLib, atk, cairo, cups, curl, dbus, expat, fontconfig, freetype, glib
, gnome2, gtk3, gdk-pixbuf, libnotify, libxcb, nspr, nss, pango
, systemd, xorg, xprintidle-ng }:

let

  version = "1.10.45";

  rpath = stdenv.lib.makeLibraryPath [
    alsaLib
    atk
    cairo
    cups
    curl
    dbus
    expat
    fontconfig
    freetype
    glib
    gnome2.GConf
    gdk-pixbuf
    gtk3
    pango
    libnotify
    libxcb
    nspr
    nss
    stdenv.cc.cc
    systemd

    xorg.libxkbfile
    xorg.libX11
    xorg.libXcomposite
    xorg.libXcursor
    xorg.libXdamage
    xorg.libXext
    xorg.libXfixes
    xorg.libXi
    xorg.libXrandr
    xorg.libXrender
    xorg.libXtst
    xorg.libXScrnSaver
  ] + ":${stdenv.cc.cc.lib}/lib64";

  src =
    if stdenv.hostPlatform.system == "x86_64-linux" then
      fetchurl {
        url = "https://github.com/johannesjo/super-productivity/releases/download/v${version}/superProductivity_${version}_amd64.deb";
        sha256 = "0jfi0lfijnhij9jvkhxgyvq8m1jzaym8n1c7707fv3hjh1h0vxn1";
      }
    else
      throw "super-productivity is not supported on ${stdenv.hostPlatform.system}";

in stdenv.mkDerivation {
  pname = "super-productivity";
  inherit version;

  inherit src;

  buildInputs = [
    dpkg
    gtk3  # needed for GSETTINGS_SCHEMAS_PATH
  ];

  nativeBuildInputs = [ makeWrapper ];

  unpackPhase = "dpkg -x $src .";

  installPhase = ''
    runHook preInstall

    mkdir -p $out

    cp -R usr/share $out/share
    cp -R opt $out/libexec

    # Otherwise it looks "suspicious"
    chmod -R g-w $out

    # set linker and rpath
    patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$out/libexec/superProductivity/superproductivity"
    patchelf --set-rpath ${rpath}:$out/libexec/superProductivity "$out/libexec/superProductivity/superproductivity"

    # wrapper for xdg_data_dirs and xprintidle path
    makeWrapper $out/libexec/superProductivity/superproductivity $out/bin/superproductivity \
      --prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \
      --prefix PATH : "${xprintidle-ng}/bin"

    # Fix the desktop link
    substituteInPlace $out/share/applications/superproductivity.desktop \
      --replace /opt/superProductivity/ $out/bin/

    runHook postInstall
  '';

  dontStrip = true;

  meta = with stdenv.lib; {
    description = "To Do List / Time Tracker with Jira Integration.";
    homepage = "https://super-productivity.com";
    license = licenses.mit;
    platforms = [ "x86_64-linux" ];
    maintainers = with maintainers; [ offline ];
  };
}