1{
2 stdenv,
3 lib,
4 fetchzip,
5 alsa-lib,
6 autoPatchelfHook,
7 copyDesktopItems,
8 dbus-glib,
9 # ffmpeg 7 not supported yet, results in MP4 playback being unavailable
10 # https://repo.palemoon.org/MoonchildProductions/UXP/issues/2523
11 ffmpeg_6,
12 gtk2-x11,
13 withGTK3 ? true,
14 gtk3,
15 libglvnd,
16 libXt,
17 libpulseaudio,
18 makeDesktopItem,
19 wrapGAppsHook3,
20 writeScript,
21 testers,
22}:
23
24stdenv.mkDerivation (finalAttrs: {
25 pname = "palemoon-bin";
26 version = "33.8.0";
27
28 src = finalAttrs.passthru.sources."gtk${if withGTK3 then "3" else "2"}";
29
30 preferLocalBuild = true;
31
32 strictDeps = true;
33
34 nativeBuildInputs = [
35 autoPatchelfHook
36 copyDesktopItems
37 wrapGAppsHook3
38 ];
39
40 buildInputs = [
41 alsa-lib
42 dbus-glib
43 gtk2-x11
44 libXt
45 (lib.getLib stdenv.cc.cc)
46 ]
47 ++ lib.optionals withGTK3 [
48 gtk3
49 ];
50
51 desktopItems = [
52 (makeDesktopItem {
53 name = "palemoon-bin";
54 desktopName = "Pale Moon Web Browser";
55 comment = "Browse the World Wide Web";
56 keywords = [
57 "Internet"
58 "WWW"
59 "Browser"
60 "Web"
61 "Explorer"
62 ];
63 exec = "palemoon %u";
64 terminal = false;
65 type = "Application";
66 icon = "palemoon";
67 categories = [
68 "Network"
69 "WebBrowser"
70 ];
71 mimeTypes = [
72 "text/html"
73 "text/xml"
74 "application/xhtml+xml"
75 "application/xml"
76 "application/rss+xml"
77 "application/rdf+xml"
78 "image/gif"
79 "image/jpeg"
80 "image/png"
81 "x-scheme-handler/http"
82 "x-scheme-handler/https"
83 "x-scheme-handler/ftp"
84 "x-scheme-handler/chrome"
85 "video/webm"
86 "application/x-xpinstall"
87 ];
88 startupNotify = true;
89 startupWMClass = "Pale moon";
90 extraConfig = {
91 X-MultipleArgs = "false";
92 };
93 actions = {
94 "NewTab" = {
95 name = "Open new tab";
96 exec = "palemoon -new-tab https://start.palemoon.org";
97 };
98 "NewWindow" = {
99 name = "Open new window";
100 exec = "palemoon -new-window";
101 };
102 "NewPrivateWindow" = {
103 name = "Open new private window";
104 exec = "palemoon -private-window";
105 };
106 "ProfileManager" = {
107 name = "Open the Profile Manager";
108 exec = "palemoon --ProfileManager";
109 };
110 };
111 })
112 ];
113
114 dontConfigure = true;
115 dontBuild = true;
116
117 installPhase = ''
118 runHook preInstall
119
120 mkdir -p $out/{bin,lib/palemoon}
121 cp -R * $out/lib/palemoon/
122
123 ln -s $out/{lib/palemoon,bin}/palemoon
124
125 for iconpath in chrome/icons/default/default{16,32,48} icons/mozicon128; do
126 n=''${iconpath//[^0-9]/}
127 size=$n"x"$n
128 mkdir -p $out/share/icons/hicolor/$size/apps
129 ln -s $out/lib/palemoon/browser/"$iconpath".png $out/share/icons/hicolor/$size/apps/palemoon.png
130 done
131
132 # Disable built-in updater
133 # https://forum.palemoon.org/viewtopic.php?f=5&t=25073&p=197771#p197747
134 # > Please do not take this as permission to change, remove, or alter any other preferences as that is forbidden
135 # > without express permission according to the Pale Moon Redistribution License.
136 # > We are allowing this one and **ONLY** one exception in order to properly facilitate [package manager] repacks.
137 install -Dm644 ${./zz-disableUpdater.js} $out/lib/palemoon/browser/defaults/preferences/zz-disableUpdates.js
138
139 runHook postInstall
140 '';
141
142 dontWrapGApps = true;
143
144 preFixup = ''
145 # Make optional dependencies available
146 gappsWrapperArgs+=(
147 --prefix LD_LIBRARY_PATH : "${
148 lib.makeLibraryPath [
149 ffmpeg_6
150 libglvnd
151 libpulseaudio
152 ]
153 }"
154 )
155 wrapGApp $out/lib/palemoon/palemoon
156 '';
157
158 passthru = {
159 sources =
160 let
161 urlRegionVariants =
162 buildVariant:
163 map
164 (
165 region:
166 "https://rm-${region}.palemoon.org/release/palemoon-${finalAttrs.version}.linux-x86_64-${buildVariant}.tar.xz"
167 )
168 [
169 "eu"
170 "us"
171 ];
172 in
173 {
174 gtk3 = fetchzip {
175 urls = urlRegionVariants "gtk3";
176 hash = "sha256-cdPFMYlVEr6D+0mH7Mg5nGpf0KvePGLm3Y/ZytdFHHA=";
177 };
178 gtk2 = fetchzip {
179 urls = urlRegionVariants "gtk2";
180 hash = "sha256-dgWKmkHl5B1ri3uev63MNz/+E767ip9wJ/YzSog8vdQ=";
181 };
182 };
183
184 tests.version = testers.testVersion {
185 package = finalAttrs.finalPackage;
186 };
187
188 updateScript = writeScript "update-palemoon-bin" ''
189 #!/usr/bin/env nix-shell
190 #!nix-shell -i bash -p common-updater-scripts curl libxml2
191
192 set -eu -o pipefail
193
194 # Only release note announcement == finalized release
195 version="$(
196 curl -s 'http://www.palemoon.org/releasenotes.shtml' |
197 xmllint --html --xpath 'html/body/table/tbody/tr/td/h3/text()' - 2>/dev/null | head -n1 |
198 sed 's/v\(\S*\).*/\1/'
199 )"
200
201 for variant in gtk3 gtk2; do
202 update-source-version palemoon-bin "$version" --ignore-same-version --source-key="sources.$variant"
203 done
204 '';
205 };
206
207 meta = with lib; {
208 homepage = "https://www.palemoon.org/";
209 description = "Open Source, Goanna-based web browser focusing on efficiency and customization";
210 longDescription = ''
211 Pale Moon is an Open Source, Goanna-based web browser focusing on
212 efficiency and customization.
213
214 Pale Moon offers you a browsing experience in a browser completely built
215 from its own, independently developed source that has been forked off from
216 Firefox/Mozilla code a number of years ago, with carefully selected
217 features and optimizations to improve the browser's stability and user
218 experience, while offering full customization and a growing collection of
219 extensions and themes to make the browser truly your own.
220 '';
221 changelog = "https://repo.palemoon.org/MoonchildProductions/Pale-Moon/releases/tag/${finalAttrs.version}_Release";
222 license = [
223 licenses.mpl20
224 {
225 fullName = "Pale Moon Redistribution License";
226 url = "https://www.palemoon.org/redist.shtml";
227 # TODO free, redistributable? Has strict limitations on what modifications may be done & shipped by packagers
228 }
229 ];
230 maintainers = with maintainers; [ OPNA2608 ];
231 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
232 mainProgram = "palemoon";
233 platforms = [ "x86_64-linux" ];
234 hydraPlatforms = [ ];
235 };
236})