summary refs log tree commit diff
path: root/pkgs/applications/networking/browsers/palemoon/default.nix
blob: 49dcfe0f9c48923932eb541f9286a0236e314b28 (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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
{ lib
, stdenv
, alsa-lib
, autoconf213
, cairo
, dbus
, dbus-glib
, desktop-file-utils
, fetchFromGitea
, ffmpeg
, fontconfig
, freetype
, gnome2
, gnum4
, libGL
, libGLU
, libevent
, libnotify
, libpulseaudio
, libstartup_notification
, pango
, perl
, pkg-config
, python2
, unzip
, which
, wrapGAppsHook
, writeScript
, xorg
, yasm
, zip
, zlib
, withGTK3 ? true, gtk3, gtk2
}:

# Only specific GCC versions are supported with branding
# https://developer.palemoon.org/build/linux/
assert stdenv.cc.isGNU;
assert with lib.strings; (
  versionAtLeast stdenv.cc.version "4.9"
  && !hasPrefix "6" stdenv.cc.version
  && versionOlder stdenv.cc.version "11"
);

stdenv.mkDerivation rec {
  pname = "palemoon";
  version = "30.0.0";

  src = fetchFromGitea {
    domain = "repo.palemoon.org";
    owner = "MoonchildProductions";
    repo = "Pale-Moon";
    rev = "${version}_Release";
    fetchSubmodules = true;
    sha256 = "02qdw8b7hphphc66m3m14r4pmcfiq2c5z4jcscm2nymy18ycb10f";
  };

  nativeBuildInputs = [
    autoconf213
    desktop-file-utils
    gnum4
    perl
    pkg-config
    python2
    unzip
    which
    wrapGAppsHook
    yasm
    zip
  ];

  buildInputs = [
    alsa-lib
    cairo
    dbus
    dbus-glib
    ffmpeg
    fontconfig
    freetype
    gnome2.GConf
    gtk2
    libGL
    libGLU
    libevent
    libnotify
    libpulseaudio
    libstartup_notification
    pango
    zlib
  ]
  ++ (with xorg; [
    libX11
    libXext
    libXft
    libXi
    libXrender
    libXScrnSaver
    libXt
    pixman
    xorgproto
  ])
  ++ lib.optionals withGTK3 [
    gtk3
  ];

  enableParallelBuilding = true;

  postPatch = ''
    patchShebangs ./mach
  '';

  configurePhase = ''
    runHook preConfigure

    export MOZCONFIG=$PWD/mozconfig
    export MOZ_NOSPAM=1

    export build64=${lib.optionalString stdenv.hostPlatform.is64bit "1"}
    export gtkversion=${if withGTK3 then "3" else "2"}
    export xlibs=${lib.makeLibraryPath [ xorg.libX11 ]}
    export prefix=$out
    export mozmakeflags="-j${if enableParallelBuilding then "$NIX_BUILD_CORES" else "1"}"
    export autoconf=${autoconf213}/bin/autoconf

    substituteAll ${./mozconfig} $MOZCONFIG

    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild

    ./mach build

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    ./mach install

    # Install official branding stuff (desktop file & icons)
    desktop-file-install --dir=$out/share/applications \
      ./other-licenses/branding/palemoon/official/palemoon.desktop
    for iconname in default{16,22,24,32,48,256} mozicon128; do
      n=''${iconname//[^0-9]/}
      size=$n"x"$n
      install -Dm644 ./other-licenses/branding/palemoon/official/$iconname.png $out/share/icons/hicolor/$size/apps/palemoon.png
    done

    runHook postInstall
  '';

  dontWrapGApps = true;

  preFixup =
    let
      libPath = lib.makeLibraryPath [
        ffmpeg
        libpulseaudio
      ];
    in
      ''
        gappsWrapperArgs+=(
          --prefix LD_LIBRARY_PATH : "${libPath}"
        )
    wrapGApp $out/lib/palemoon-${version}/palemoon
  '';

  meta = with lib; {
    homepage = "https://www.palemoon.org/";
    description = "An Open Source, Goanna-based web browser focusing on efficiency and customization";
    longDescription = ''
      Pale Moon is an Open Source, Goanna-based web browser focusing on
      efficiency and customization.

      Pale Moon offers you a browsing experience in a browser completely built
      from its own, independently developed source that has been forked off from
      Firefox/Mozilla code a number of years ago, with carefully selected
      features and optimizations to improve the browser's stability and user
      experience, while offering full customization and a growing collection of
      extensions and themes to make the browser truly your own.
    '';
    changelog = "https://repo.palemoon.org/MoonchildProductions/Pale-Moon/releases/tag/${version}_Release";
    license = licenses.mpl20;
    maintainers = with maintainers; [ AndersonTorres OPNA2608 ];
    platforms = [ "i686-linux" "x86_64-linux" ];
  };

  passthru.updateScript = writeScript "update-${pname}" ''
    #!/usr/bin/env nix-shell
    #!nix-shell -i bash -p common-updater-scripts curl libxml2

    set -eu -o pipefail

    # Only release note announcement == finalized release
    version="$(
      curl -s 'http://www.palemoon.org/releasenotes.shtml' |
      xmllint --html --xpath 'html/body/table/tbody/tr/td/h3/text()' - 2>/dev/null | head -n1 |
      sed 's/v\(\S*\).*/\1/'
    )"
    update-source-version ${pname} "$version"
  '';
}