firefox: assert bookmarks migration warning

This commit is contained in:
Austin Horstman
2026-06-01 12:43:59 -05:00
parent 6a6941ad20
commit 6459fc4aee
6 changed files with 186 additions and 20 deletions

View File

@@ -483,25 +483,11 @@ in
(
bookmarks:
if bookmarks != { } then
lib.warn
''
${cfg.name} bookmarks have been refactored into a submodule that now explicitly require a 'force' option to be enabled.
Replace:
${moduleName}.profiles.${name}.bookmarks = [ ... ];
With:
${moduleName}.profiles.${name}.bookmarks = {
force = true;
settings = [ ... ];
};
''
{
force = true;
settings = bookmarks;
}
{
force = true;
_legacySettings = if builtins.isList bookmarks then "a list" else "an attribute set";
settings = bookmarks;
}
else
{ }
)
@@ -1028,7 +1014,59 @@ in
++ optional (cfg.vendorPath != null) ''
Using '${moduleName}.vendorPath' has been deprecated and
will be removed in the future. Native messaging hosts will function normally without specifying this path.
'';
''
++ lib.flatten (
lib.mapAttrsToList (
name: profile:
lib.optional (profile.bookmarks._legacySettings != null) (
let
legacySettingsExample =
if profile.bookmarks._legacySettings == "a list" then "[ ... ]" else "{ ... }";
in
lib.hm.deprecations.mkDeprecatedOptionValueWarning {
option = modulePath ++ [
"profiles"
name
"bookmarks"
];
old = profile.bookmarks._legacySettings;
replacement = "`${
lib.showOption (
modulePath
++ [
"profiles"
name
"bookmarks"
"settings"
]
)
}` with `${
lib.showOption (
modulePath
++ [
"profiles"
name
"bookmarks"
"force"
]
)
} = true`";
details = ''
Set `force = true` to acknowledge replacing existing custom bookmarks.
Replace:
${moduleName}.profiles.${name}.bookmarks = ${legacySettingsExample};
With:
${moduleName}.profiles.${name}.bookmarks = {
force = true;
settings = ${legacySettingsExample};
};
'';
}
)
) cfg.profiles
);
targets.darwin.defaults = (
mkIf (cfg.darwinDefaultsId != null && isDarwin) {

View File

@@ -84,6 +84,12 @@ in
];
options = {
_legacySettings = mkOption {
type = types.nullOr types.str;
default = null;
visible = false;
};
enable = mkOption {
type = with types; bool;
default = config.settings != [ ];

View File

@@ -0,0 +1,50 @@
{
config,
...
}:
let
cfg = config.programs.firefox;
in
{
imports = [
(import ./setup-firefox-mock-overlay.nix [
"programs"
"firefox"
])
];
home.stateVersion = "26.05";
programs.firefox = {
enable = true;
profiles.default.bookmarks = {
"Home Manager" = {
url = "https://wiki.nixos.org/wiki/Home_Manager";
};
};
};
test.asserts.warnings.expected = [
''
Using `programs.firefox.profiles.default.bookmarks` as an attribute set is deprecated and will be
removed in a future release. Please use `programs.firefox.profiles.default.bookmarks.settings` with `programs.firefox.profiles.default.bookmarks.force = true` instead.
Set `force = true` to acknowledge replacing existing custom bookmarks.
Replace:
programs.firefox.profiles.default.bookmarks = { ... };
With:
programs.firefox.profiles.default.bookmarks = {
force = true;
settings = { ... };
};
''
];
nmt.script = ''
assertFileExists "home-files/${cfg.profilesPath}/default/user.js"
'';
}

View File

@@ -0,0 +1,51 @@
{
config,
...
}:
let
cfg = config.programs.firefox;
in
{
imports = [
(import ./setup-firefox-mock-overlay.nix [
"programs"
"firefox"
])
];
home.stateVersion = "26.05";
programs.firefox = {
enable = true;
profiles.default.bookmarks = [
{
name = "Home Manager";
url = "https://wiki.nixos.org/wiki/Home_Manager";
}
];
};
test.asserts.warnings.expected = [
''
Using `programs.firefox.profiles.default.bookmarks` as a list is deprecated and will be
removed in a future release. Please use `programs.firefox.profiles.default.bookmarks.settings` with `programs.firefox.profiles.default.bookmarks.force = true` instead.
Set `force = true` to acknowledge replacing existing custom bookmarks.
Replace:
programs.firefox.profiles.default.bookmarks = [ ... ];
With:
programs.firefox.profiles.default.bookmarks = {
force = true;
settings = [ ... ];
};
''
];
nmt.script = ''
assertFileExists "home-files/${cfg.profilesPath}/default/user.js"
'';
}

View File

@@ -1,5 +1,7 @@
{ lib, ... }:
{
"firefox-bookmarks-legacy-warning" = ./bookmarks-legacy-warning.nix;
"firefox-bookmarks-legacy-attrset-warning" = ./bookmarks-legacy-attrset-warning.nix;
"firefox-config-path-explicit-legacy" = ./config-path-explicit-legacy.nix;
"firefox-config-path-explicit-xdg" = ./config-path-explicit-xdg.nix;
"firefox-config-path-xdg-default" = ./config-path-xdg-default.nix;

View File

@@ -72,6 +72,25 @@ in
};
}
// {
test.asserts.warnings.expected = [
''
Using `${lib.showOption modulePath}.profiles.bookmarks.bookmarks` as an attribute set is deprecated and will be
removed in a future release. Please use `${lib.showOption modulePath}.profiles.bookmarks.bookmarks.settings` with `${lib.showOption modulePath}.profiles.bookmarks.bookmarks.force = true` instead.
Set `force = true` to acknowledge replacing existing custom bookmarks.
Replace:
${lib.showOption modulePath}.profiles.bookmarks.bookmarks = { ... };
With:
${lib.showOption modulePath}.profiles.bookmarks.bookmarks = {
force = true;
settings = { ... };
};
''
];
nmt.script = ''
bookmarksUserJs=$(normalizeStorePaths \
"home-files/${cfg.profilesPath}/bookmarks/user.js")