nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 pkg-config,
6 wrapGAppsHook3,
7 atk,
8 bzip2,
9 cairo,
10 dbus,
11 gdk-pixbuf,
12 glib,
13 gst_all_1,
14 gtk3,
15 libayatana-appindicator,
16 libgit2,
17 libpulseaudio,
18 libsodium,
19 libXtst,
20 libvpx,
21 libyuv,
22 libopus,
23 libaom,
24 libxkbcommon,
25 libsciter,
26 xdotool,
27 openssl,
28 pam,
29 pango,
30 perl,
31 zlib,
32 zstd,
33 stdenv,
34 alsa-lib,
35 makeDesktopItem,
36 copyDesktopItems,
37}:
38
39rustPlatform.buildRustPackage (finalAttrs: {
40 pname = "rustdesk";
41 version = "1.4.5";
42
43 src = fetchFromGitHub {
44 owner = "rustdesk";
45 repo = "rustdesk";
46 tag = finalAttrs.version;
47 fetchSubmodules = true;
48 hash = "sha256-FRtYafsIKHnGPV8NaiaHxIHkon8/T2P83uq9taUD1Xc=";
49 };
50
51 cargoHash = "sha256-mEtTo1ony5w/dzJcHieG9WywHirBoQ/C0WpiAr7pUVc=";
52
53 patches = [
54 ./make-build-reproducible.patch
55 ];
56
57 desktopItems = [
58 (makeDesktopItem {
59 name = "rustdesk";
60 exec = finalAttrs.meta.mainProgram;
61 icon = "rustdesk";
62 desktopName = "RustDesk";
63 comment = finalAttrs.meta.description;
64 genericName = "Remote Desktop";
65 categories = [ "Network" ];
66 mimeTypes = [ "x-scheme-handler/rustdesk" ];
67 })
68 ];
69
70 nativeBuildInputs = [
71 copyDesktopItems
72 perl
73 pkg-config
74 rustPlatform.bindgenHook
75 wrapGAppsHook3
76 ];
77
78 buildFeatures = lib.optionals stdenv.hostPlatform.isLinux [ "linux-pkg-config" ];
79
80 # Checks require an active X server
81 doCheck = false;
82
83 buildInputs = [
84 atk
85 bzip2
86 cairo
87 dbus
88 gdk-pixbuf
89 glib
90 gst_all_1.gst-plugins-base
91 gst_all_1.gstreamer
92 gtk3
93 libgit2
94 libpulseaudio
95 libsodium
96 libXtst
97 libvpx
98 libyuv
99 libopus
100 libaom
101 libxkbcommon
102 openssl
103 pam
104 pango
105 zlib
106 zstd
107 ]
108
109 ++ lib.optionals stdenv.hostPlatform.isLinux [
110 alsa-lib
111 xdotool
112 ];
113
114 postPatch = ''
115 sed -e '1i #include <cstdint>' -i $cargoDepsCopy/webm-1.1.0/src/sys/libwebm/mkvparser/mkvparser.cc
116 sed -e '1i #include <cstdint>' -i $cargoDepsCopy/webm-sys-1.0.4/libwebm/mkvparser/mkvparser.cc
117 '';
118
119 # Add static ui resources and libsciter to same folder as binary so that it
120 # can find them.
121 postInstall = ''
122 mkdir -p $out/{share/src,lib/rustdesk}
123
124 # .so needs to be next to the executable
125 mv $out/bin/rustdesk $out/lib/rustdesk
126 ${lib.optionalString stdenv.hostPlatform.isLinux "ln -s ${libsciter}/lib/libsciter-gtk.so $out/lib/rustdesk"}
127
128 makeWrapper $out/lib/rustdesk/rustdesk $out/bin/rustdesk \
129 --chdir "$out/share"
130
131 cp -a $src/src/ui $out/share/src
132
133 install -Dm0644 $src/res/logo.svg $out/share/icons/hicolor/scalable/apps/rustdesk.svg
134 '';
135
136 postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
137 patchelf --add-rpath "${libayatana-appindicator}/lib" "$out/lib/rustdesk/rustdesk"
138 '';
139
140 env = {
141 SODIUM_USE_PKG_CONFIG = true;
142 ZSTD_SYS_USE_PKG_CONFIG = true;
143 };
144
145 meta = {
146 description = "Virtual / remote desktop infrastructure for everyone! Open source TeamViewer / Citrix alternative";
147 homepage = "https://rustdesk.com";
148 changelog = "https://github.com/rustdesk/rustdesk/releases/tag/${finalAttrs.version}";
149 license = lib.licenses.agpl3Only;
150 maintainers = with lib.maintainers; [
151 ocfox
152 leixb
153 ];
154 mainProgram = "rustdesk";
155 badPlatforms = lib.platforms.darwin;
156 };
157})