let module = { lib, ... }: with lib; with types; let mySubmodule = types.submodule { options.flags = mkOption { type = types.listOf types.str; default = []; }; options.value = mkOption { type = types.nullOr types.str; }; }; toAttr = value: { inherit value; }; strToMySubmodule = types.coercedTo types.str toAttr mySubmodule; in { options.my = mkOption { type = attrsOf strToMySubmodule; default = mapAttrs (_: mkOptionDefault) { foo = "bar"; }; }; config.my = mkMerge [ (mkOptionDefault { foo.flags = [ "my-flag"]; }) (mapAttrs (_: mkOptionDefault) { baz = "test"; }) ]; }; in (import ).evalModules { modules = [ module ]; }