aboutsummaryrefslogtreecommitdiff
path: root/lib/types.nix (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib/types.nix: fix missing inheritKeshav Kini2020-10-261-0/+3
| | | | | | | I think there was a silent (i.e. semantic) merge conflict between PR #101139 and PR #100456. This commit should fix the error, which manifests as follows: error: undefined variable 'boolToString' at /home/kkini/src/nixpkgs/lib/types.nix:552:42
* Merge pull request #101139 from roberth/lib-use-static-scope-checkingRobert Hensing2020-10-261-6/+56
|\ | | | | lib: Use Nix's static scope checking, fix error message, optimize
| * lib: Use Nix's static scope checking, fix error message, optimizeRobert Hensing2020-10-221-5/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nix can perform static scope checking, but whenever code is inside a `with` expression, the analysis breaks down, because it can't know statically what's in the attribute set whose attributes were brought into scope. In those cases, Nix has to assume that everything works out. Except it doesnt. Removing `with` from lib/ revealed an undefined variable in an error message. If that doesn't convince you that we're better off without `with`, I can tell you that this PR results in a 3% evaluation performance improvement because Nix can look up local variables by index. This adds up with applications like the module system. Furthermore, removing `with` makes the binding site of each variable obvious, which helps with comprehension.
| * lib/types.nix: Use // instead of mergeAttrsRobert Hensing2020-10-221-1/+1
| |
* | treewide: De-inline uses of lib.boolToStringMalte Brandy2020-10-141-1/+1
|/ | | | This commit should not change eval results
* lib/types: Fix type description of bool enum valuesSilvan Mosberger2020-10-031-0/+1
| | | | Previously bool values would show as <bool>
* lib/types: Remove unreachable if branchSilvan Mosberger2020-09-211-10/+8
| | | | | The type's check function already ensured that it can't be passed non-lists
* Merge pull request #97119 from Infinisil/types.anythingRobert Hensing2020-09-211-0/+36
|\ | | | | Introduce `types.anything`
| * lib/types: Introduce types.anythingSilvan Mosberger2020-09-151-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | This new type has unsurprising merge behavior: Only attribute sets are merged together (recursively), and only if they don't conflict. This is in contrast to the existing types: - types.attrs is problematic because later definitions completely override attributes of earlier definitions, and it doesn't support mkIf and co. - types.unspecified is very similar to types.attrs, but it has smart merging behavior that often doesn't make sense, and it doesn't support all types
* | Merge pull request #97114 from Infinisil/type-deprecationSilvan Mosberger2020-09-071-15/+16
|\ \ | | | | | | Better type deprecation messages
| * | lib/types: Set deprecationMessage for types.optionSetSilvan Mosberger2020-09-071-1/+2
| | |
| * | lib/types: Set deprecationMessage for types.loaOfSilvan Mosberger2020-09-071-8/+6
| | |
| * | lib/types: Set deprecationMessage for types.stringSilvan Mosberger2020-09-071-2/+4
| | |
| * | lib/types: Remove types.list, it's been deprecated long enoughSilvan Mosberger2020-09-071-3/+0
| | | | | | | | | | | | | | | Has been deprecated since fd803fce606a007403ba6d05f09ed2e6a3371830 (2013-08-22)
| * | lib/types: Allow types to emit a deprecation warningSilvan Mosberger2020-09-071-1/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | Previously the only way to deprecate a type was using theType = lib.warn "deprecated" (mkOptionType ...) This caused the warning to be emitted when the type was evaluated, but the error didn't include which option actually used that type. With this commit, types can specify a deprecationMessage, which when non-null, is printed along with the option that uses the type
* | Merge pull request #97042 from Infinisil/freeform-option-docsSilvan Mosberger2020-09-071-1/+6
|\ \ | |/ |/| Show sub options of freeform types
| * lib/types: Show sub options of freeform typesSilvan Mosberger2020-09-031-1/+6
| | | | | | | | | | Previously if you set the freeform type to e.g. attrsOf (submodule ..), those submodule options wouldn't be shown in the manual.
* | treewide: completely remove types.loaOfrnhmjoj2020-09-021-106/+11
|/
* lib/types: Make submodules use the freeform type descriptionSilvan Mosberger2020-08-031-0/+6
| | | | | | | Submodules that have a freeform type set behave as if that was the type of the option itself (for values that don't have an option). Since the submodules options are shown as separate entries in the manual, it makes sense to show the freeform type as the submodule type.
* Replace short URL from #63103 with full URL.Drew Hess2020-01-151-1/+1
| | | | | The error message is already helpfully verbose, so there's little reason to shorten the informational URL.
* lib/types: prioritise coercedType in coercedToarcnmx2020-01-141-4/+4
| | | | | This more intuitively matches `types.either` and allows paths to be coerced to submodules again, which was inhibited by #76861
* lib/types: dont warn loaOf for home-manager namespaceworldofpeace2020-01-121-12/+0
| | | | | This option namespace is not a part of NixOS so we shouldn't provide this warning for it.
* Merge pull request #77501 from jtojnar/more-loaof-fxesJan Tojnar2020-01-121-5/+67
|\ | | | | tree-wide: fix more warning related to loaOf deprecation
| * lib/types: improve loaOf message even moreJan Tojnar2020-01-111-7/+64
| | | | | | | | Now we suggest correct names for all options in Nixpkgs and also home-manager at the time of writing.
| * lib/types: only show ... in loaOf warning when necessaryJan Tojnar2020-01-111-2/+3
| |
| * lib/types: improve loaOf warningJan Tojnar2020-01-111-3/+7
| | | | | | | | | | Not all modules use name attribute as the name of the submodule, for example, environment.etc uses target. We will need to maintain a list of exceptions.
* | Merge pull request #76861 from Infinisil/paths-as-submodulesRobert Hensing2020-01-121-3/+5
|\ \ | |/ |/| lib/types: Allow paths as submodule values
| * lib/types: Allow paths as submodule valuesSilvan Mosberger2020-01-081-3/+5
| |
* | lib/types: Introduce lazyAttrsOfSilvan Mosberger2020-01-101-0/+24
| | | | | | | | | | | | | | The standard attrsOf is strict in its *values*, meaning it's impossible to access only one attribute value without evaluating all others as well. lazyAttrsOf is a version that doesn't have that problem, at the expense of conditional definitions not properly working anymore.
* | lib/types: Add emptyValue attribute to typesSilvan Mosberger2020-01-101-2/+18
|/ | | | Co-Authored-By: Robert Hensing <roberth@users.noreply.github.com>
* Merge pull request #77133 from Infinisil/fix-path-checkSilvan Mosberger2020-01-071-2/+1
|\ | | | | lib/types: Fix path type check
| * lib/types: Fix path type checkSilvan Mosberger2020-01-061-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously when this function was called without a value coercible to a string it would throw an error instead of returning false. Now it does. As a result this now allows the use of a type like `either path attrs` without it erroring out when a definition is an attribute set. The warning about there not being a isPath primop was removed because this is not the case anymore, there is builtins.isPath. But also there always was `builtins.typeOf x == "path"` that could've been used instead. However the path type now stands for more than just path types, but absolute paths in general.
* | lib/types: warn loaOf is deprecatedrnhmjoj2020-01-061-12/+29
|/
* Revert "lib/types: Allow paths as submodule values"Silvan Mosberger2020-01-031-5/+3
| | | | | | | | | This reverts commit eec83d41e3e7d9ad5bc1086198d972d55bab1203. This broke hydra evaluation because with this commit submodule values are allowed to be paths, however the certmgr module uses `either (submodule ...) path` in its type, meaning it already used paths for something else which would now be interpreted as a submodule.
* lib/types: Allow paths as submodule valuesSilvan Mosberger2020-01-021-3/+5
|
* lib/types: Add types.submoduleWith for more flexibility than types.submoduleSilvan Mosberger2020-01-011-15/+47
|
* Merge branch 'master' into stagingVladimír Čunát2019-09-021-1/+2
|\
| * lib/types: Make usage of types.string emit a warningSilvan Mosberger2019-08-311-1/+2
| |
* | treewide: remove redundant recvolth2019-08-281-3/+3
| |
* | treewide: remove redundant quotesvolth2019-08-261-1/+1
|/
* Merge pull request #65728 from Infinisil/types-eithersAaron Andersen2019-08-131-0/+7
|\ | | | | lib/types: Add oneOf, extension of either to a list of types
| * lib/types: Add oneOf, extension of either to a list of typesSilvan Mosberger2019-08-061-0/+7
| |
* | lib/types: change merge strategy for `str`, `int`, `float` and `enum`danbst2019-07-251-5/+5
|/ | | | Change to `mergeEqualOption`.
* module system: revert "remove types.optionSet", just deprecate (#56857)Danylo Hlynskyi2019-03-071-2/+4
| | | | | | | | | | | | | | | | | | | | The explicit remove helped to uncover some hidden uses of `optionSet` in NixOps. However it makes life harder for end-users of NixOps - it will be impossible to deploy 19.03 systems with old NixOps, but there is no new release of NixOps with `optionSet` fixes. Also, "deprecation" process isn't well defined. Even that `optionSet` was declared "deprecated" for many years, it was never announced. Hence, I leave "deprecation" announce. Then, 3 releases after announce, we can announce removal of this feature. This type has to be removed, not `throw`-ed in runtime, because it makes some perfectly fine code to fail. For example: ``` $ nix-instantiate --eval -E '(import <nixpkgs/lib>).types' --strict trace: `types.list` is deprecated; use `types.listOf` instead error: types.optionSet is deprecated; use types.submodule instead (use '--show-trace' to show detailed location information) ```
* types.optionSet: deprecate and remove last usagesdanbst2019-01-311-4/+1
|
* lib/types.nix: small eval optimization (listToAttrs + mapAttrsToList -> ↵danbst2019-01-301-2/+1
| | | | mapAttrs)
* Add type port as an alias to u16Daniel Rutz2018-10-181-0/+3
|
* lib/types: enhances separatedString's descriptionSamuel Dionne-Riel2018-10-121-1/+4
| | | | | | | | | The previous description "string" is misleading in the full options manual pages; they are actually concatenated strings, with a specific character. The empty string version ("types.string") has been special-cased to provide a better message.
* lib: move assertMsg and assertOneOf to their own library fileProfpatsch2018-09-061-1/+1
| | | | | Since the `assertOneOf` uses `lib.generators`, they are not really trivial anymore and should go into their own library file.
* lib/trivial: add a few examples of usage of assertMsg/assertOneOfProfpatsch2018-09-061-2/+6
|