git.iko.soy/typeable/nixpkgs
on master help sign in
firefox: refactor into firefoxPackages, add more options
commitf0f572ff4635ff58e2ebbccf1b60617911308b16 authorJan Malakhovski <oxij@oxij.org> dateMon 27 Mar 2017, 12:33 (10 years ago) parent1d40717
3 files changed+195−156
pkgs/applications/networking/browsers/firefox/common.nix+141−149 pkgs/applications/networking/browsers/firefox/packages.nix+43 pkgs/top-level/all-packages.nix+11−7
pkgs/applications/networking/browsers/firefox/common.nix+141−149
@@ -1,175 +1,167 @@
1−{ lib, stdenv, fetchurl, pkgconfig, gtk2, pango, perl, python, zip, libIDL
1+{ pname, version, updateScript ? null
2+, src, patches ? [], meta }:
3+
4+{ lib, stdenv, pkgconfig, pango, perl, python, zip, libIDL
25, libjpeg, zlib, dbus, dbus_glib, bzip2, xorg
3−, freetype, fontconfig, file, alsaLib, nspr, nss, libnotify
6+, freetype, fontconfig, file, nspr, nss, libnotify
47, yasm, mesa, sqlite, unzip, makeWrapper
58, hunspell, libevent, libstartup_notification, libvpx
6−, cairo, gstreamer, gst-plugins-base, icu, libpng, jemalloc, libpulseaudio
7−, autoconf213, which, cargo, rustc
8−, writeScript, xidel, common-updater-scripts, coreutils, gnused, gnugrep, curl
9−, enableGTK3 ? false, gtk3, wrapGAppsHook
9+, cairo, icu, libpng, jemalloc
10+, autoconf213, which, gnused, cargo, rustc
11+
1012, debugBuild ? false
11−, # If you want the resulting program to call itself "Firefox" instead
12− # of "Nightly" or whatever, enable this option. However, those
13− # binaries may not be distributed without permission from the
14− # Mozilla Foundation, see
15− # http://www.mozilla.org/foundation/trademarks/.
16− enableOfficialBranding ? false
13+
14+### optionals
15+
16+, alsaSupport ? true, alsaLib
17+, pulseaudioSupport ? true, libpulseaudio
18+, ffmpegSupport ? true, gstreamer, gst-plugins-base
19+, gtk3Support ? true, gtk2, gtk3, wrapGAppsHook
20+
21+, webrtcSupport ? true
22+, geolocationSupport ? true
23+, googleAPISupport ? geolocationSupport
24+, crashreporterSupport ? false
25+
26+, safeBrowsingSupport ? false
27+, drmSupport ? false
28+
29+# If you want the resulting program to call itself "Firefox" instead
30+# of "Nightly" or whatever, enable this option. However, those
31+# binaries may not be distributed without permission from the
32+# Mozilla Foundation, see
33+# http://www.mozilla.org/foundation/trademarks/.
34+, enableOfficialBranding ? false
1735}:
1836
1937assert stdenv.cc ? libc && stdenv.cc.libc != null;
2038
2139let
40+ flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")];
41+in
2242
23−common = { pname, version, sha512, updateScript }: stdenv.mkDerivation rec {
43+stdenv.mkDerivation rec {
2444 name = "${pname}-unwrapped-${version}";
2545
26− src = fetchurl {
27− url =
28− let ext = if lib.versionAtLeast version "41.0" then "xz" else "bz2";
29− in "mirror://mozilla/firefox/releases/${version}/source/firefox-${version}.source.tar.${ext}";
30− inherit sha512;
31− };
32−
33− # this patch should no longer be needed in 53
34− # from https://bugzilla.mozilla.org/show_bug.cgi?id=1013882
35− patches = lib.optional debugBuild ./fix-debug.patch;
36−
37− buildInputs =
38− [ gtk2 zip libIDL libjpeg zlib bzip2
39− dbus dbus_glib pango freetype fontconfig xorg.libXi
40− xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
41− alsaLib nspr nss libnotify xorg.pixman yasm mesa
42− xorg.libXScrnSaver xorg.scrnsaverproto
43− xorg.libXext xorg.xextproto sqlite unzip
44− hunspell libevent libstartup_notification libvpx /* cairo */
45− icu libpng jemalloc
46− libpulseaudio # only headers are needed
47− ]
48− ++ lib.optional enableGTK3 gtk3
49− ++ lib.optionals (!passthru.ffmpegSupport) [ gstreamer gst-plugins-base ];
46+ inherit src patches meta;
47+
48+ buildInputs = [
49+ gtk2 perl zip libIDL libjpeg zlib bzip2
50+ dbus dbus_glib pango freetype fontconfig xorg.libXi
51+ xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
52+ nss nspr libnotify xorg.pixman yasm mesa
53+ xorg.libXScrnSaver xorg.scrnsaverproto
54+ xorg.libXext xorg.xextproto sqlite unzip makeWrapper
55+ hunspell libevent libstartup_notification libvpx /* cairo */
56+ icu libpng jemalloc
57+ ]
58+ ++ lib.optional alsaSupport alsaLib
59+ ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed
60+ ++ lib.optionals ffmpegSupport [ gstreamer gst-plugins-base ]
61+ ++ lib.optional gtk3Support gtk3;
5062
5163 nativeBuildInputs =
5264 [ autoconf213 which gnused pkgconfig perl python cargo rustc ]
53− ++ lib.optional enableGTK3 wrapGAppsHook;
54−
55− configureFlags =
56− [ "--enable-application=browser"
57− "--with-system-jpeg"
58− "--with-system-zlib"
59− "--with-system-bz2"
60− "--with-system-nspr"
61− "--with-system-nss"
62− "--with-system-libevent"
63− "--with-system-libvpx"
64− "--with-system-png" # needs APNG support
65− "--with-system-icu"
66− "--enable-alsa"
67− "--enable-system-ffi"
68− "--enable-system-hunspell"
69− "--enable-system-pixman"
70− "--enable-system-sqlite"
71− #"--enable-system-cairo"
72− "--enable-startup-notification"
73− "--enable-content-sandbox" # available since 26.0, but not much info available
74− "--disable-crashreporter"
75− "--disable-tests"
76− "--disable-necko-wifi" # maybe we want to enable this at some point
77− "--disable-updater"
78− "--enable-jemalloc"
79− "--disable-gconf"
80− "--enable-default-toolkit=cairo-gtk${if enableGTK3 then "3" else "2"}"
81− "--with-google-api-keyfile=ga"
82− ]
83− ++ (if debugBuild then [ "--enable-debug" "--enable-profiling" ]
84− else [ "--disable-debug" "--enable-release"
85− "--enable-optimize"
86− "--enable-strip" ])
87− ++ lib.optional enableOfficialBranding "--enable-official-branding";
65+ ++ lib.optional gtk3Support wrapGAppsHook;
66+
67+ preConfigure = ''
68+ # remove distributed configuration files
69+ rm -f configure
70+ rm -f js/src/configure
71+ rm -f .mozconfig*
72+
73+ # this will run autoconf213
74+ make -f client.mk configure-files
75+
76+ configureScript="$(realpath ./configure)"
77+ cd obj-*
78+ '' + lib.optionalString googleAPISupport ''
79+ # Google API key used by Chromium and Firefox.
80+ # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
81+ # please get your own set of keys.
82+ echo "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI" >ga
83+ '';
84+
85+ configureFlags = [
86+ "--enable-application=browser"
87+ "--with-system-jpeg"
88+ "--with-system-zlib"
89+ "--with-system-bz2"
90+ "--with-system-nspr"
91+ "--with-system-nss"
92+ "--with-system-libevent"
93+ "--with-system-libvpx"
94+ "--with-system-png" # needs APNG support
95+ "--with-system-icu"
96+ "--enable-system-ffi"
97+ "--enable-system-hunspell"
98+ "--enable-system-pixman"
99+ "--enable-system-sqlite"
100+ #"--enable-system-cairo"
101+ "--enable-startup-notification"
102+ "--enable-content-sandbox" # available since 26.0, but not much info available
103+ "--disable-tests"
104+ "--disable-necko-wifi" # maybe we want to enable this at some point
105+ "--disable-updater"
106+ "--enable-jemalloc"
107+ "--disable-maintenance-service"
108+ "--disable-gconf"
109+ "--enable-default-toolkit=cairo-gtk${if gtk3Support then "3" else "2"}"
110+ ]
111+ ++ flag alsaSupport "alsa"
112+ ++ flag pulseaudioSupport "pulseaudio"
113+ ++ flag ffmpegSupport "ffmpeg"
114+ ++ lib.optional (!ffmpegSupport) "--disable-gstreamer"
115+ ++ flag webrtcSupport "webrtc"
116+ ++ flag geolocationSupport "mozril-geoloc"
117+ ++ lib.optional googleAPISupport "--with-google-api-keyfile=ga"
118+ ++ flag crashreporterSupport "crashreporter"
119+ ++ flag safeBrowsingSupport "safe-browsing"
120+ ++ flag drmSupport "eme"
121+
122+ ++ (if debugBuild then [ "--enable-debug" "--enable-profiling" ]
123+ else [ "--disable-debug" "--enable-release"
124+ "--enable-optimize"
125+ "--enable-strip" ])
126+ ++ lib.optional enableOfficialBranding "--enable-official-branding";
88127
89128 enableParallelBuilding = true;
90129
91− preConfigure =
92− ''
93− configureScript="$(realpath ./configure)"
94− mkdir ../objdir
95− cd ../objdir
96−
97− # Google API key used by Chromium and Firefox.
98− # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
99− # please get your own set of keys.
100− echo "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI" >ga
101− '';
102−
103− preInstall =
104− ''
105− # The following is needed for startup cache creation on grsecurity kernels.
106− paxmark m ../objdir/dist/bin/xpcshell
107− '';
108−
109− postInstall =
110− ''
111− # For grsecurity kernels
112− paxmark m $out/lib/firefox-[0-9]*/{firefox,firefox-bin,plugin-container}
113−
114− # Remove SDK cruft. FIXME: move to a separate output?
115− rm -rf $out/share/idl $out/include $out/lib/firefox-devel-*
116−
117− # Needed to find Mozilla runtime
118− gappsWrapperArgs+=(--argv0 "$out/bin/.firefox-wrapped")
119− '';
120−
121− postFixup =
130+ preInstall = ''
131+ # The following is needed for startup cache creation on grsecurity kernels.
132+ paxmark m dist/bin/xpcshell
133+ '';
134+
135+ postInstall = ''
136+ # For grsecurity kernels
137+ paxmark m $out/lib/firefox-[0-9]*/{firefox,firefox-bin,plugin-container}
138+
139+ # Remove SDK cruft. FIXME: move to a separate output?
140+ rm -rf $out/share/idl $out/include $out/lib/firefox-devel-*
141+
142+ # Needed to find Mozilla runtime
143+ gappsWrapperArgs+=(--argv0 "$out/bin/.firefox-wrapped")
144+ '';
145+
146+ postFixup = ''
122147 # Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712.
123− ''
124− patchelf --set-rpath "${lib.getLib libnotify
125− }/lib:$(patchelf --print-rpath "$out"/lib/firefox-*/libxul.so)" \
126− "$out"/lib/firefox-*/libxul.so
127− '';
148+ patchelf --set-rpath "${lib.getLib libnotify
149+ }/lib:$(patchelf --print-rpath "$out"/lib/firefox-*/libxul.so)" \
150+ "$out"/lib/firefox-*/libxul.so
151+ '';
128152
129153 doInstallCheck = true;
130− installCheckPhase =
131− ''
132− # Some basic testing
133− "$out/bin/firefox" --version
134− '';
135−
136− meta = {
137− description = "A web browser" + lib.optionalString (pname == "firefox-esr") " (Extended Support Release)";
138− homepage = http://www.mozilla.com/en-US/firefox/;
139− maintainers = with lib.maintainers; [ eelco ];
140− platforms = lib.platforms.linux;
141− };
154+ installCheckPhase = ''
155+ # Some basic testing
156+ "$out/bin/firefox" --version
157+ '';
142158
143159 passthru = {
144− inherit nspr version updateScript;
145− gtk = gtk2;
146− isFirefox3Like = true;
147160 browserName = "firefox";
148− ffmpegSupport = lib.versionAtLeast version "46.0";
149− };
150−};
151−
152−in {
153−
154− firefox-unwrapped = common {
155− pname = "firefox";
156− version = "53.0";
157− sha512 = "36ec810bab58e3d99478455a38427a5efbc74d6dd7d4bb93b700fd7429b9b89250efd0abe4609091483991802090c6373c8434dfc9ba64c79a778e51fd2a2886";
158− updateScript = import ./update.nix {
159− attrPath = "firefox-unwrapped";
160− inherit writeScript lib common-updater-scripts xidel coreutils gnused gnugrep curl;
161− };
162− };
163−
164− firefox-esr-unwrapped = common {
165− pname = "firefox-esr";
166− version = "52.1.0esr";
167− sha512 = "ba833904654eda347f83df77e04c8e81572772e8555f187b796ecc30e498b93fb729b6f60935731d9584169adc9d61329155364fddf635cbd11abebe4a600247";
168− updateScript = import ./update.nix {
169− attrPath = "firefox-esr-unwrapped";
170− versionSuffix = "esr";
171− inherit writeScript lib common-updater-scripts xidel coreutils gnused gnugrep curl;
172− };
161+ inherit version updateScript;
162+ isFirefox3Like = true;
163+ gtk = gtk2;
164+ inherit nspr;
165+ inherit ffmpegSupport;
173166 };
174−
175167}
pkgs/applications/networking/browsers/firefox/packages.nixnew file+43
@@ -0,0 +1,43 @@
1+{ lib, callPackage, fetchurl }:
2+
3+let common = opts: callPackage (import ./common.nix opts); in
4+
5+rec {
6+
7+ firefox = common rec {
8+ pname = "firefox";
9+ version = "53.0";
10+ src = fetchurl {
11+ url = "mirror://mozilla/firefox/releases/${version}/source/firefox-${version}.source.tar.xz";
12+ sha512 = "36ec810bab58e3d99478455a38427a5efbc74d6dd7d4bb93b700fd7429b9b89250efd0abe4609091483991802090c6373c8434dfc9ba64c79a778e51fd2a2886";
13+ };
14+
15+ meta = {
16+ description = "A web browser built from Firefox source tree";
17+ homepage = http://www.mozilla.com/en-US/firefox/;
18+ maintainers = with lib.maintainers; [ eelco ];
19+ platforms = lib.platforms.linux;
20+ };
21+ updateScript = callPackage ./update.nix {
22+ attrPath = "firefox-unwrapped";
23+ };
24+ } {};
25+
26+ firefox-esr = common rec {
27+ pname = "firefox-esr";
28+ version = "52.1.0esr";
29+ src = fetchurl {
30+ url = "mirror://mozilla/firefox/releases/${version}/source/firefox-${version}.source.tar.xz";
31+ sha512 = "ba833904654eda347f83df77e04c8e81572772e8555f187b796ecc30e498b93fb729b6f60935731d9584169adc9d61329155364fddf635cbd11abebe4a600247";
32+ };
33+
34+ meta = firefox.meta // {
35+ description = "A web browser built from Firefox Extended Support Release source tree";
36+ };
37+ updateScript = callPackage ./update.nix {
38+ attrPath = "firefox-esr-unwrapped";
39+ versionSuffix = "esr";
40+ };
41+ } {};
42+
43+}
pkgs/top-level/all-packages.nix+11−7
@@ -13776,13 +13776,17 @@ with pkgs;
1377613776
1377713777 filezilla = callPackage ../applications/networking/ftp/filezilla { };
1377813778
13779− inherit (callPackages ../applications/networking/browsers/firefox {
13780− inherit (gnome2) libIDL;
13781− libpng = libpng_apng;
13782− enableGTK3 = true;
13783− python = python2;
13784− gnused = gnused_422;
13785− }) firefox-unwrapped firefox-esr-unwrapped;
13779+ firefoxPackages = recurseIntoAttrs (callPackage ../applications/networking/browsers/firefox/packages.nix {
13780+ callPackage = pkgs.newScope {
13781+ inherit (gnome2) libIDL;
13782+ libpng = libpng_apng;
13783+ python = python2;
13784+ gnused = gnused_422;
13785+ };
13786+ });
13787+
13788+ firefox-unwrapped = firefoxPackages.firefox;
13789+ firefox-esr-unwrapped = firefoxPackages.firefox-esr;
1378613790
1378713791 firefox = wrapFirefox firefox-unwrapped { };
1378813792 firefox-esr = wrapFirefox firefox-esr-unwrapped { };