1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

firefox: add preConfig option

This option mirrors `extraConfig`, except its values are added to the
resulting `user.js` before those specified in `options`.
This commit is contained in:
bandithedoge 2024-12-11 18:17:04 +01:00
parent f26aa4b76f
commit e2cbad7366
3 changed files with 26 additions and 3 deletions

View file

@ -1899,6 +1899,17 @@ in {
registry with the option 'programs.nushell.plugins'. registry with the option 'programs.nushell.plugins'.
''; '';
} }
{
time = "2024-12-11T18:32+00:00";
condition = config.programs.firefox.enable;
message = ''
The Firefox module now provides a
`programs.firefox.profiles.<name>.preConfig` option that allows an
arbitrary string to be added to `user.js` *before* the options
specified in `programs.firefox.profiles.<name>.settings`.
'';
}
]; ];
}; };
} }

View file

@ -75,7 +75,7 @@ let
else else
builtins.toJSON pref); builtins.toJSON pref);
mkUserJs = prefs: extraPrefs: bookmarks: mkUserJs = prefs: prePrefs: extraPrefs: bookmarks:
let let
prefs' = lib.optionalAttrs ([ ] != bookmarks) { prefs' = lib.optionalAttrs ([ ] != bookmarks) {
"browser.bookmarks.file" = toString (browserBookmarksFile bookmarks); "browser.bookmarks.file" = toString (browserBookmarksFile bookmarks);
@ -84,6 +84,8 @@ let
in '' in ''
// Generated by Home Manager. // Generated by Home Manager.
${prePrefs}
${concatStrings (mapAttrsToList (name: value: '' ${concatStrings (mapAttrsToList (name: value: ''
user_pref("${name}", ${userPrefValue value}); user_pref("${name}", ${userPrefValue value});
'') prefs')} '') prefs')}
@ -406,6 +408,14 @@ in {
''; '';
}; };
preConfig = mkOption {
type = types.lines;
default = "";
description = ''
Extra preferences to add to {file}`user.js` before those specified in `settings`.
'';
};
userChrome = mkOption { userChrome = mkOption {
type = types.lines; type = types.lines;
default = ""; default = "";
@ -770,8 +780,8 @@ in {
"${profilesPath}/${profile.path}/user.js" = mkIf (profile.settings != { } "${profilesPath}/${profile.path}/user.js" = mkIf (profile.settings != { }
|| profile.extraConfig != "" || profile.bookmarks != [ ]) { || profile.extraConfig != "" || profile.bookmarks != [ ]) {
text = text = mkUserJs profile.settings profile.preConfig profile.extraConfig
mkUserJs profile.settings profile.extraConfig profile.bookmarks; profile.bookmarks;
}; };
"${profilesPath}/${profile.path}/containers.json" = "${profilesPath}/${profile.path}/containers.json" =

View file

@ -1,5 +1,7 @@
// Generated by Home Manager. // Generated by Home Manager.
user_pref("browser.newtabpage.pinned", "[{\"title\":\"NixOS\",\"url\":\"https://nixos.org\"}]"); user_pref("browser.newtabpage.pinned", "[{\"title\":\"NixOS\",\"url\":\"https://nixos.org\"}]");
user_pref("general.smoothScroll", false); user_pref("general.smoothScroll", false);