summary refs log tree commit diff
path: root/pkgs/applications/misc/googleearth-pro/default.nix
blob: e7cfe04da6e848253acfdb7b13793281b6230e56 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
{ lib
, stdenv
, mkDerivation
, fetchurl
, ffmpeg_3
, freetype
, gdal_2
, glib
, libGL
, libGLU
, libICE
, libSM
, libXi
, libXv
, libav_12

, libXrender
, libXrandr
, libXfixes
, libXcursor
, libXinerama
, libXext
, libX11
, libXcomposite

, libxcb
, sqlite
, zlib
, fontconfig
, dpkg
, libproxy
, libxml2
, gst_all_1
, dbus
, makeWrapper

, qtlocation
, qtwebkit
, qtx11extras
, qtsensors
, qtscript

, xkeyboardconfig
, autoPatchelfHook
}:
let
  arch =
    if stdenv.hostPlatform.system == "x86_64-linux" then "amd64"
    else throw "Unsupported system ${stdenv.hostPlatform.system} ";
in
mkDerivation rec {
  pname = "googleearth-pro";
  version = "7.3.3.7786";

  src = fetchurl {
    url = "https://dl.google.com/linux/earth/deb/pool/main/g/google-earth-pro-stable/google-earth-pro-stable_${version}-r0_${arch}.deb";
    sha256 = "1s3cakwrgf702g33rh8qs657d8bl68wgg8k89rksgvswwpd2zbb3";
  };

  nativeBuildInputs = [ dpkg makeWrapper autoPatchelfHook ];
  propagatedBuildInputs = [ xkeyboardconfig ];
  buildInputs = [
    dbus
    ffmpeg_3
    fontconfig
    freetype
    gdal_2
    glib
    gst_all_1.gst-plugins-base
    gst_all_1.gstreamer
    libGL
    libGLU
    libICE
    libSM
    libX11
    libXcomposite
    libXcursor
    libXext
    libXfixes
    libXi
    libXinerama
    libXrandr
    libXrender
    libXv
    libav_12
    libproxy
    libxcb
    libxml2
    qtlocation
    qtscript
    qtsensors
    qtwebkit
    qtx11extras
    sqlite
    zlib
  ];

  doInstallCheck = true;

  dontBuild = true;

  unpackPhase = ''
    # deb file contains a setuid binary, so 'dpkg -x' doesn't work here
    dpkg --fsys-tarfile ${src} | tar --extract
  '';

  installPhase =''
    runHook preInstall

    mkdir $out
    mv usr/* $out/
    rmdir usr
    mv * $out/
    rm $out/bin/google-earth-pro $out/opt/google/earth/pro/googleearth

    # patch and link googleearth binary
    ln -s $out/opt/google/earth/pro/googleearth-bin $out/bin/googleearth-pro

    # patch and link gpsbabel binary
    ln -s $out/opt/google/earth/pro/gpsbabel $out/bin/gpsbabel

    # Add desktop config file and icons
    mkdir -p $out/share/{applications,icons/hicolor/{16x16,22x22,24x24,32x32,48x48,64x64,128x128,256x256}/apps,pixmaps}
    ln -s $out/opt/google/earth/pro/google-earth-pro.desktop $out/share/applications/google-earth-pro.desktop
    sed -i -e "s|Exec=.*|Exec=$out/bin/googleearth-pro|g" $out/opt/google/earth/pro/google-earth-pro.desktop
    for size in 16 22 24 32 48 64 128 256; do
      ln -s $out/opt/google/earth/pro/product_logo_"$size".png $out/share/icons/hicolor/"$size"x"$size"/apps/google-earth-pro.png
    done
    ln -s $out/opt/google/earth/pro/product_logo_256.png $out/share/pixmaps/google-earth-pro.png

    runHook postInstall
  '';

  postInstall = ''
    find "$out/opt/google/earth/pro" -name "*.so.*" | \
      egrep -v 'libssl*|libcrypto*|libicu*' | \
      xargs rm
    find "$out/opt/google/earth/pro" -name "*.so" | \
      egrep -v 'libgoogle*|libauth*|libbase*|libcommon*|libcommon_gui*|libcommon_platform*|libcommon_webbrowser*|libcomponentframework*|libgeobase*|libgeobaseutils*|libge_net*|libgdata*|libgoogleapi*|libmath*|libmoduleframework*|libmaps*|libport*|libprintmodule*|libprofile*|librender*|libreporting*|libsgutil*|libspatial*|libxsltransform*|libbase*|libport*|libport*|libbase*|libcomponentframework*|libIGCore*|libIGUtils*|libaction*|libapiloader*|libapiloader*|libIGCore*|libIGUtils*|libIGMath*|libfusioncommon*|libge_exif*|libaction*|libfusioncommon*|libapiloader*|liblayer*|libapiloader*|libIGAttrs*|libIGCore*|libIGGfx*|libIGMath*|libIGSg*|libIGUtils*|libwmsbase*|libwebbrowser*|libevllpro*|libalchemyext*|libge_cache*|libflightsim*|libnpgeinprocessplugin*|libmeasure*|libviewsync*|libcapture*|libtheme*|libgps*|libgisingest*|libsearchmodule*|libinput_plugin*|libnavigate*|libspnav*|libsearch*|libLeap*' | \
      xargs rm
  '';

  autoPatchelfIgnoreMissingDeps=true;

  installCheckPhase = ''
    $out/bin/gpsbabel -V > /dev/null
  '';

  # wayland is not supported by Qt included in binary package, so make sure it uses xcb
  postFixup = ''
    wrapProgram $out/bin/googleearth-pro \
      --set QT_QPA_PLATFORM xcb \
      --set QT_XKB_CONFIG_ROOT "${xkeyboardconfig}/share/X11/xkb"
  '';

  meta = with lib; {
    description = "A world sphere viewer";
    homepage = "https://www.google.com/earth/";
    license = licenses.unfree;
    maintainers = with maintainers; [ friedelino shamilton ];
    platforms = platforms.linux;
  };
}