2024-09-26 11:04:55 +00:00
{
lib ,
clangStdenv ,
cargo ,
copyDesktopItems ,
fetchFromGitHub ,
flutter319 ,
ffmpeg ,
gst_all_1 ,
fuse3 ,
libXtst ,
libaom ,
libopus ,
libpulseaudio ,
libva ,
libvdpau ,
libvpx ,
libxkbcommon ,
libyuv ,
pam ,
makeDesktopItem ,
rustPlatform ,
libayatana-appindicator ,
rustc ,
rustfmt ,
xdotool ,
} :
let
2024-02-07 01:22:34 +00:00
flutterRustBridge = rustPlatform . buildRustPackage rec {
pname = " f l u t t e r _ r u s t _ b r i d g e _ c o d e g e n " ;
2024-09-26 11:04:55 +00:00
version = " 1 . 8 0 . 1 " ; # https://github.com/rustdesk/rustdesk/blob/1.3.1/.github/workflows/bridge.yml#L10
2024-02-07 01:22:34 +00:00
src = fetchFromGitHub {
owner = " f z y z c j y " ;
repo = " f l u t t e r _ r u s t _ b r i d g e " ;
rev = " v ${ version } " ;
hash = " s h a 2 5 6 - S b w q W a p J b t 6 + R o q R K i + w k S H 1 D + W z 7 J m n V b f c f K k j t 8 Q = " ;
} ;
cargoHash = " s h a 2 5 6 - d D y i p t G 9 T K e s + f X x 2 a t w x 6 9 7 S W H 7 R l t x 6 x V u b t T n 7 F M = " ;
2024-09-26 11:04:55 +00:00
cargoBuildFlags = [
" - - p a c k a g e "
" f l u t t e r _ r u s t _ b r i d g e _ c o d e g e n "
] ;
2024-02-07 01:22:34 +00:00
doCheck = false ;
} ;
2024-02-29 20:09:43 +00:00
sharedLibraryExt = rustc . stdenv . hostPlatform . extensions . sharedLibrary ;
2024-09-26 11:04:55 +00:00
in
flutter319 . buildFlutterApplication rec {
2024-02-07 01:22:34 +00:00
pname = " r u s t d e s k " ;
2024-09-26 11:04:55 +00:00
version = " 1 . 3 . 1 " ;
2024-02-07 01:22:34 +00:00
src = fetchFromGitHub {
owner = " r u s t d e s k " ;
repo = " r u s t d e s k " ;
2024-04-21 15:54:59 +00:00
rev = version ;
2024-09-26 11:04:55 +00:00
hash = " s h a 2 5 6 - P i o a S d v g J 9 o X C 5 D A b l + e m 7 r x c G x 1 o m 9 + s j C M d r v o x 9 0 = " ;
2024-02-07 01:22:34 +00:00
} ;
strictDeps = true ;
2024-09-19 14:19:46 +00:00
env . VCPKG_ROOT = " / h o m e l e s s - s h e l t e r " ; # idk man, makes the build go since https://github.com/21pages/hwcodec/commit/1873c34e3da070a462540f61c0b782b7ab15dc84
2024-02-07 01:22:34 +00:00
# Configure the Flutter/Dart build
2024-04-21 15:54:59 +00:00
sourceRoot = " ${ src . name } / f l u t t e r " ;
2024-09-26 11:04:55 +00:00
# curl https://raw.githubusercontent.com/rustdesk/rustdesk/1.3.1/flutter/pubspec.lock | yq > pubspec.lock.json
2024-02-07 01:22:34 +00:00
pubspecLock = lib . importJSON ./pubspec.lock.json ;
gitHashes = {
dash_chat_2 = " s h a 2 5 6 - J 5 B c 6 C e C o R G N 8 7 0 a N E V J 2 d k Q N b + L O I Z e t f G 2 D s f z 5 O w = " ;
2024-09-19 14:19:46 +00:00
desktop_multi_window = " s h a 2 5 6 - 6 n b O U m G T m J Q x 3 D r 4 M I 6 c K W w B 1 j E g U F U e H x 2 4 g p C k W Y 0 = " ;
2024-02-07 01:22:34 +00:00
dynamic_layouts = " s h a 2 5 6 - e F p 1 Y V I 6 v I 2 H R g t E 5 n T q G Z I y l B 2 2 6 H 0 O 8 k u x y 9 y p u f 8 = " ;
2024-04-21 15:54:59 +00:00
flutter_gpu_texture_renderer = " s h a 2 5 6 - 0 z n I H l Z 0 a s h R T e v 2 k A X U 1 7 9 e q / V 1 R J C 9 H p 4 j A f i P h 5 Q = " ;
2024-02-07 01:22:34 +00:00
flutter_improved_scrolling = " s h a 2 5 6 - f K s 1 + J m h D V V f j y h r 6 F l 1 7 p c 6 n + + m C T j B o 1 P T 3 l / D U n c = " ;
window_manager = " s h a 2 5 6 - C U T c S l + W 7 W z / O g 5 k 9 u j O d A l h K W v / g I Y e 5 8 w u r f 9 C J H 4 = " ;
window_size = " s h a 2 5 6 - + l q Y 4 6 Z U R T 0 q c q P v H F X U n d 8 3 U v f q 7 9 X r + r w 1 A H q r p a k = " ;
} ;
# Configure the Rust build
cargoRoot = " . . " ;
cargoDeps = rustPlatform . importCargoLock {
2024-07-01 15:47:52 +00:00
# Upstream lock file after removing the registry variant of core-foundation-sys
# and fixing the resulting errors by removing the other registry deps.
2024-02-07 01:22:34 +00:00
lockFile = ./Cargo.lock ;
outputHashes = {
2024-09-26 11:04:55 +00:00
" a n d r o i d - w a k e l o c k - 0 . 1 . 0 " = " s h a 2 5 6 - 0 9 E H / U 1 B B s 3 l 4 g a l Q O r T K m P U Y B g r y U j f c / r q P Z h d Y c 4 = " ;
" a r b o a r d - 3 . 4 . 0 " = " s h a 2 5 6 - x u M f M a k H V j / z j i U r 6 P V F y + a N Q x w s X t A A F l T Y x U t 1 2 f U = " ;
" c a c a o - 0 . 4 . 0 - b e t a 2 " = " s h a 2 5 6 - U 5 t C L e V x j m Z C m 7 t i 1 u 7 1 + i 1 1 6 x m o z P a R 6 9 p C s A 4 p x r M = " ;
" c l i p b o a r d - m a s t e r - 4 . 0 . 0 - b e t a . 6 " = " s h a 2 5 6 - G Z y z G M Q O Z 0 i w G N Z a / Z z F p 8 g U 2 t Q V W Z B p A b i m 8 y b 6 y Z A = " ;
" c o n f y - 0 . 4 . 0 - 2 " = " s h a 2 5 6 - V 7 B C K I S r k J I x W C 3 W T 5 + B 5 V a v 8 6 Y T Q v d O 9 T O 6 A + + 4 7 F U = " ;
" c o r e - f o u n d a t i o n - 0 . 9 . 3 " = " s h a 2 5 6 - i B 4 O V m W Z h u W b s 9 R F W v N c + R N u t 6 r i p 2 / 5 0 o 5 Z M 6 c 0 c 3 g = " ;
" e v d e v - 0 . 1 1 . 5 " = " s h a 2 5 6 - a o P m j G i / P f t n H 6 C l E W X H v I j 0 X 3 o h 1 5 Z C 1 q 7 w P C 1 X P r 0 = " ;
" h w c o d e c - 0 . 7 . 0 " = " s h a 2 5 6 - S s w Z I 2 B J 4 p R X T 3 7 9 c z i J l i s P s c 5 s O i O i D q J 5 W a P E T n A = " ;
" i m p e r s o n a t e _ s y s t e m - 0 . 1 . 0 " = " s h a 2 5 6 - p I V 7 s 2 q G o C I U r h a R o v B D C J a G Q / p M d J a c D X J m e B p k c y I = " ;
" k e e p a w a k e - 0 . 4 . 3 " = " s h a 2 5 6 - c q S p k q / P C z + 5 + Z U y P y 5 h F 6 r P 3 f B z u Z D y w y x M U Q 5 0 R k 4 = " ;
" m a c h i n e - u i d - 0 . 3 . 0 " = " s h a 2 5 6 - r E O y N T h g 6 p 5 o q E 9 U R n x S k P t z y W 8 D 4 z K z L i 9 p A n z T E l E = " ;
" m a g n u m - o p u s - 0 . 4 . 0 " = " s h a 2 5 6 - T 4 q a Y O l 8 l C K 1 h 9 j W a 9 K q G v n V f D V i T 9 O b 5 R + Y g n S w 2 t g = " ;
" p a m - 0 . 7 . 0 " = " s h a 2 5 6 - o 4 7 t V o F l W 9 R i L 7 O 8 L v u w z 7 r M Y Q H O + 5 T G 2 7 X x k A d H E O E = " ;
" p a m - s y s - 1 . 0 . 0 - a l p h a 4 " = " s h a 2 5 6 - 5 H I E r V W n a n L o 5 0 5 4 N g U + D E K C 2 w w y i J 8 A H v b x 0 B G b y W o = " ;
" p a r i t y - t o k i o - i p c - 0 . 7 . 3 - 4 " = " s h a 2 5 6 - P K w 2 T w d 2 a p + t R r Q x q g 8 T 1 F v p o e K n 0 h v B q n 1 Z 4 4 F 1 L c Y = " ;
" r d e v - 0 . 5 . 0 - 2 " = " s h a 2 5 6 - G + P v n A 5 m Z y N 0 8 0 u o I 5 C G j / d Q 9 B 1 J 4 h 5 i Y d 7 2 1 4 M K B R 8 = " ;
" r e q w e s t - 0 . 1 1 . 2 3 " = " s h a 2 5 6 - k E U T + g s 4 z i k n D i G d P M L n j 5 p m x C 5 S B p L o p Z 8 j Z 3 4 G D W c = " ;
" r u s t - p u l s e c t l - 0 . 2 . 1 2 " = " s h a 2 5 6 - 8 j X T s p W v j O N F c v w 9 / Z 8 C 4 3 g 4 B u G Z 3 r s G 3 2 t v L M Q b t b M = " ;
" s c i t e r - r s - 0 . 5 . 5 7 " = " s h a 2 5 6 - 5 N d 9 n p d x 8 y Q J E c z H v 7 W m S m r E 1 l B f v p 5 z 7 B u b T b Y B g 3 E = " ;
" s y s i n f o - 0 . 2 9 . 1 0 " = " s h a 2 5 6 - / U s F A v l W s / F 7 X 1 x T + 9 7 F x + p n p C g u o P H U 3 h T y n q Y M E s 4 = " ;
" t a o - 0 . 2 5 . 0 " = " s h a 2 5 6 - k L m x 1 z 9 Y b n / h D t 2 O c s z E j t Z y t Q I E + N K T I n 9 z N r 9 o E Q k = " ;
" t f c - 0 . 7 . 0 " = " s h a 2 5 6 - 4 p l K 8 t t b H s B P a t 3 / r S + 4 R h G z i r q 2 K e d 2 w r U 8 c Q E U 1 z o = " ;
" t o k i o - s o c k s - 0 . 5 . 2 - 1 " = " s h a 2 5 6 - i 1 d f N a t q N 4 d i n M c y A d L h j 9 h J W V s T 1 0 O W p C X s x l 7 p i f I = " ;
" t r a y - i c o n - 0 . 1 4 . 3 " = " s h a 2 5 6 - d S X 7 L u c Z a L p l R r h 6 z L w m F z y Z N 4 Z t w I X z A E d Z z l u 3 g Q g = " ;
" w a l l p a p e r - 3 . 2 . 0 " = " s h a 2 5 6 - p 9 N R m u s d A 0 w v F 6 o n p 1 U T L 0 / 4 t 7 X n E A c 1 9 s q y G D n f g / Q = " ;
" w e b m - 1 . 1 . 0 " = " s h a 2 5 6 - p 4 B M e j 7 y v b 8 c / d J y n R W Z m w o 2 h x A A Y 9 6 Q x 6 Q x 2 D b T 8 h E = " ;
" x 1 1 - 2 . 1 9 . 0 " = " s h a 2 5 6 - G D C e K z U t v a L e B D m P Q d y r 4 9 9 E j E f T 6 y 4 d i B M z Z V E p t z c = " ;
" x 1 1 - c l i p b o a r d - 0 . 8 . 1 " = " s h a 2 5 6 - P t q m S D 2 M w k b L V W b f T S X Z W 3 W E v E n U l o 0 4 q i e U T j N 2 w h E = " ;
2024-02-07 01:22:34 +00:00
} ;
} ;
dontCargoBuild = true ;
cargoBuildFlags = " - - l i b " ;
cargoBuildType = " r e l e a s e " ;
cargoBuildFeatures = [
" f l u t t e r "
2024-07-01 15:47:52 +00:00
" h w c o d e c "
" l i n u x - p k g - c o n f i g "
2024-02-07 01:22:34 +00:00
] ;
nativeBuildInputs = [
# flutter_rust_bridge_codegen
cargo
copyDesktopItems
rustfmt
# Rust
rustPlatform . cargoSetupHook
rustPlatform . cargoBuildHook
rustPlatform . bindgenHook
] ;
buildInputs = [
2024-09-19 14:19:46 +00:00
ffmpeg
2024-07-27 06:49:29 +00:00
fuse3
2024-02-07 01:22:34 +00:00
gst_all_1 . gst-plugins-base
gst_all_1 . gstreamer
libXtst
libaom
libopus
libpulseaudio
libva
libvdpau
libvpx
libxkbcommon
libyuv
2024-07-01 15:47:52 +00:00
pam
2024-02-07 01:22:34 +00:00
xdotool
] ;
2024-02-29 20:09:43 +00:00
prePatch = ''
2024-02-07 01:22:34 +00:00
chmod - R + w . .
2024-02-29 20:09:43 +00:00
'' ;
2024-09-26 11:04:55 +00:00
patchFlags = [
" - p 1 "
" - d "
" . . "
] ;
2024-02-29 20:09:43 +00:00
2024-09-19 14:19:46 +00:00
patches = [ ./make-build-reproducible.patch ] ;
2024-02-29 20:09:43 +00:00
postPatch = ''
2024-09-26 11:04:55 +00:00
substituteInPlace $ cargoDepsCopy/libappindicator-sys- * /src/lib.rs \
- - replace-fail " l i b a y a t a n a - a p p i n d i c a t o r 3 . s o . 1 " " ${ lib . getLib libayatana-appindicator } / l i b / l i b a y a t a n a - a p p i n d i c a t o r 3 . s o . 1 "
2024-09-19 14:19:46 +00:00
substituteInPlace ../Cargo.toml - - replace-fail " , \" s t a t i c l i b \" , \" r l i b \" " " "
2024-02-07 01:22:34 +00:00
# The supplied Cargo.lock doesn't work with our fetcher so copy over the fixed version
cp $ { ./Cargo.lock } ../Cargo.lock
chmod + w ../Cargo.lock
'' ;
preBuild = ''
2024-09-26 11:04:55 +00:00
# Disable static linking of ffmpeg since https://github.com/21pages/hwcodec/commit/1873c34e3da070a462540f61c0b782b7ab15dc84
2024-09-19 14:19:46 +00:00
sed - i ' s/static = // g' /build/cargo-vendor-dir/hwcodec- * /build.rs
2024-02-07 01:22:34 +00:00
# Build the Flutter/Rust bridge bindings
cat < < EOF > bridge . yml
rust_input :
- " . . / s r c / f l u t t e r _ f f i . r s "
dart_output :
- " . / l i b / g e n e r a t e d _ b r i d g e . d a r t "
llvm_path :
2024-02-29 20:09:43 +00:00
- " ${ lib . getLib clangStdenv . cc . cc } "
2024-02-07 01:22:34 +00:00
dart_format_line_length : 80
2024-02-29 20:09:43 +00:00
llvm_compiler_opts : " - I ${ lib . getLib clangStdenv . cc . cc } / l i b / c l a n g / ${ lib . versions . major clangStdenv . cc . version } / i n c l u d e - I ${ clangStdenv . cc . libc_dev } / i n c l u d e "
2024-02-07 01:22:34 +00:00
EOF
RUST_LOG = info $ { flutterRustBridge } /bin/flutter_rust_bridge_codegen bridge . yml
# Build the Rust shared library
cd . .
preBuild = ( ) # prevent loops
2024-02-29 20:09:43 +00:00
cargoBuildHook
mv ./target /* / r e l e a s e / l i b l i b r u s t d e s k $ { s h a r e d L i b r a r y E x t } . / t a r g e t / r e l e a s e / l i b l i b r u s t d e s k $ { s h a r e d L i b r a r y E x t }
2024-02-07 01:22:34 +00:00
cd flutter
'' ;
postInstall = ''
mkdir - p $ out/share/polkit-1/actions $ out/share/icons/hicolor / { 2 5 6 x256 , scalable } /apps
cp ../res/128x128 @ 2 x . png $ out/share/icons/hicolor/256x256/apps/rustdesk.png
cp ../res/scalable.svg $ out/share/icons/hicolor/scalable/apps/rustdesk.svg
'' ;
desktopItems = [
( makeDesktopItem {
name = " r u s t d e s k " ;
desktopName = " R u s t D e s k " ;
genericName = " R e m o t e D e s k t o p " ;
2024-02-29 20:09:43 +00:00
comment = " R e m o t e D e s k t o p " ;
exec = " r u s t d e s k % u " ;
2024-02-07 01:22:34 +00:00
icon = " r u s t d e s k " ;
terminal = false ;
type = " A p p l i c a t i o n " ;
startupNotify = true ;
2024-09-26 11:04:55 +00:00
categories = [
" N e t w o r k "
" R e m o t e A c c e s s "
" G T K "
] ;
2024-02-07 01:22:34 +00:00
keywords = [ " i n t e r n e t " ] ;
actions . new-window = {
name = " O p e n a N e w W i n d o w " ;
2024-02-29 20:09:43 +00:00
exec = " r u s t d e s k % u " ;
2024-02-07 01:22:34 +00:00
} ;
} )
( makeDesktopItem {
name = " r u s t d e s k - l i n k " ;
desktopName = " R u s t D e s k U R L S c h e m e H a n d l e r " ;
noDisplay = true ;
mimeTypes = [ " x - s c h e m e - h a n d l e r / r u s t d e s k " ] ;
tryExec = " r u s t d e s k " ;
2024-02-29 20:09:43 +00:00
exec = " r u s t d e s k % u " ;
2024-02-07 01:22:34 +00:00
icon = " r u s t d e s k " ;
terminal = false ;
type = " A p p l i c a t i o n " ;
startupNotify = false ;
} )
] ;
meta = with lib ; {
description = " V i r t u a l / r e m o t e d e s k t o p i n f r a s t r u c t u r e f o r e v e r y o n e ! O p e n s o u r c e T e a m V i e w e r / C i t r i x a l t e r n a t i v e " ;
homepage = " h t t p s : / / r u s t d e s k . c o m " ;
license = licenses . agpl3Only ;
maintainers = with maintainers ; [ das_j ] ;
mainProgram = " r u s t d e s k " ;
platforms = platforms . linux ; # should work on darwin as well but I have no machine to test with
} ;
}