ocamlPackages.hxd: 0.3.2 -> 0.3.3 (#364231)
[NixPkgs.git] / pkgs / by-name / to / todesk / package.nix
blob7891ca6e656e8720c030bfb8122186e52b4a52e1
2   stdenv,
3   lib,
4   procps,
5   fetchurl,
6   dpkg,
7   writeShellScript,
8   buildFHSEnv,
9   nspr,
10   kmod,
11   systemdMinimal,
12   glib,
13   pulseaudio,
14   libXext,
15   libX11,
16   libXrandr,
17   glibc,
18   cairo,
19   libva,
20   libdrm,
21   coreutils,
22   libXi,
23   libGL,
24   bash,
25   libXcomposite,
26   libXdamage,
27   libXfixes,
28   libXtst,
29   nss,
30   libXxf86vm,
31   gtk3,
32   gdk-pixbuf,
33   pango,
34   libz,
35   libayatana-appindicator,
38 let
39   version = "4.7.2.0";
40   todesk-unwrapped = stdenv.mkDerivation (finalAttrs: {
41     pname = "todesk-unwrapped";
42     version = version;
43     src = fetchurl {
44       url = "https://newdl.todesk.com/linux/todesk-v${finalAttrs.version}-amd64.deb";
45       hash = "sha256-v7VpXXFVaKI99RpzUWfAc6eE7NHGJeFrNeUTbVuX+yg=";
46       curlOptsList = [
47         "--user-agent"
48         "Mozilla/5.0"
49       ];
50     };
51     nativeBuildInputs = [ dpkg ];
53     unpackPhase = ''
54       runHook preUnpack
55       dpkg -x $src ./todesk-src
56       runHook postUnpack
57     '';
59     installPhase = ''
60       runHook preInstall
61       mkdir -p "$out/lib"
62       cp -r todesk-src/* "$out"
63       cp "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" "$out/opt/todesk/bin/libappindicator3.so.1"
64       mv "$out/opt/todesk/bin" "$out/bin"
65       cp "$out/bin/libmfx.so.1" "$out/lib"
66       cp "$out/bin/libglut.so.3" "$out/lib"
67       mkdir "$out/opt/todesk/config"
68       mkdir "$out/opt/todesk/bin"
69       mkdir -p "$out/share/applications"
70       mkdir "$out/share/icons"
71       runHook postInstall
72     '';
74   });
77 buildFHSEnv {
78   inherit version;
79   pname = "todesk";
80   targetPkgs = pkgs: [
81     todesk-unwrapped
82     pulseaudio
83     nspr
84     kmod
85     libXi
86     systemdMinimal
87     glib
88     libz
89     bash
90     coreutils
91     libX11
92     libXext
93     libXrandr
94     glibc
95     libdrm
96     libGL
97     procps
98     cairo
99     libXcomposite
100     libXdamage
101     libXfixes
102     libXtst
103     nss
104     libXxf86vm
105     gtk3
106     gdk-pixbuf
107     pango
108     libva
109   ];
110   extraBwrapArgs = [
111     "--bind /var/lib/todesk /opt/todesk/config" # create the folder before bind to avoid permission denided.
112     "--bind ${todesk-unwrapped}/bin /opt/todesk/bin"
113     "--bind /var/lib/todesk /etc/todesk" # service write uuid here. Such a pain!
114   ]; # soft link doesn't work so that we should bind ourselves
115   runScript = writeShellScript "ToDesk.sh" ''
116     export LIBVA_DRIVER_NAME=iHD
117     export LIBVA_DRIVERS_PATH=${todesk-unwrapped}/bin
118     if [ "''${1}" = 'service' ]
119     then
120         /opt/todesk/bin/ToDesk_Service
121     else
122         /opt/todesk/bin/ToDesk
123     fi
124   ''; # a small script to choose what to exec
125   extraInstallCommands = ''
126     mkdir -p "$out/share/applications"
127     mkdir -p "$out/share/icons"
128     cp ${todesk-unwrapped}/usr/share/applications/todesk.desktop $out/share/applications
129     cp -rf ${todesk-unwrapped}/usr/share/icons/* $out/share/icons
130     substituteInPlace "$out/share/applications/todesk.desktop" \
131       --replace-fail '/opt/todesk/bin/ToDesk' "$out/bin/todesk desktop"
132     substituteInPlace "$out/share/applications/todesk.desktop" \
133       --replace-fail '/opt/todesk/bin' "${todesk-unwrapped}/lib"
134   '';
135   meta = {
136     description = "Remote Desktop Application";
137     homepage = "https://www.todesk.com/linux.html";
138     license = lib.licenses.unfree;
139     platforms = [ "x86_64-linux" ];
140     sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
141     maintainers = with lib.maintainers; [ bot-wxt1221 ];
142     mainProgram = "todesk";
143   };