{ 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; } ]; }); }) ]; }