types.attrTagWith: remove

Keep it simple for now.

Changed files
+19 -11
lib
+1 -1
lib/tests/modules.sh
···
checkConfigError 'A definition for option .intStrings\.badTagError. is not of type .attribute-tagged union' config.intStrings.badTagError ./types-attrTag.nix
checkConfigError 'A definition for option .intStrings\.badTagTypeError\.left. is not of type .signed integer.' config.intStrings.badTagTypeError.left ./types-attrTag.nix
checkConfigError 'A definition for option .nested\.right\.left. is not of type .signed integer.' config.nested.right.left ./types-attrTag.nix
-
checkConfigError 'In attrTag/attrTagWith, each tag value must be an option, but tag int was a bare type, not wrapped in mkOption.' config.opt.int ./types-attrTag-wrong-decl.nix
# types.pathInStore
checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix
···
checkConfigError 'A definition for option .intStrings\.badTagError. is not of type .attribute-tagged union' config.intStrings.badTagError ./types-attrTag.nix
checkConfigError 'A definition for option .intStrings\.badTagTypeError\.left. is not of type .signed integer.' config.intStrings.badTagTypeError.left ./types-attrTag.nix
checkConfigError 'A definition for option .nested\.right\.left. is not of type .signed integer.' config.nested.right.left ./types-attrTag.nix
+
checkConfigError 'In attrTag, each tag value must be an option, but tag int was a bare type, not wrapped in mkOption.' config.opt.int ./types-attrTag-wrong-decl.nix
# types.pathInStore
checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix
+18 -10
lib/types.nix
···
nestedTypes.elemType = elemType;
};
-
attrTag = tags: attrTagWith { inherit tags; };
-
-
attrTagWith = args@{ tags }:
let
tags =
mapAttrs
(n: opt:
-
builtins.addErrorContext "while checking that attrTag tag ${lib.strings.escapeNixIdentifier n} is an option with a type${inAttrPosSuffix args.tags n}" (
throwIf (opt._type or null != "option")
-
"In attrTag/attrTagWith, each tag value must be an option, but tag ${lib.strings.escapeNixIdentifier n} ${
if opt?_type then
if opt._type == "option-type"
then "was a bare type, not wrapped in mkOption."
···
else "was not."}"
opt // {
declarations = opt.declarations or (
-
let pos = builtins.unsafeGetAttrPos n args.tags;
in if pos == null then [] else [ pos.file ]
);
declarationPositions = opt.declarationPositions or (
-
let pos = builtins.unsafeGetAttrPos n args.tags;
in if pos == null then [] else [ pos ]
);
}
))
-
args.tags;
choicesStr = concatMapStringsSep ", " lib.strings.escapeNixIdentifier (attrNames tags);
in
mkOptionType {
···
};
})
tags;
-
substSubModules = m: attrTagWith { tags = mapAttrs (n: opt: opt // { type = (opt.type or types.unspecified).substSubModules m; }) tags; };
check = v: isAttrs v && length (attrNames v) == 1 && tags?${head (attrNames v)};
merge = loc: defs:
let
···
}
else throw "The option `${showOption loc}` is defined as ${lib.strings.escapeNixIdentifier choice}, but ${lib.strings.escapeNixIdentifier choice} is not among the valid choices (${choicesStr}). Value ${choice} was defined in ${showFiles (getFiles defs)}.";
nestedTypes = tags;
-
functor = (defaultFunctor "attrTagWith") // {
payload = { inherit tags; };
binOp =
let
···
nestedTypes.elemType = elemType;
};
+
attrTag = tags:
+
let tags_ = tags; in
let
tags =
mapAttrs
(n: opt:
+
builtins.addErrorContext "while checking that attrTag tag ${lib.strings.escapeNixIdentifier n} is an option with a type${inAttrPosSuffix tags_ n}" (
throwIf (opt._type or null != "option")
+
"In attrTag, each tag value must be an option, but tag ${lib.strings.escapeNixIdentifier n} ${
if opt?_type then
if opt._type == "option-type"
then "was a bare type, not wrapped in mkOption."
···
else "was not."}"
opt // {
declarations = opt.declarations or (
+
let pos = builtins.unsafeGetAttrPos n tags_;
in if pos == null then [] else [ pos.file ]
);
declarationPositions = opt.declarationPositions or (
+
let pos = builtins.unsafeGetAttrPos n tags_;
in if pos == null then [] else [ pos ]
);
}
))
+
tags_;
choicesStr = concatMapStringsSep ", " lib.strings.escapeNixIdentifier (attrNames tags);
in
mkOptionType {
···
};
})
tags;
+
substSubModules = m:
+
attrTag
+
(mapAttrs
+
(n: opt:
+
opt // {
+
type = (opt.type or types.unspecified).substSubModules m;
+
}
+
)
+
tags);
check = v: isAttrs v && length (attrNames v) == 1 && tags?${head (attrNames v)};
merge = loc: defs:
let
···
}
else throw "The option `${showOption loc}` is defined as ${lib.strings.escapeNixIdentifier choice}, but ${lib.strings.escapeNixIdentifier choice} is not among the valid choices (${choicesStr}). Value ${choice} was defined in ${showFiles (getFiles defs)}.";
nestedTypes = tags;
+
functor = defaultFunctor "attrTag" // {
+
type = { tags, ... }: types.attrTag tags;
payload = { inherit tags; };
binOp =
let