summary refs log tree commit diff
path: root/pkgs/applications/misc/todoist-electron/default.nix
blob: 798f1708ae705ab185ca86b632c5968e0a95d00c (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
{ stdenv, lib, fetchurl, makeDesktopItem, dpkg, atk, at-spi2-atk, glib, pango, gdk-pixbuf
, gtk3, cairo, freetype, fontconfig, dbus, xorg, nss, nspr, alsaLib, cups, expat
, udev, libpulseaudio, utillinux, makeWrapper }:

stdenv.mkDerivation rec {
  pname = "todoist-electron";
  version = "1.20";

  src = fetchurl {
    url = "https://github.com/KryDos/todoist-linux/releases/download/${version}/Todoist_${version}.0_amd64.deb";
    sha256 = "0w885xqy1304cp6b0jll5lvm6b1zd1ciqjl97d2hkdi8c9gv3bqx";
  };

  desktopItem = makeDesktopItem {
    name = "Todoist";
    exec = "todoist";
    desktopName = "Todoist";
    categories = "Utility";
  };

  nativeBuildInputs = [ makeWrapper dpkg ];
  unpackPhase = ''
    mkdir pkg
    dpkg-deb -x $src pkg
    sourceRoot=pkg
  '';
  installPhase = let
    libPath = lib.makeLibraryPath ([
      stdenv.cc.cc gtk3 atk at-spi2-atk glib pango gdk-pixbuf cairo freetype fontconfig dbus
      nss nspr alsaLib libpulseaudio cups expat udev utillinux
    ] ++ (with xorg; [
      libXi libXcursor libXdamage libXrandr libXcomposite libXext libXfixes libxcb
      libXrender libX11 libXtst libXScrnSaver
    ]));
  in ''
    mkdir -p "$out/bin"
    mv opt "$out/"

    # Patch binary
    patchelf \
      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      --set-rpath "${libPath}:\$ORIGIN" \
      $out/opt/Todoist/todoist

    # Hacky workaround for RPATH problems
    makeWrapper $out/opt/Todoist/todoist $out/bin/todoist \
      --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libpulseaudio udev ]}

    # Desktop item
    mkdir -p "$out/share"
    ln -s "${desktopItem}/share/applications" "$out/share/applications"
  '';

  meta = with lib; {
    homepage = "https://github.com/KryDos/todoist-linux";
    description = "The Linux wrapper for Todoist web version";
    platforms = [ "x86_64-linux" ];
    license = licenses.isc;
    maintainers = with maintainers; [ i077 ];
  };
}