1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-15 17:50:53 +00:00

firefox: prepare for updated sideloading behavior

Co-Authored-By: Cole Helbling <cole.e.helbling@outlook.com>
This commit is contained in:
Robert Helgesson 2020-03-15 18:10:38 +01:00
parent 2681568f2b
commit cc386e4b3b
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 42 additions and 11 deletions

View file

@ -1381,6 +1381,32 @@ in
A new module is available: 'services.lieer'.
'';
}
{
time = "2020-03-15T16:55:28+00:00";
condition = config.programs.firefox.enable;
message = ''
In anticipation of Firefox dropping support for extension
sideloading[1], we now install extensions directly to
Firefox profiles managed through Home Manager's
'programs.firefox.profiles'
option.
Unfortunately this will most likely trigger an "Existing
file is in the way" error when activating your configuration
since Firefox keeps a copy of the add-on in the location
Home Manager wants to overwrite. If this is the case, remove
the listed '.xpi' files and try again.
This change also means that extensions installed through
Home Manager may disappear from unmanaged profiles in future
Firefox releases.
[1] https://blog.mozilla.org/addons/2019/10/31/firefox-to-discontinue-sideloaded-extensions/
'';
}
];
};
}

View file

@ -23,8 +23,15 @@ let
then "${firefoxConfigPath}/Profiles"
else firefoxConfigPath;
# The extensions path shared by all profiles; will not be supported
# by future Firefox versions.
extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
extensionsEnvPkg = pkgs.buildEnv {
name = "hm-firefox-extensions";
paths = cfg.extensions;
};
profiles =
flip mapAttrs' cfg.profiles (_: profile:
nameValuePair "Profile${toString profile.id}" {
@ -283,17 +290,10 @@ in
home.file = mkMerge (
[{
"${mozillaConfigPath}/${extensionPath}" = mkIf (cfg.extensions != []) (
let
extensionsEnv = pkgs.buildEnv {
name = "hm-firefox-extensions";
paths = cfg.extensions;
};
in {
source = "${extensionsEnv}/share/mozilla/${extensionPath}";
recursive = true;
}
);
"${mozillaConfigPath}/${extensionPath}" = mkIf (cfg.extensions != []) {
source = "${extensionsEnvPkg}/share/mozilla/${extensionPath}";
recursive = true;
};
"${firefoxConfigPath}/profiles.ini" = mkIf (cfg.profiles != {}) {
text = profilesIni;
@ -314,6 +314,11 @@ in
mkIf (profile.settings != {} || profile.extraConfig != "") {
text = mkUserJs profile.settings profile.extraConfig;
};
"${profilesPath}/${profile.path}/extensions" = mkIf (cfg.extensions != []) {
source = "${extensionsEnvPkg}/share/mozilla/${extensionPath}";
recursive = true;
};
})
);
};