From 1ba9dfbd974616ecf9735742fab179de64065f15 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 20 May 2022 11:18:48 +0200 Subject: [PATCH 1/3] buildMozillaMach: add support for MLS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have received our very own API key for Mozilla Location Services and have been recognized as a Public Interest Project, implying a rate limit of 100k daily requests¹, which should be sufficient for our population. N.B: This key belongs to the NixOS project, please don't use ours, but instead request your own. [1] https://location.services.mozilla.com/terms --- pkgs/applications/networking/browsers/firefox/common.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index b2008a201d3d..d4b6046ec08c 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -102,6 +102,7 @@ , crashreporterSupport ? !privacySupport , geolocationSupport ? !privacySupport , googleAPISupport ? geolocationSupport +, mlsAPISupport ? geolocationSupport , webrtcSupport ? !privacySupport # digital rights managemewnt @@ -298,6 +299,12 @@ buildStdenv.mkDerivation ({ # 60.5+ & 66+ did split the google API key arguments: https://bugzilla.mozilla.org/show_bug.cgi?id=1531176 configureFlagsArray+=("--with-google-location-service-api-keyfile=$TMPDIR/ga") configureFlagsArray+=("--with-google-safebrowsing-api-keyfile=$TMPDIR/ga") + '' + lib.optionalString mlsAPISupport '' + # Mozilla Location services API key + # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution, + # please get your own set of keys at https://location.services.mozilla.com/api. + echo "dfd7836c-d458-4917-98bb-421c82d3c8a0" > $TMPDIR/mls-api-key + configureFlagsArray+=("--with-mozilla-api-keyfile=$TMPDIR/mls-api-key") '' + lib.optionalString enableOfficialBranding '' export MOZILLA_OFFICIAL=1 ''; From 0750e47a4d3a7c6a09d1c67348477148847eb87b Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 20 May 2022 11:25:23 +0200 Subject: [PATCH 2/3] buildMozillaMach: Clean up Google API key configuration Use a proper filename that and add the URL where information about requesting API keys can be found. --- pkgs/applications/networking/browsers/firefox/common.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index d4b6046ec08c..bb07a21d1705 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -294,11 +294,11 @@ buildStdenv.mkDerivation ({ '' + lib.optionalString googleAPISupport '' # Google API key used by Chromium and Firefox. # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution, - # please get your own set of keys. - echo "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI" > $TMPDIR/ga + # please get your own set of keys at https://www.chromium.org/developers/how-tos/api-keys/. + echo "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI" > $TMPDIR/google-api-key # 60.5+ & 66+ did split the google API key arguments: https://bugzilla.mozilla.org/show_bug.cgi?id=1531176 - configureFlagsArray+=("--with-google-location-service-api-keyfile=$TMPDIR/ga") - configureFlagsArray+=("--with-google-safebrowsing-api-keyfile=$TMPDIR/ga") + configureFlagsArray+=("--with-google-location-service-api-keyfile=$TMPDIR/google-api-key") + configureFlagsArray+=("--with-google-safebrowsing-api-keyfile=$TMPDIR/google-api-key") '' + lib.optionalString mlsAPISupport '' # Mozilla Location services API key # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution, From 2d97db78736a4b60f4c6ab39350fa07fedc8ab3c Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 22 May 2022 01:49:20 +0200 Subject: [PATCH 3/3] buildMozillaMach: set geo.provider.network.url for new profiles. Use Mozilla Location Service as geolocation provider for new profiles, since our Google API key does not seem to work for geolocation at this time. Related: https://github.com/NixOS/nixpkgs/issues/173758 --- .../networking/browsers/firefox/common.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index bb07a21d1705..c246ccec1135 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -180,6 +180,18 @@ let }; }); + defaultPrefs = { + "geo.provider.network.url" = { + value = "https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%"; + reason = "Use MLS by default for geolocation, since our Google API Keys are not working"; + }; + }; + + defaultPrefsFile = pkgs.writeText "nixos-default-prefs.js" (lib.concatStringsSep "\n" (lib.mapAttrsToList (key: value: '' + // ${value.reason} + pref("${key}", ${builtins.toJSON value.value}); + '') defaultPrefs)); + in buildStdenv.mkDerivation ({ @@ -458,6 +470,7 @@ buildStdenv.mkDerivation ({ postInstall = '' # Install distribution customizations install -Dvm644 ${distributionIni} $out/lib/${binaryName}/distribution/distribution.ini + install -Dvm644 ${defaultPrefsFile} $out/lib/${binaryName}/browser/defaults/preferences/nixos-default-prefs.js '' + lib.optionalString buildStdenv.isLinux '' # Remove SDK cruft. FIXME: move to a separate output?