Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 173 lines 5.5 kB view raw
1{ 2 mkDerivation, 3 lib, 4 stdenv, 5 fetchurl, 6 autoPatchelfHook, 7 makeWrapper, 8 xdg-utils, 9 dbus, 10 getconf, 11 glibc, 12 libXrandr, 13 libX11, 14 libXext, 15 libXdamage, 16 libXtst, 17 libSM, 18 libXfixes, 19 coreutils, 20 wrapQtAppsHook, 21 icu63, 22 nss, 23 minizip, 24}: 25 26mkDerivation rec { 27 pname = "teamviewer"; 28 # teamviewer itself has not development files but the dev output removes propagated other dev outputs from runtime 29 outputs = [ 30 "out" 31 "dev" 32 ]; 33 version = "15.67.4"; 34 35 src = 36 let 37 base_url = "https://dl.teamviewer.com/download/linux/version_${lib.versions.major version}x"; 38 in 39 { 40 x86_64-linux = fetchurl { 41 url = "${base_url}/teamviewer_${version}_amd64.deb"; 42 hash = "sha256-ibKRYgsvBmh18LfG29ve/yrDEFTdgsNZ3kJu8YkMbsw="; 43 }; 44 aarch64-linux = fetchurl { 45 url = "${base_url}/teamviewer_${version}_arm64.deb"; 46 hash = "sha256-MDNxqmu4dJA6dWKy8EFNOy2V253+UgsYwmZ3RidQqFE="; 47 }; 48 } 49 .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); 50 51 unpackPhase = '' 52 ar x $src 53 tar xf data.tar.* 54 ''; 55 56 nativeBuildInputs = [ 57 autoPatchelfHook 58 makeWrapper 59 wrapQtAppsHook 60 ]; 61 buildInputs = [ 62 minizip 63 icu63 64 nss 65 ]; 66 67 installPhase = '' 68 mkdir -p $out/share/teamviewer $out/bin $out/share/applications 69 cp -a opt/teamviewer/* $out/share/teamviewer 70 rm -R \ 71 $out/share/teamviewer/logfiles \ 72 $out/share/teamviewer/config \ 73 $out/share/teamviewer/tv_bin/script/{teamviewer_setup,teamviewerd.sysv,teamviewerd.service,teamviewerd.*.conf,tv-delayed-start.sh} 74 75 # Teamviewer packages its own qt library files. So do not use nixpkgs qt files. These will cause issues 76 # See https://github.com/NixOS/nixpkgs/issues/321333 77 78 ln -s $out/share/teamviewer/tv_bin/script/teamviewer $out/bin 79 ln -s $out/share/teamviewer/tv_bin/teamviewerd $out/bin 80 ln -s $out/share/teamviewer/tv_bin/desktop/com.teamviewer.*.desktop $out/share/applications 81 ln -s /var/lib/teamviewer $out/share/teamviewer/config 82 ln -s /var/log/teamviewer $out/share/teamviewer/logfiles 83 ln -s ${xdg-utils}/bin $out/share/teamviewer/tv_bin/xdg-utils 84 85 declare in_script_dir="./opt/teamviewer/tv_bin/script" 86 87 install -d "$out/share/dbus-1/services" 88 install -m 644 "$in_script_dir/com.teamviewer.TeamViewer.service" "$out/share/dbus-1/services" 89 substituteInPlace "$out/share/dbus-1/services/com.teamviewer.TeamViewer.service" \ 90 --replace-fail '/opt/teamviewer/tv_bin/TeamViewer' \ 91 "$out/share/teamviewer/tv_bin/TeamViewer" 92 install -m 644 "$in_script_dir/com.teamviewer.TeamViewer.Desktop.service" "$out/share/dbus-1/services" 93 substituteInPlace "$out/share/dbus-1/services/com.teamviewer.TeamViewer.Desktop.service" \ 94 --replace-fail '/opt/teamviewer/tv_bin/TeamViewer_Desktop' \ 95 "$out/share/teamviewer/tv_bin/TeamViewer_Desktop" 96 97 install -d "$out/share/dbus-1/system.d" 98 install -m 644 "$in_script_dir/com.teamviewer.TeamViewer.Daemon.conf" "$out/share/dbus-1/system.d" 99 100 install -d "$out/share/polkit-1/actions" 101 install -m 644 "$in_script_dir/com.teamviewer.TeamViewer.policy" "$out/share/polkit-1/actions" 102 substituteInPlace "$out/share/polkit-1/actions/com.teamviewer.TeamViewer.policy" \ 103 --replace '/opt/teamviewer/tv_bin/script/execscript' \ 104 "$out/share/teamviewer/tv_bin/script/execscript" 105 106 for i in 16 20 24 32 48 256; do 107 size=$i"x"$i 108 109 mkdir -p $out/share/icons/hicolor/$size/apps 110 ln -s $out/share/teamviewer/tv_bin/desktop/teamviewer_$i.png $out/share/icons/hicolor/$size/apps/TeamViewer.png 111 done; 112 113 sed -i "s,/opt/teamviewer,$out/share/teamviewer,g" $out/share/teamviewer/tv_bin/desktop/com.teamviewer.*.desktop 114 115 substituteInPlace $out/share/teamviewer/tv_bin/script/tvw_aux \ 116 --replace '/lib64/ld-linux-x86-64.so.2' '${glibc.out}/lib/ld-linux-x86-64.so.2' 117 substituteInPlace $out/share/teamviewer/tv_bin/script/tvw_config \ 118 --replace '/var/run/' '/run/' 119 ''; 120 121 makeWrapperArgs = [ 122 "--prefix PATH : ${ 123 lib.makeBinPath [ 124 getconf 125 coreutils 126 ] 127 }" 128 "--prefix LD_LIBRARY_PATH : ${ 129 lib.makeLibraryPath [ 130 libXrandr 131 libX11 132 libXext 133 libXdamage 134 libXtst 135 libSM 136 libXfixes 137 dbus 138 icu63 139 ] 140 }" 141 ]; 142 143 postFixup = '' 144 wrapProgram $out/share/teamviewer/tv_bin/teamviewerd ''${makeWrapperArgs[@]} 145 # tv_bin/script/teamviewer runs tvw_main which runs tv_bin/TeamViewer 146 wrapProgram $out/share/teamviewer/tv_bin/script/teamviewer ''${makeWrapperArgs[@]} ''${qtWrapperArgs[@]} 147 wrapProgram $out/share/teamviewer/tv_bin/teamviewer-config ''${makeWrapperArgs[@]} ''${qtWrapperArgs[@]} 148 wrapProgram $out/share/teamviewer/tv_bin/TeamViewer_Desktop ''${makeWrapperArgs[@]} ''${qtWrapperArgs[@]} 149 ''; 150 151 dontStrip = true; 152 dontWrapQtApps = true; 153 preferLocalBuild = true; 154 155 passthru.updateScript = ./update-teamviewer.sh; 156 157 meta = with lib; { 158 homepage = "https://www.teamviewer.com"; 159 sourceProvenance = with sourceTypes; [ binaryNativeCode ]; 160 license = licenses.unfree; 161 description = "Desktop sharing application, providing remote support and online meetings"; 162 platforms = [ 163 "x86_64-linux" 164 "aarch64-linux" 165 ]; 166 maintainers = with maintainers; [ 167 jagajaga 168 jraygauthier 169 gador 170 c4patino 171 ]; 172 }; 173}