I’m currently working at making recursive bookmark directories in firefox with home-manager, and I’m currently stuck at the option type. Here’s an example of a configuration:
{
wikipedia = {
keyword = "wiki";
url = "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go";
};
"kernel.org" = {
url = "https://www.kernel.org";
};
"Nix sites" = {
homepage = {
url = "https://nixos.org/";
};
wiki = {
url = "https://nixos.wiki/";
};
};
}
And I’m defining the type as follows:
bookmarks = mkOption {
type = let
bookmarkType = types.submodule ({ config, name, ... }: {
options = {
keyword = mkOption {
type = types.nullOr types.str;
default = null;
description = "Bookmark search keyword.";
};
url = mkOption {
type = types.str;
description = "Bookmark url, use %s for search terms.";
};
};
});
bookmarkDirectoryType = with types;
attrsOf (either bookmarkType (bookmarkDirectoryType // { description = "self"; }));
in bookmarkDirectoryType;
};
By overwriting the description attribute, we avoid the infinite recursion that occurs when the type description gets evaluated. However, this breaks because it doesn’t recognize the option bookmarks.bookmarks.Nix sites.homepage
. Which I guess means that it doesn’t recurse, and thus can’t recognize the option?
I’ve also tried playing around with lazyAttrsOf
without any luck. Am I reaching for the impossible, or am I just missing some crucial details? I’ve read through the option declaration manual, but couldn’t seem to find what I’m looking for.