chromium,chromedriver: 129.0.6668.91 -> 129.0.6668.100
[NixPkgs.git] / pkgs / by-name / ru / rustdesk-flutter / package.nix
blob2dd1b134eaa63c42ad6a5b58007c5a748dee2574
2   lib,
3   clangStdenv,
4   cargo,
5   copyDesktopItems,
6   fetchFromGitHub,
7   flutter319,
8   ffmpeg,
9   gst_all_1,
10   fuse3,
11   libXtst,
12   libaom,
13   libopus,
14   libpulseaudio,
15   libva,
16   libvdpau,
17   libvpx,
18   libxkbcommon,
19   libyuv,
20   pam,
21   makeDesktopItem,
22   rustPlatform,
23   libayatana-appindicator,
24   rustc,
25   rustfmt,
26   xdotool,
28 let
30   flutterRustBridge = rustPlatform.buildRustPackage rec {
31     pname = "flutter_rust_bridge_codegen";
32     version = "1.80.1"; # https://github.com/rustdesk/rustdesk/blob/1.3.1/.github/workflows/bridge.yml#L10
34     src = fetchFromGitHub {
35       owner = "fzyzcjy";
36       repo = "flutter_rust_bridge";
37       rev = "v${version}";
38       hash = "sha256-SbwqWapJbt6+RoqRKi+wkSH1D+Wz7JmnVbfcfKkjt8Q=";
39     };
41     cargoHash = "sha256-dDyiptG9TKes+fXx2atwx697SWH7Rltx6xVubtTn7FM=";
42     cargoBuildFlags = [
43       "--package"
44       "flutter_rust_bridge_codegen"
45     ];
46     doCheck = false;
47   };
49   sharedLibraryExt = rustc.stdenv.hostPlatform.extensions.sharedLibrary;
52 flutter319.buildFlutterApplication rec {
53   pname = "rustdesk";
54   version = "1.3.1";
55   src = fetchFromGitHub {
56     owner = "rustdesk";
57     repo = "rustdesk";
58     rev = version;
59     hash = "sha256-PioaSdvgJ9oXC5DAbl+em7rxcGx1om9+sjCMdrvox90=";
60   };
62   strictDeps = true;
63   env.VCPKG_ROOT = "/homeless-shelter"; # idk man, makes the build go since https://github.com/21pages/hwcodec/commit/1873c34e3da070a462540f61c0b782b7ab15dc84
65   # Configure the Flutter/Dart build
66   sourceRoot = "${src.name}/flutter";
67   # curl https://raw.githubusercontent.com/rustdesk/rustdesk/1.3.1/flutter/pubspec.lock | yq > pubspec.lock.json
68   pubspecLock = lib.importJSON ./pubspec.lock.json;
69   gitHashes = {
70     dash_chat_2 = "sha256-J5Bc6CeCoRGN870aNEVJ2dkQNb+LOIZetfG2Dsfz5Ow=";
71     desktop_multi_window = "sha256-6nbOUmGTmJQx3Dr4MI6cKWwB1jEgUFUeHx24gpCkWY0=";
72     dynamic_layouts = "sha256-eFp1YVI6vI2HRgtE5nTqGZIylB226H0O8kuxy9ypuf8=";
73     flutter_gpu_texture_renderer = "sha256-0znIHlZ0ashRTev2kAXU179eq/V1RJC9Hp4jAfiPh5Q=";
74     flutter_improved_scrolling = "sha256-fKs1+JmhDVVfjyhr6Fl17pc6n++mCTjBo1PT3l/DUnc=";
75     window_manager = "sha256-CUTcSl+W7Wz/Og5k9ujOdAlhKWv/gIYe58wurf9CJH4=";
76     window_size = "sha256-+lqY46ZURT0qcqPvHFXUnd83Uvfq79Xr+rw1AHqrpak=";
77   };
79   # Configure the Rust build
80   cargoRoot = "..";
81   cargoDeps = rustPlatform.importCargoLock {
82     # Upstream lock file after removing the registry variant of core-foundation-sys
83     # and fixing the resulting errors by removing the other registry deps.
84     lockFile = ./Cargo.lock;
85     outputHashes = {
86       "android-wakelock-0.1.0" = "sha256-09EH/U1BBs3l4galQOrTKmPUYBgryUjfc/rqPZhdYc4=";
87       "arboard-3.4.0" = "sha256-xuMfMakHVj/zjiUr6PVFy+aNQxwsXtAAFlTYxUt12fU=";
88       "cacao-0.4.0-beta2" = "sha256-U5tCLeVxjmZCm7ti1u71+i116xmozPaR69pCsA4pxrM=";
89       "clipboard-master-4.0.0-beta.6" = "sha256-GZyzGMQOZ0iwGNZa/ZzFp8gU2tQVWZBpAbim8yb6yZA=";
90       "confy-0.4.0-2" = "sha256-V7BCKISrkJIxWC3WT5+B5Vav86YTQvdO9TO6A++47FU=";
91       "core-foundation-0.9.3" = "sha256-iB4OVmWZhuWbs9RFWvNc+RNut6rip2/50o5ZM6c0c3g=";
92       "evdev-0.11.5" = "sha256-aoPmjGi/PftnH6ClEWXHvIj0X3oh15ZC1q7wPC1XPr0=";
93       "hwcodec-0.7.0" = "sha256-SswZI2BJ4pRXT379cziJlisPsc5sOiOiDqJ5WaPETnA=";
94       "impersonate_system-0.1.0" = "sha256-pIV7s2qGoCIUrhaRovBDCJaGQ/pMdJacDXJmeBpkcyI=";
95       "keepawake-0.4.3" = "sha256-cqSpkq/PCz+5+ZUyPy5hF6rP3fBzuZDywyxMUQ50Rk4=";
96       "machine-uid-0.3.0" = "sha256-rEOyNThg6p5oqE9URnxSkPtzyW8D4zKzLi9pAnzTElE=";
97       "magnum-opus-0.4.0" = "sha256-T4qaYOl8lCK1h9jWa9KqGvnVfDViT9Ob5R+YgnSw2tg=";
98       "pam-0.7.0" = "sha256-o47tVoFlW9RiL7O8Lvuwz7rMYQHO+5TG27XxkAdHEOE=";
99       "pam-sys-1.0.0-alpha4" = "sha256-5HIErVWnanLo5054NgU+DEKC2wwyiJ8AHvbx0BGbyWo=";
100       "parity-tokio-ipc-0.7.3-4" = "sha256-PKw2Twd2ap+tRrQxqg8T1FvpoeKn0hvBqn1Z44F1LcY=";
101       "rdev-0.5.0-2" = "sha256-G+PvnA5mZyN080uoI5CGj/dQ9B1J4h5iYd7214MKBR8=";
102       "reqwest-0.11.23" = "sha256-kEUT+gs4ziknDiGdPMLnj5pmxC5SBpLopZ8jZ34GDWc=";
103       "rust-pulsectl-0.2.12" = "sha256-8jXTspWvjONFcvw9/Z8C43g4BuGZ3rsG32tvLMQbtbM=";
104       "sciter-rs-0.5.57" = "sha256-5Nd9npdx8yQJEczHv7WmSmrE1lBfvp5z7BubTbYBg3E=";
105       "sysinfo-0.29.10" = "sha256-/UsFAvlWs/F7X1xT+97Fx+pnpCguoPHU3hTynqYMEs4=";
106       "tao-0.25.0" = "sha256-kLmx1z9Ybn/hDt2OcszEjtZytQIE+NKTIn9zNr9oEQk=";
107       "tfc-0.7.0" = "sha256-4plK8ttbHsBPat3/rS+4RhGzirq2Ked2wrU8cQEU1zo=";
108       "tokio-socks-0.5.2-1" = "sha256-i1dfNatqN4dinMcyAdLhj9hJWVsT10OWpCXsxl7pifI=";
109       "tray-icon-0.14.3" = "sha256-dSX7LucZaLplRrh6zLwmFzyZN4ZtwIXzAEdZzlu3gQg=";
110       "wallpaper-3.2.0" = "sha256-p9NRmusdA0wvF6onp1UTL0/4t7XnEAc19sqyGDnfg/Q=";
111       "webm-1.1.0" = "sha256-p4BMej7yvb8c/dJynRWZmwo2hxAAY96Qx6Qx2DbT8hE=";
112       "x11-2.19.0" = "sha256-GDCeKzUtvaLeBDmPQdyr499EjEfT6y4diBMzZVEptzc=";
113       "x11-clipboard-0.8.1" = "sha256-PtqmSD2MwkbLVWbfTSXZW3WEvEnUlo04qieUTjN2whE=";
114     };
115   };
116   dontCargoBuild = true;
117   cargoBuildFlags = "--lib";
118   cargoBuildType = "release";
119   cargoBuildFeatures = [
120     "flutter"
121     "hwcodec"
122     "linux-pkg-config"
123   ];
125   nativeBuildInputs = [
126     # flutter_rust_bridge_codegen
127     cargo
128     copyDesktopItems
129     rustfmt
130     # Rust
131     rustPlatform.cargoSetupHook
132     rustPlatform.cargoBuildHook
133     rustPlatform.bindgenHook
134   ];
136   buildInputs = [
137     ffmpeg
138     fuse3
139     gst_all_1.gst-plugins-base
140     gst_all_1.gstreamer
141     libXtst
142     libaom
143     libopus
144     libpulseaudio
145     libva
146     libvdpau
147     libvpx
148     libxkbcommon
149     libyuv
150     pam
151     xdotool
152   ];
154   prePatch = ''
155     chmod -R +w ..
156   '';
157   patchFlags = [
158     "-p1"
159     "-d"
160     ".."
161   ];
163   patches = [ ./make-build-reproducible.patch ];
165   postPatch = ''
166     substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \
167       --replace-fail "libayatana-appindicator3.so.1" "${lib.getLib libayatana-appindicator}/lib/libayatana-appindicator3.so.1"
168     substituteInPlace ../Cargo.toml --replace-fail ", \"staticlib\", \"rlib\"" ""
169     # The supplied Cargo.lock doesn't work with our fetcher so copy over the fixed version
170     cp ${./Cargo.lock} ../Cargo.lock
171     chmod +w ../Cargo.lock
172   '';
174   preBuild = ''
175     # Disable static linking of ffmpeg since https://github.com/21pages/hwcodec/commit/1873c34e3da070a462540f61c0b782b7ab15dc84
176     sed -i 's/static=//g' /build/cargo-vendor-dir/hwcodec-*/build.rs
178     # Build the Flutter/Rust bridge bindings
179     cat <<EOF > bridge.yml
180     rust_input:
181       - "../src/flutter_ffi.rs"
182     dart_output:
183       - "./lib/generated_bridge.dart"
184     llvm_path:
185       - "${lib.getLib clangStdenv.cc.cc}"
186     dart_format_line_length: 80
187     llvm_compiler_opts: "-I ${lib.getLib clangStdenv.cc.cc}/lib/clang/${lib.versions.major clangStdenv.cc.version}/include -I ${clangStdenv.cc.libc_dev}/include"
188     EOF
189     RUST_LOG=info ${flutterRustBridge}/bin/flutter_rust_bridge_codegen bridge.yml
191     # Build the Rust shared library
192     cd ..
193     preBuild=() # prevent loops
194     cargoBuildHook
195     mv ./target/*/release/liblibrustdesk${sharedLibraryExt} ./target/release/liblibrustdesk${sharedLibraryExt}
196     cd flutter
197   '';
199   postInstall = ''
200     mkdir -p $out/share/polkit-1/actions $out/share/icons/hicolor/{256x256,scalable}/apps
201     cp ../res/128x128@2x.png $out/share/icons/hicolor/256x256/apps/rustdesk.png
202     cp ../res/scalable.svg $out/share/icons/hicolor/scalable/apps/rustdesk.svg
203   '';
205   desktopItems = [
206     (makeDesktopItem {
207       name = "rustdesk";
208       desktopName = "RustDesk";
209       genericName = "Remote Desktop";
210       comment = "Remote Desktop";
211       exec = "rustdesk %u";
212       icon = "rustdesk";
213       terminal = false;
214       type = "Application";
215       startupNotify = true;
216       categories = [
217         "Network"
218         "RemoteAccess"
219         "GTK"
220       ];
221       keywords = [ "internet" ];
222       actions.new-window = {
223         name = "Open a New Window";
224         exec = "rustdesk %u";
225       };
226     })
227     (makeDesktopItem {
228       name = "rustdesk-link";
229       desktopName = "RustDeskURL Scheme Handler";
230       noDisplay = true;
231       mimeTypes = [ "x-scheme-handler/rustdesk" ];
232       tryExec = "rustdesk";
233       exec = "rustdesk %u";
234       icon = "rustdesk";
235       terminal = false;
236       type = "Application";
237       startupNotify = false;
238     })
239   ];
241   meta = with lib; {
242     description = "Virtual / remote desktop infrastructure for everyone! Open source TeamViewer / Citrix alternative";
243     homepage = "https://rustdesk.com";
244     license = licenses.agpl3Only;
245     maintainers = with maintainers; [ das_j ];
246     mainProgram = "rustdesk";
247     platforms = platforms.linux; # should work on darwin as well but I have no machine to test with
248   };