@@ -100,29 +100,25 @@ stdenv.mkDerivation (rec {
100100 rm -f configure
101101 rm -f js/src/configure
102102 rm -f .mozconfig*
103+ '' + (if lib.versionAtLeast version "58"
104+ # this will run autoconf213
105+ then ''
106+ configureScript="$(realpath ./mach) configure"
107+ '' else ''
108+ make -f client.mk configure-files
109+ configureScript="$(realpath ./configure)"
110+ '') + ''
111+ cxxLib=$( echo -n ${gcc}/include/c++/* )
112+ archLib=$cxxLib/$( ${gcc}/bin/gcc -dumpmachine )
103113
104− '' + lib.optionalString (stdenv.lib.versionAtLeast version "58.0.0") ''
105− cat >.mozconfig <<END_MOZCONFIG
106− ${lib.concatStringsSep "\n" (map (flag: "ac_add_options ${flag}") configureFlags)}
107− ${lib.optionalString googleAPISupport "ac_add_options --with-google-api-keyfile=$TMPDIR/ga"}
108− END_MOZCONFIG
114+ test -f layout/style/ServoBindings.toml && sed -i -e '/"-DMOZ_STYLO"/ a , "-cxx-isystem", "'$cxxLib'", "-isystem", "'$archLib'"' layout/style/ServoBindings.toml
109115 '' + lib.optionalString googleAPISupport ''
110116 # Google API key used by Chromium and Firefox.
111117 # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
112118 # please get your own set of keys.
113119 echo "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI" > $TMPDIR/ga
114120 configureFlagsArray+=("--with-google-api-keyfile=$TMPDIR/ga")
115− '' + ''
116− # this will run autoconf213
117− ${if (stdenv.lib.versionAtLeast version "58.0.0") then "./mach configure" else "make -f client.mk configure-files"}
118−
119− configureScript="$(realpath ./configure)"
120−
121− cxxLib=$( echo -n ${gcc}/include/c++/* )
122− archLib=$cxxLib/$( ${gcc}/bin/gcc -dumpmachine )
123−
124− test -f layout/style/ServoBindings.toml && sed -i -e '/"-DMOZ_STYLO"/ a , "-cxx-isystem", "'$cxxLib'", "-isystem", "'$archLib'"' layout/style/ServoBindings.toml
125−
121+ '' + lib.optionalString (lib.versionOlder version "58") ''
126122 cd obj-*
127123 '';
128124
@@ -150,12 +146,12 @@ stdenv.mkDerivation (rec {
150146 "--disable-gconf"
151147 "--enable-default-toolkit=cairo-gtk${if gtk3Support then "3" else "2"}"
152148 ]
153− ++ lib.optionals (stdenv.lib.versionAtLeast version "56" && !stdenv.hostPlatform.isi686) [
149+ ++ lib.optionals (lib.versionAtLeast version "56" && !stdenv.hostPlatform.isi686) [
154150 # on i686-linux: --with-libclang-path is not available in this configuration
155151 "--with-libclang-path=${llvmPackages.libclang}/lib"
156152 "--with-clang-path=${llvmPackages.clang}/bin/clang"
157153 ]
158− ++ lib.optionals (stdenv.lib.versionAtLeast version "57") [
154+ ++ lib.optionals (lib.versionAtLeast version "57") [
159155 "--enable-webrender=build"
160156 ]
161157
@@ -196,6 +192,16 @@ stdenv.mkDerivation (rec {
196192 ++ lib.optional enableOfficialBranding "--enable-official-branding"
197193 ++ extraConfigureFlags;
198194
195+ # Before 58 we have to run `make -f client.mk configure-files` at
196+ # the top level, and then run `./configure` in the obj-* dir (see
197+ # above), but in 58 we have to instead run `./mach configure` at the
198+ # top level and then run `make` in obj-*. (We can also run the
199+ # `make` at the top level in 58, but then we would have to `cd` to
200+ # `make install` anyway. This is ugly, but simple.)
201+ postConfigure = lib.optionalString (lib.versionAtLeast version "58") ''
202+ cd obj-*
203+ '';
204+
199205 preBuild = lib.optionalString (enableOfficialBranding && isTorBrowserLike) ''
200206 buildFlagsArray=("MOZ_APP_DISPLAYNAME=Tor Browser")
201207 '';