Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions modules/programs/firefox.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ let

profilesIni = generators.toINI { } profiles;

userPrefValue = pref:
builtins.toJSON (if isBool pref || isInt pref || isString pref then
pref
else
builtins.toJSON pref);

mkUserJs = prefs: extraPrefs: bookmarks:
let
prefs' = lib.optionalAttrs ([ ] != bookmarks) {
Expand All @@ -52,7 +58,7 @@ let
// Generated by Home Manager.

${concatStrings (mapAttrsToList (name: value: ''
user_pref("${name}", ${builtins.toJSON value});
user_pref("${name}", ${userPrefValue value});
'') prefs')}

${extraPrefs}
Expand Down Expand Up @@ -202,7 +208,10 @@ in {
};

settings = mkOption {
type = with types; attrsOf (either bool (either int str));
type = types.attrsOf (jsonFormat.type // {
description =
"Firefox preference (int, bool, string, and also attrs, list, float as a JSON string)";
});
default = { };
example = literalExpression ''
{
Expand All @@ -212,9 +221,19 @@ in {
"distribution.searchplugins.defaultLocale" = "en-GB";
"general.useragent.locale" = "en-GB";
"browser.bookmarks.showMobileBookmarks" = true;
"browser.newtabpage.pinned" = [{
title = "NixOS";
url = "https://nixos.org";
}];
Comment thread
kira-bruneau marked this conversation as resolved.
}
'';
description = "Attribute set of Firefox preferences.";
description = ''
Attribute set of Firefox preferences.

Firefox only supports int, bool, and string types for
preferences, but home-manager will automatically
convert all other JSON-compatible values into strings.
'';
};

extraConfig = mkOption {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion tests/modules/programs/firefox/profile-settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ lib.mkIf config.test.enableBig {

profiles.test = {
id = 1;
settings = { "general.smoothScroll" = false; };
settings = {
"general.smoothScroll" = false;
"browser.newtabpage.pinned" = [{
title = "NixOS";
url = "https://nixos.org";
}];
};
};

profiles.bookmarks = {
Expand Down