hylonix/modules/home-manager/gecko-browser/gecko-lib/bookmarks.nix
hylodon 0f0c4c7727 Added a module to configure browser based on the gecko engine, such as Firefox.
This module should provide similar functionality to the firefox module in
home-manager. Some notable differences between the two include:

* home-manager configures a single browser. This means that any configuration
  that cannot be done on a per-profile basis is shared between all
  profiles. This module configures a new copy of the browser for every profile,
  ensuring that *all* configuration can be on a per-profile basis.

  This might be seen as insanity in a regular distro, but in NixOS this is
  trivial to do and requires no extra storage space.

* home-manager modifies files in the user's directory to configure things such
  as extensions and search engines. This module avoids that when possible by
  pushing configuration into policies and preferences at a browser level.
  This is much nicer for impermanence-based systems.
2026-02-22 19:57:42 +00:00

104 lines
2.7 KiB
Nix

{
pkgs,
lib,
info,
...
}:
let
## BookmarkConfig -> BookmarkJSON
updateBookmarkJSON =
data:
builtins.removeAttrs
(
data
// (
if (data ? children) then
{
type = "text/x-moz-place-container";
children = builtins.map updateBookmarkJSON data.children;
}
else
{
type = "text/x-moz-place";
}
)
// lib.optionalAttrs (data ? addTime) { dateAdded = data.addTime; }
// lib.optionalAttrs (data ? modTime) { lastModified = data.modTime; }
)
[
"addTime"
"modTime"
];
in
{
options = {
bookmarks = lib.mkOption {
type = lib.types.submodule {
options = {
menu = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.anything);
default = [ ];
description = "Bookmarks to be placed in the menu.";
};
toolbar = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.anything);
default = [ ];
description = "Bookmarks to be placed in the toolbar";
};
unfiled = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.anything);
default = [ ];
description = "Bookmarks to be placed in the unsorted bookmarks folder.";
};
mobile = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.anything);
default = [ ];
description = "Bookmarks to be placed in the mobile bookmarks folder. This folder is not visible on PC, but the bookmarks can still be searched for.";
};
};
};
default = { };
description = "Declarative bookmarks for this profile.";
};
};
files =
{
name,
path,
bookmarks,
...
}:
[
({
name = "${info.configPath}/${path}/bookmarkbackups/bookmarks-1970-01-01.json";
value.text = builtins.toJSON (updateBookmarkJSON {
title = "";
root = "placesRoot";
children = [
{
title = "menu";
root = "bookmarksMenuFolder";
children = bookmarks.menu;
}
{
title = "toolbar";
root = "toolbarFolder";
children = bookmarks.toolbar;
}
{
title = "unfiled";
root = "unfiledBookmarksFolder";
children = bookmarks.unfiled;
}
{
title = "mobile";
root = "mobileFolder";
children = bookmarks.mobile;
}
];
});
})
];
}