Hello, I want to define a module that has nested options with a default. I’ve tried something like this:
{ config, lib, ... } :
with lib;
let
cfg = config.services.foo;
in
{
options.services.foo = {
strA = mkOption {
type = types.str;
default = "A";
};
sub = mkOption {
default = { };
type = types.attrsOf ( types.submodule {
options = {
strB = mkOption {
type = types.str;
default = "B";
};
};
});
};
}
config = {
...
# error within config when trying to use cfg.sub.strB
};
}
I’ve made something similar and try to use the module something like this without specifying the submodule:
services.foo = {
strA = "notA";
}
It complains when implementing the config with cfg.sub.strB
that error: attribute 'strB' missing
. I thought that this would resolve to the default of strB but it does not. Still trying to figure out attrsOf
and types.submodule
so I’m not sure what i’m missing?