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\.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 .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 '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
|
# types.pathInStore
|
||||||
checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix
|
checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix
|
||||||
|
|
|
@ -620,16 +620,15 @@ rec {
|
||||||
nestedTypes.elemType = elemType;
|
nestedTypes.elemType = elemType;
|
||||||
};
|
};
|
||||||
|
|
||||||
attrTag = tags: attrTagWith { inherit tags; };
|
attrTag = tags:
|
||||||
|
let tags_ = tags; in
|
||||||
attrTagWith = args@{ tags }:
|
|
||||||
let
|
let
|
||||||
tags =
|
tags =
|
||||||
mapAttrs
|
mapAttrs
|
||||||
(n: opt:
|
(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")
|
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 then
|
||||||
if opt._type == "option-type"
|
if opt._type == "option-type"
|
||||||
then "was a bare type, not wrapped in mkOption."
|
then "was a bare type, not wrapped in mkOption."
|
||||||
|
@ -637,16 +636,16 @@ rec {
|
||||||
else "was not."}"
|
else "was not."}"
|
||||||
opt // {
|
opt // {
|
||||||
declarations = opt.declarations or (
|
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 ]
|
in if pos == null then [] else [ pos.file ]
|
||||||
);
|
);
|
||||||
declarationPositions = opt.declarationPositions or (
|
declarationPositions = opt.declarationPositions or (
|
||||||
let pos = builtins.unsafeGetAttrPos n args.tags;
|
let pos = builtins.unsafeGetAttrPos n tags_;
|
||||||
in if pos == null then [] else [ pos ]
|
in if pos == null then [] else [ pos ]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
args.tags;
|
tags_;
|
||||||
choicesStr = concatMapStringsSep ", " lib.strings.escapeNixIdentifier (attrNames tags);
|
choicesStr = concatMapStringsSep ", " lib.strings.escapeNixIdentifier (attrNames tags);
|
||||||
in
|
in
|
||||||
mkOptionType {
|
mkOptionType {
|
||||||
|
@ -663,7 +662,15 @@ rec {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
tags;
|
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)};
|
check = v: isAttrs v && length (attrNames v) == 1 && tags?${head (attrNames v)};
|
||||||
merge = loc: defs:
|
merge = loc: defs:
|
||||||
let
|
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)}.";
|
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;
|
nestedTypes = tags;
|
||||||
functor = (defaultFunctor "attrTagWith") // {
|
functor = defaultFunctor "attrTag" // {
|
||||||
|
type = { tags, ... }: types.attrTag tags;
|
||||||
payload = { inherit tags; };
|
payload = { inherit tags; };
|
||||||
binOp =
|
binOp =
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in New Issue
Block a user