mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 19:21:04 +00:00
types.attrTagWith: remove
Keep it simple for now.
This commit is contained in:
parent
1465777b63
commit
47e4a18d01
|
@ -113,7 +113,7 @@ checkConfigError 'A definition for option .intStrings\.mergeError. is not of typ
|
|||
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
|
||||
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
|
||||
|
|
|
@ -620,16 +620,15 @@ rec {
|
|||
nestedTypes.elemType = elemType;
|
||||
};
|
||||
|
||||
attrTag = tags: attrTagWith { inherit tags; };
|
||||
|
||||
attrTagWith = args@{ tags }:
|
||||
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 args.tags n}" (
|
||||
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/attrTagWith, each tag value must be an option, but tag ${lib.strings.escapeNixIdentifier n} ${
|
||||
"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."
|
||||
|
@ -637,16 +636,16 @@ rec {
|
|||
else "was not."}"
|
||||
opt // {
|
||||
declarations = opt.declarations or (
|
||||
let pos = builtins.unsafeGetAttrPos n args.tags;
|
||||
let pos = builtins.unsafeGetAttrPos n tags_;
|
||||
in if pos == null then [] else [ pos.file ]
|
||||
);
|
||||
declarationPositions = opt.declarationPositions or (
|
||||
let pos = builtins.unsafeGetAttrPos n args.tags;
|
||||
let pos = builtins.unsafeGetAttrPos n tags_;
|
||||
in if pos == null then [] else [ pos ]
|
||||
);
|
||||
}
|
||||
))
|
||||
args.tags;
|
||||
tags_;
|
||||
choicesStr = concatMapStringsSep ", " lib.strings.escapeNixIdentifier (attrNames tags);
|
||||
in
|
||||
mkOptionType {
|
||||
|
@ -663,7 +662,15 @@ rec {
|
|||
};
|
||||
})
|
||||
tags;
|
||||
substSubModules = m: attrTagWith { tags = mapAttrs (n: opt: opt // { type = (opt.type or types.unspecified).substSubModules m; }) 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
|
||||
|
@ -687,7 +694,8 @@ rec {
|
|||
}
|
||||
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") // {
|
||||
functor = defaultFunctor "attrTag" // {
|
||||
type = { tags, ... }: types.attrTag tags;
|
||||
payload = { inherit tags; };
|
||||
binOp =
|
||||
let
|
||||
|
|
Loading…
Reference in a new issue