teamviewer: refactor executable wrapping

This centralizes `PATH` and `LD_LIBRARY_PATH`, avoid multiple
layers of wrappers.

Refactor as suggested by @Artturin in PR provided patch:
<https://github.com/NixOS/nixpkgs/pull/140076#issuecomment-934770391>.
This commit is contained in:
Raymond Gauthier 2021-10-12 10:35:35 -04:00
parent db889eb913
commit c55bc5bfd3
No known key found for this signature in database
GPG key ID: 88FBFBAC9B57497A

View file

@ -72,19 +72,19 @@ mkDerivation rec {
--replace '/lib64/ld-linux-x86-64.so.2' '${glibc.out}/lib/ld-linux-x86-64.so.2'
substituteInPlace $out/share/teamviewer/tv_bin/script/tvw_config \
--replace '/var/run/' '/run/'
'';
wrapProgram $out/share/teamviewer/tv_bin/script/teamviewer \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libXrandr libX11 dbus ]}"
wrapProgram $out/share/teamviewer/tv_bin/teamviewerd \
--prefix PATH : "${lib.makeBinPath [ getconf ]}" \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libXrandr libX11 dbus ]}"
wrapProgram $out/share/teamviewer/tv_bin/TeamViewer \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libXrandr libX11 dbus ]}"
wrapProgram $out/share/teamviewer/tv_bin/TeamViewer_Desktop \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [libXrandr libX11 libXext libXdamage libXtst libSM libXfixes dbus ]}"
makeWrapperArgs = [
"--prefix PATH : ${lib.makeBinPath [ getconf ]}"
"--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libXrandr libX11 libXext libXdamage libXtst libSM libXfixes dbus ]}"
];
wrapQtApp $out/share/teamviewer/tv_bin/script/teamviewer
wrapQtApp $out/bin/teamviewer
postFixup = ''
wrapProgram $out/share/teamviewer/tv_bin/teamviewerd ''${makeWrapperArgs[@]}
# tv_bin/script/teamviewer runs tvw_main which runs tv_bin/TeamViewer
wrapProgram $out/share/teamviewer/tv_bin/script/teamviewer ''${makeWrapperArgs[@]} ''${qtWrapperArgs[@]}
wrapProgram $out/share/teamviewer/tv_bin/teamviewer-config ''${makeWrapperArgs[@]} ''${qtWrapperArgs[@]}
wrapProgram $out/share/teamviewer/tv_bin/TeamViewer_Desktop ''${makeWrapperArgs[@]} ''${qtWrapperArgs[@]}
'';
dontStrip = true;