Merge pull request #106000 from Luis-Hebendanz/firefoxWrapperAddonSettings
firefox: wrapper updating an addon perserves addon settings
This commit is contained in:
commit
00b8fa792b
@ -9,7 +9,7 @@ The `wrapFirefox` function allows to pass policies, preferences and extension th
|
|||||||
myFirefox = wrapFirefox firefox-unwrapped {
|
myFirefox = wrapFirefox firefox-unwrapped {
|
||||||
nixExtensions = [
|
nixExtensions = [
|
||||||
(fetchFirefoxAddon {
|
(fetchFirefoxAddon {
|
||||||
name = "ublock";
|
name = "ublock"; # Has to be unique!
|
||||||
url = "https://addons.mozilla.org/firefox/downloads/file/3679754/ublock_origin-1.31.0-an+fx.xpi";
|
url = "https://addons.mozilla.org/firefox/downloads/file/3679754/ublock_origin-1.31.0-an+fx.xpi";
|
||||||
sha256 = "1h768ljlh3pi23l27qp961v1hd0nbj2vasgy11bmcrlqp40zgvnr";
|
sha256 = "1h768ljlh3pi23l27qp961v1hd0nbj2vasgy11bmcrlqp40zgvnr";
|
||||||
})
|
})
|
||||||
@ -42,7 +42,7 @@ The `wrapFirefox` function allows to pass policies, preferences and extension th
|
|||||||
If `nixExtensions != null` then all manually installed addons will be uninstalled from your browser profile.
|
If `nixExtensions != null` then all manually installed addons will be uninstalled from your browser profile.
|
||||||
To view available enterprise policies visit [enterprise policies](https://github.com/mozilla/policy-templates#enterprisepoliciesenabled)
|
To view available enterprise policies visit [enterprise policies](https://github.com/mozilla/policy-templates#enterprisepoliciesenabled)
|
||||||
or type into the Firefox url bar: `about:policies#documentation`.
|
or type into the Firefox url bar: `about:policies#documentation`.
|
||||||
Nix installed addons do not have a valid signature, which is why signature verification is disabled. This does not compromise security because downloaded addons are checksumed and manual addons can't be installed.
|
Nix installed addons do not have a valid signature, which is why signature verification is disabled. This does not compromise security because downloaded addons are checksumed and manual addons can't be installed. Also make sure that the `name` field of fetchFirefoxAddon is unique. If you remove an addon from the nixExtensions array, rebuild and start Firefox the removed addon will be completly removed with all of its settings.
|
||||||
|
|
||||||
## Troubleshooting {#sec-firefox-troubleshooting}
|
## Troubleshooting {#sec-firefox-troubleshooting}
|
||||||
If addons do not appear installed although they have been defined in your nix configuration file reset the local addon state of your Firefox profile by clicking `help -> restart with addons disabled -> restart -> refresh firefox`. This can happen if you switch from manual addon mode to nix addon mode and then back to manual mode and then again to nix addon mode.
|
If addons do not appear installed although they have been defined in your nix configuration file reset the local addon state of your Firefox profile by clicking `help -> restart with addons disabled -> restart -> refresh firefox`. This can happen if you switch from manual addon mode to nix addon mode and then back to manual mode and then again to nix addon mode.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{ stdenv, lib, makeDesktopItem, makeWrapper, lndir, config
|
{ stdenv, lib, makeDesktopItem, makeWrapper, lndir, config
|
||||||
, replace, fetchurl, zip, unzip, jq, xdg_utils
|
, replace, fetchurl, zip, unzip, jq, xdg_utils, writeText
|
||||||
|
|
||||||
## various stuff that can be plugged in
|
## various stuff that can be plugged in
|
||||||
, flashplayer, hal-flash
|
, flashplayer, hal-flash
|
||||||
@ -97,12 +97,17 @@ let
|
|||||||
# EXTRA PREF CHANGES #
|
# EXTRA PREF CHANGES #
|
||||||
# #
|
# #
|
||||||
#########################
|
#########################
|
||||||
policiesJson = builtins.toFile "policies.json"
|
policiesJson = writeText "policies.json" (builtins.toJSON enterprisePolicies);
|
||||||
(builtins.toJSON enterprisePolicies);
|
|
||||||
|
|
||||||
usesNixExtensions = nixExtensions != null;
|
usesNixExtensions = nixExtensions != null;
|
||||||
|
|
||||||
extensions = builtins.map (a:
|
nameArray = builtins.map(a: a.name) (if usesNixExtensions then nixExtensions else []);
|
||||||
|
|
||||||
|
# Check that every extension has a unqiue .name attribute
|
||||||
|
# and an extid attribute
|
||||||
|
extensions = if nameArray != (lib.unique nameArray) then
|
||||||
|
throw "Firefox addon name needs to be unique"
|
||||||
|
else builtins.map (a:
|
||||||
if ! (builtins.hasAttr "extid" a) then
|
if ! (builtins.hasAttr "extid" a) then
|
||||||
throw "nixExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
|
throw "nixExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
|
||||||
else
|
else
|
||||||
@ -128,12 +133,19 @@ let
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
) {} extensions;
|
) {} extensions;
|
||||||
|
} //
|
||||||
|
{
|
||||||
|
Extensions = {
|
||||||
|
Install = lib.foldr (e: ret:
|
||||||
|
ret ++ [ "${e.outPath}/${e.extid}.xpi" ]
|
||||||
|
) [] extensions;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// extraPolicies;
|
// extraPolicies;
|
||||||
};
|
};
|
||||||
|
|
||||||
mozillaCfg = builtins.toFile "mozilla.cfg" ''
|
mozillaCfg = writeText "mozilla.cfg" ''
|
||||||
// First line must be a comment
|
// First line must be a comment
|
||||||
|
|
||||||
// Disables addon signature checking
|
// Disables addon signature checking
|
||||||
// to be able to install addons that do not have an extid
|
// to be able to install addons that do not have an extid
|
||||||
@ -320,18 +332,13 @@ let
|
|||||||
# preparing for autoconfig
|
# preparing for autoconfig
|
||||||
mkdir -p "$out/lib/${firefoxLibName}/defaults/pref"
|
mkdir -p "$out/lib/${firefoxLibName}/defaults/pref"
|
||||||
|
|
||||||
cat > "$out/lib/${firefoxLibName}/defaults/pref/autoconfig.js" <<EOF
|
echo 'pref("general.config.filename", "mozilla.cfg");' > "$out/lib/${firefoxLibName}/defaults/pref/autoconfig.js"
|
||||||
pref("general.config.filename", "mozilla.cfg");
|
echo 'pref("general.config.obscure_value", 0);' >> "$out/lib/${firefoxLibName}/defaults/pref/autoconfig.js"
|
||||||
pref("general.config.obscure_value", 0);
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$out/lib/${firefoxLibName}/mozilla.cfg" < ${mozillaCfg}
|
cat > "$out/lib/${firefoxLibName}/mozilla.cfg" < ${mozillaCfg}
|
||||||
|
|
||||||
mkdir -p $out/lib/${firefoxLibName}/distribution/extensions
|
mkdir -p $out/lib/${firefoxLibName}/distribution/extensions
|
||||||
|
|
||||||
for i in ${toString extensions}; do
|
|
||||||
ln -s -t $out/lib/${firefoxLibName}/distribution/extensions $i/*
|
|
||||||
done
|
|
||||||
#############################
|
#############################
|
||||||
# #
|
# #
|
||||||
# END EXTRA PREF CHANGES #
|
# END EXTRA PREF CHANGES #
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
{stdenv, lib, coreutils, unzip, jq, zip, fetchurl,writeScript, ...}:
|
{stdenv, lib, coreutils, unzip, jq, zip, fetchurl,writeScript, ...}:
|
||||||
{ name
|
|
||||||
|
{
|
||||||
|
name
|
||||||
, url
|
, url
|
||||||
, md5 ? ""
|
, md5 ? ""
|
||||||
, sha1 ? ""
|
, sha1 ? ""
|
||||||
, sha256 ? ""
|
, sha256 ? ""
|
||||||
, sha512 ? ""
|
, sha512 ? ""
|
||||||
|
, fixedExtid ? null
|
||||||
, hash ? ""
|
, hash ? ""
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
|
|
||||||
inherit name;
|
inherit name;
|
||||||
extid = "${src.outputHash}@${name}";
|
extid = if fixedExtid == null then "nixos@${name}" else fixedExtid;
|
||||||
passthru = {
|
passthru = {
|
||||||
exitd=extid;
|
exitd=extid;
|
||||||
};
|
};
|
||||||
@ -35,4 +39,3 @@ stdenv.mkDerivation rec {
|
|||||||
};
|
};
|
||||||
nativeBuildInputs = [ coreutils unzip zip jq ];
|
nativeBuildInputs = [ coreutils unzip zip jq ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user