summary refs log tree commit diff
path: root/pkgs/applications/networking/remote/teamviewer/default.nix
blob: 55a5beb5093f98e10906b5c70c6556827583ab3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{ stdenv, fetchurl, libX11, libXtst, libXext, libXdamage, libXfixes, wine, makeWrapper
, bash, findutils, coreutils }:

assert stdenv.system == "i686-linux";
let
  topath = "${wine}/bin";

  toldpath = stdenv.lib.concatStringsSep ":" (map (x: "${x}/lib") 
    [ stdenv.cc.cc libX11 libXtst libXext libXdamage libXfixes wine ]);
in
stdenv.mkDerivation {
  name = "teamviewer-7.0.9377";
  src = fetchurl {
    url = "http://download.teamviewer.com/download/version_7x/teamviewer_linux.tar.gz";
    sha256 = "1f8934jqj093m1z56yl6k2ah6njkk6pz1rjvpqnryi29pp5piaiy";
  };

  buildInputs = [ makeWrapper ];

  # I need patching, mainly for it not try to use its own 'wine' (in the tarball).
  installPhase = ''
    mkdir -p $out/share/teamviewer $out/bin
    cp -a .tvscript/* $out/share/teamviewer
    cp -a .wine/drive_c $out/share/teamviewer
    sed -i -e 's/^tv_Run//' \
      -e 's/^  setup_tar_env//' \
      -e 's/^  setup_env//' \
      -e 's,^  TV_Wine_dir=.*,  TV_Wine_dir=${wine},' \
      -e 's,progsrc=.*drive_c,progsrc='$out'"/share/teamviewer/drive_c,' \
      $out/share/teamviewer/wrapper

    cat > $out/bin/teamviewer << EOF
    #!${bash}/bin/sh
    # Teamviewer puts symlinks to nix store paths in ~/.teamviewer. When those
    # paths become garbage collected, teamviewer crashes upon start because of
    # those broken symlinks. An easy workaround to this behaviour is simply to
    # delete all symlinks before we start teamviewer. Teamviewer will fixup the
    # symlinks, just like it did the first time the user ran it.
    ${findutils}/bin/find "\$HOME"/.teamviewer/*/*/"Program Files/TeamViewer/" -type l -print0 | ${findutils}/bin/xargs -0 ${coreutils}/bin/rm

    export LD_LIBRARY_PATH=${toldpath}\''${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}
    export PATH=${topath}\''${PATH:+:\$PATH}
    $out/share/teamviewer/wrapper wine "c:\Program Files\TeamViewer\Version7\TeamViewer.exe" "\$@"
    EOF
    chmod +x $out/bin/teamviewer
  '';

  meta = {
    homepage = "http://www.teamviewer.com";
    license = stdenv.lib.licenses.unfree;
    description = "Desktop sharing application, providing remote support and online meetings";
  };
}