1 { lib, stdenv, fetchurl, config, wrapGAppsHook3, autoPatchelfHook
21 , systemLocale ? config.i18n.defaultLocale or "en_US"
22 , patchelfUnstable # have to use patchelfUnstable to support --no-clobber-old-sections
27 inherit (generated) version sources;
29 binaryName = if channel == "release" then "firefox" else "firefox-${channel}";
32 i686-linux = "linux-i686";
33 x86_64-linux = "linux-x86_64";
36 arch = mozillaPlatforms.${stdenv.hostPlatform.system};
38 isPrefixOf = prefix: string:
39 builtins.substring 0 (builtins.stringLength prefix) string == prefix;
41 sourceMatches = locale: source:
42 (isPrefixOf source.locale locale) && source.arch == arch;
45 DisableAppUpdate = true;
46 } // config.firefox.policies or {};
48 policiesJson = writeText "firefox-policies.json" (builtins.toJSON { inherit policies; });
50 defaultSource = lib.findFirst (sourceMatches "en-US") {} sources;
53 if systemLocale == "ca_ES@valencia"
55 else lib.replaceStrings ["_"] ["-"] systemLocale;
57 source = lib.findFirst (sourceMatches mozLocale) defaultSource sources;
59 pname = "firefox-${channel}-bin-unwrapped";
63 inherit pname version;
65 src = fetchurl { inherit (source) url sha256; };
67 nativeBuildInputs = [ wrapGAppsHook3 autoPatchelfHook patchelfUnstable ];
75 runtimeDependencies = [
83 # Firefox uses "relrhack" to manually process relocations from a fixed offset
84 patchelfFlags = [ "--no-clobber-old-sections" ];
88 mkdir -p "$prefix/lib/firefox-bin-${version}"
89 cp -r * "$prefix/lib/firefox-bin-${version}"
92 ln -s "$prefix/lib/firefox-bin-${version}/firefox" "$out/bin/${binaryName}"
94 # See: https://github.com/mozilla/policy-templates/blob/master/README.md
95 mkdir -p "$out/lib/firefox-bin-${version}/distribution";
96 ln -s ${policiesJson} "$out/lib/firefox-bin-${version}/distribution/policies.json";
101 libName = "firefox-bin-${version}";
102 ffmpegSupport = true;
107 # $ nix-shell maintainers/scripts/update.nix --argstr package firefox-bin-unwrapped
108 updateScript = import ./update.nix {
109 inherit pname channel lib writeScript xidel coreutils gnused gnugrep gnupg curl runtimeShell;
111 if channel == "developer-edition"
112 then "https://archive.mozilla.org/pub/devedition/releases/"
113 else "https://archive.mozilla.org/pub/firefox/releases/";
118 changelog = "https://www.mozilla.org/en-US/firefox/${version}/releasenotes/";
119 description = "Mozilla Firefox, free web browser (binary package)";
120 homepage = "https://www.mozilla.org/firefox/";
121 license = licenses.mpl20;
122 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
123 platforms = builtins.attrNames mozillaPlatforms;
125 maintainers = with maintainers; [ taku0 lovesegfault ];
126 mainProgram = binaryName;