forked from NixOS/nixpkgs
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
firefoxLocaleWrapper: takes care of firefox localization
This patch adds a locale-wrapper for firefoxWrapper. The new wrapper does two tings: 1) adds corresponding -UILocale <lang> option 2) Downloads language pack in the background when it thinks language pack is not installed. Use it like following: environment.systemPackages = with pkgs ; [ ... (firefoxLocaleWrapper "ru") ... ];
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
pkgs/applications/networking/browsers/firefox/localeWrapper.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ stdenv, language, firefoxWrapper, firefoxPkgs, gnused, bash, wget }: | ||
let | ||
|
||
version = firefoxPkgs.xulVersion; | ||
|
||
mkscript = name : text : '' | ||
mkdir -pv $out/bin | ||
cat > $out/bin/${name} <<"EOF" | ||
#!${bash}/bin/bash | ||
${text} | ||
EOF | ||
chmod +x $out/bin/${name} | ||
''; | ||
|
||
# FIXME: encode more archs. Check | ||
# ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/${version} for naming | ||
# pattern. | ||
arch = assert stdenv.isLinux; | ||
if stdenv.is64bit | ||
then "linux-x86_64" | ||
else "linux-i686"; | ||
|
||
langurl = "ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/${version}/${arch}/xpi/${language}.xpi"; | ||
|
||
wrapper = mkscript "firefox" '' | ||
LANGPACK=~/.firefox-${version}-langpack-${language}.xpi | ||
if ! test -f "$LANGPACK" ; then | ||
( | ||
# Downloads language pack in separate process | ||
${wget}/bin/wget ${langurl} -O "$LANGPACK" && | ||
${firefoxWrapper}/bin/firefox -UILocale ${language} "$LANGPACK" | ||
) & | ||
fi | ||
exec ${firefoxWrapper}/bin/firefox -UILocale ${language} "''${extraFlagsArray[@]}" "$@" | ||
''; | ||
in | ||
stdenv.mkDerivation { | ||
|
||
name = firefoxWrapper.name + "-with-localeWrapper"; | ||
|
||
buildCommand = '' | ||
mkdir -pv $out/bin | ||
${wrapper} | ||
mkdir -pv $out/share/applications | ||
cp ${firefoxWrapper}/share/applications/* $out/share/applications | ||
mkdir -pv $out/nix-support | ||
echo ${firefoxWrapper} > $out/nix-support/propagated-user-env-packages | ||
''; | ||
|
||
meta = { | ||
description = | ||
firefoxWrapper.meta.description | ||
+ " (with ${language} locale wrapper) "; | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters