mkFirefoxModule: serialize path prefs as strings

Treat Nix paths like plain string preferences when generating user.js so
values such as browser.bookmarks.file are not JSON-quoted twice.

Add a regression case in the Firefox settings test for a path-valued
preference.
This commit is contained in:
Austin Horstman
2026-04-23 22:06:37 -05:00
parent 5bba6a1e02
commit d035caf3ac
4 changed files with 11 additions and 3 deletions
+4 -1
View File
@@ -75,7 +75,10 @@ let
userPrefValue =
pref:
builtins.toJSON (
if lib.isBool pref || lib.isInt pref || lib.isString pref then pref else builtins.toJSON pref
if lib.isBool pref || lib.isInt pref || lib.isString pref || lib.isPath pref then
pref
else
builtins.toJSON pref
);
extensionSettingsNeedForce =
@@ -0,0 +1 @@
<!DOCTYPE NETSCAPE-Bookmark-file-1>
@@ -24,6 +24,7 @@ in
test = {
id = 1;
settings = {
"browser.bookmarks.file" = ./bookmarks.html;
"general.smoothScroll" = false;
"browser.newtabpage.pinned" = [
{
@@ -51,8 +52,11 @@ in
assertDirectoryExists "home-files/${cfg.profilesPath}/basic"
settingsUserJs=$(normalizeStorePaths \
"home-files/${cfg.profilesPath}/test/user.js")
assertFileContent \
"home-files/${cfg.profilesPath}/test/user.js" \
$settingsUserJs \
${./expected-user.js}
'';
}
@@ -2,8 +2,8 @@
user_pref("browser.bookmarks.file", "/nix/store/00000000000000000000000000000000-bookmarks.html");
user_pref("browser.newtabpage.pinned", "[{\"title\":\"NixOS\",\"url\":\"https://nixos.org\"}]");
user_pref("general.smoothScroll", false);