1{
2 alsa-lib,
3 at-spi2-atk,
4 at-spi2-core,
5 atk,
6 cairo,
7 cups,
8 curl,
9 dbus,
10 dpkg,
11 expat,
12 fetchurl,
13 fontconfig,
14 freetype,
15 gdk-pixbuf,
16 glib,
17 gtk3,
18 lib,
19 libdrm,
20 libGL,
21 libnotify,
22 libsecret,
23 libuuid,
24 libxcb,
25 libxkbcommon,
26 libgbm,
27 nspr,
28 nss,
29 pango,
30 stdenv,
31 systemd,
32 wrapGAppsHook3,
33 xorg,
34 pname,
35 version,
36 meta,
37}:
38
39let
40 rpath = lib.makeLibraryPath [
41 alsa-lib
42 at-spi2-atk
43 at-spi2-core
44 atk
45 cairo
46 cups
47 curl
48 dbus
49 expat
50 fontconfig
51 freetype
52 gdk-pixbuf
53 glib
54 gtk3
55 libdrm
56 libGL
57 libnotify
58 libsecret
59 libuuid
60 libxcb
61 libxkbcommon
62 libgbm
63 nspr
64 nss
65 pango
66 stdenv.cc.cc
67 systemd
68 xorg.libX11
69 xorg.libXScrnSaver
70 xorg.libXcomposite
71 xorg.libXcursor
72 xorg.libXdamage
73 xorg.libXext
74 xorg.libXfixes
75 xorg.libXi
76 xorg.libXrandr
77 xorg.libXrender
78 xorg.libXtst
79 xorg.libxkbfile
80 xorg.libxshmfence
81 (lib.getLib stdenv.cc.cc)
82 ];
83
84in
85stdenv.mkDerivation {
86 inherit pname version meta;
87
88 src =
89 if stdenv.hostPlatform.system == "x86_64-linux" then
90 fetchurl {
91 url = "https://downloads.mongodb.com/compass/mongodb-compass_${version}_amd64.deb";
92 hash = "sha256-cwhYiV5G8GRBT7MST20MPUxEMQM1mzxlLUfzGO6jv10=";
93 }
94 else
95 throw "MongoDB compass is not supported on ${stdenv.hostPlatform.system}";
96
97 buildInputs = [
98 dpkg
99 wrapGAppsHook3
100 gtk3
101 ];
102 dontUnpack = true;
103
104 buildCommand = ''
105 IFS=$'\n'
106
107 # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here
108 dpkg --fsys-tarfile $src | tar --extract
109
110 mkdir -p $out
111 mv usr/* $out
112
113 # cp -av $out/usr/* $out
114 rm -rf $out/share/lintian
115
116 # The node_modules are bringing in non-linux files/dependencies
117 find $out -name "*.app" -exec rm -rf {} \; || true
118 find $out -name "*.dll" -delete
119 find $out -name "*.exe" -delete
120
121 # Otherwise it looks "suspicious"
122 chmod -R g-w $out
123
124 for file in `find $out -type f -perm /0111 -o -name \*.so\*`; do
125 echo "Manipulating file: $file"
126 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
127 patchelf --set-rpath ${rpath}:$out/lib/mongodb-compass "$file" || true
128 done
129
130 wrapGAppsHook $out/bin/mongodb-compass
131 '';
132}