1{ stdenv, lib, fetchurl, alsa-lib, atk, cairo, cups, udev, libdrm, mesa
2, dbus, expat, fontconfig, freetype, gdk-pixbuf, glib, gtk3, libappindicator-gtk3
3, libnotify, nspr, nss, pango, systemd, xorg, autoPatchelfHook, wrapGAppsHook
4, runtimeShell, gsettings-desktop-schemas }:
5
6let
7 versionSuffix = "20230726175256.4464bfb32d";
8in
9
10stdenv.mkDerivation rec {
11 pname = "keybase-gui";
12 version = "6.2.2"; # Find latest version from https://prerelease.keybase.io/deb/dists/stable/main/binary-amd64/Packages
13
14 src = fetchurl {
15 url = "https://s3.amazonaws.com/prerelease.keybase.io/linux_binaries/deb/keybase_${version + "-" + versionSuffix}_amd64.deb";
16 hash = "sha256-X3BJksdddTdxeUqVjzcq3cDRGRqmaYE7Z+eXtHoqbkg=";
17 };
18
19 nativeBuildInputs = [
20 autoPatchelfHook
21 wrapGAppsHook
22 ];
23
24 buildInputs = [
25 alsa-lib
26 atk
27 cairo
28 cups
29 dbus
30 expat
31 fontconfig
32 freetype
33 gdk-pixbuf
34 glib
35 gsettings-desktop-schemas
36 gtk3
37 libappindicator-gtk3
38 libnotify
39 nspr
40 nss
41 pango
42 systemd
43 xorg.libX11
44 xorg.libXScrnSaver
45 xorg.libXcomposite
46 xorg.libXcursor
47 xorg.libXdamage
48 xorg.libXext
49 xorg.libXfixes
50 xorg.libXi
51 xorg.libXrandr
52 xorg.libXrender
53 xorg.libXtst
54 xorg.libxcb
55 libdrm
56 mesa.out
57 ];
58
59 runtimeDependencies = [
60 (lib.getLib udev)
61 libappindicator-gtk3
62 ];
63
64 dontBuild = true;
65 dontConfigure = true;
66 dontPatchELF = true;
67
68 unpackPhase = ''
69 ar xf $src
70 tar xf data.tar.xz
71 '';
72
73 installPhase = ''
74 mkdir -p $out/bin
75 mv usr/share $out/share
76 mv opt/keybase $out/share/
77
78 cat > $out/bin/keybase-gui <<EOF
79 #!${runtimeShell}
80
81 checkFailed() {
82 if [ "\$NIX_SKIP_KEYBASE_CHECKS" = "1" ]; then
83 return
84 fi
85 echo "Set NIX_SKIP_KEYBASE_CHECKS=1 if you want to skip this check." >&2
86 exit 1
87 }
88
89 if [ ! -S "\$XDG_RUNTIME_DIR/keybase/keybased.sock" ]; then
90 echo "Keybase service doesn't seem to be running." >&2
91 echo "You might need to run: keybase service" >&2
92 checkFailed
93 fi
94
95 if [ -z "\$(keybase status | grep kbfsfuse)" ]; then
96 echo "Could not find kbfsfuse client in keybase status." >&2
97 echo "You might need to run: kbfsfuse" >&2
98 checkFailed
99 fi
100
101 exec $out/share/keybase/Keybase "\$@"
102 EOF
103 chmod +x $out/bin/keybase-gui
104
105 substituteInPlace $out/share/applications/keybase.desktop \
106 --replace run_keybase $out/bin/keybase-gui
107 '';
108
109 meta = with lib; {
110 homepage = "https://www.keybase.io/";
111 description = "The Keybase official GUI";
112 platforms = [ "x86_64-linux" ];
113 maintainers = with maintainers; [ avaq rvolosatovs puffnfresh np Br1ght0ne shofius ];
114 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
115 license = licenses.bsd3;
116 };
117}