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