-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite meta-check.nix type checking logic. #37252
Commits on Mar 19, 2018
-
A simple type system to check plain nix values. Please see the module comments for further explanations. Will be used to correct the buggy meta-field checks and help in sanity-checking other parts of nixpkgs.
Configuration menu - View commit details
-
Copy full SHA for b75602d - Browse repository at this point
Copy the full SHA b75602dView commit details -
lib/types-simple: add productOpt and defaults
productOpt: a product type with the possibility for optional fields defaults: generate (semi-arbitrary) default values for a given type In preparation for the rewrite of `check-meta.nix`.
Configuration menu - View commit details
-
Copy full SHA for 0ec18b2 - Browse repository at this point
Copy the full SHA 0ec18b2View commit details -
stdenv/generic/check-meta: rewrite type checking code
The previous code used some ad-hoc attribute enumeration to check for missing fields and did not really type check the attributes, because it used `t.check` from the module system types, which only does shallow checks for nested types, e.g. just `builtins.isList` for (listOf strings). This new version uses `types-simple` to recursively check every attribute, outputting accurate information for type errors in nested fields, e.g.: Package ‘hello-2.10’ in … has an invalid meta attrset: maintainers.1.email should be: string but is: null When we set meta.maintainers [ eelco foobar ]; in `hello/default.nix` and foobar is defined as { name = "foobar"; email = null; }; in `maintainers-list.nix`. The path accurately pins down where the type check failed: In the `maintainers` field, the second element of the list (counting from 0) and the field email in that element. Further work: If an unsupported meta field is used, the type error will print the complete type of the meta product, which is quite big. The type error should show a diff of the problematic fields in that case. This is possible but not yet integrated into the type checking logic.
Configuration menu - View commit details
-
Copy full SHA for 4812142 - Browse repository at this point
Copy the full SHA 4812142View commit details -
check-meta: unify meta.licenses attribute type
The meta type is changed to either a string, a license or a list of licenses, where license is an attrset with required `fullName`, `shortName` and `free` fields, and two optional fields. Every package that does not conform to this union type is fixed; I noticed that only a few packages used `list of strings`, so I corrected them and removed the alternative.
Configuration menu - View commit details
-
Copy full SHA for 7435fa2 - Browse repository at this point
Copy the full SHA 7435fa2View commit details -
lib/types-simple: add lots more (inline) documentation
Especially document the inner workings of the `checkType` function.
Configuration menu - View commit details
-
Copy full SHA for 8729bda - Browse repository at this point
Copy the full SHA 8729bdaView commit details -
lib/types-simple: remove defaults & small improvement
`defaults` originally only was a crutch to make products accept optional attributes shallowly, but that has been replaced by `productOpt`, so we don’t need it anymore. Also a few other changes based on input by @aszlig.
Configuration menu - View commit details
-
Copy full SHA for eefcd09 - Browse repository at this point
Copy the full SHA eefcd09View commit details -
lib/types-simple: add
restrict
`restrict` is able to restrict the inhabitants of a type, meaning only a subset of a type is allowed, the new type is “smaller”, but still gives nice type errors if a nested value has the wrong type. See the tests for some usage examples.
Configuration menu - View commit details
-
Copy full SHA for 85f28ff - Browse repository at this point
Copy the full SHA 85f28ffView commit details
Commits on Mar 31, 2018
-
lib/types-simple: enable “open” products
Open products can have additional fields in the actual value, which always succeed in the type check (effectively default to `any`).
Configuration menu - View commit details
-
Copy full SHA for 8fc5946 - Browse repository at this point
Copy the full SHA 8fc5946View commit details -
lib/types-simple: assert
req
andopt
are disjunctWhen defining a `productOpt` type, `req` and `opt` must not contain the same fields, otherwise the type checking behaviour is undefined.
Configuration menu - View commit details
-
Copy full SHA for f3bca07 - Browse repository at this point
Copy the full SHA f3bca07View commit details
Commits on Apr 1, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 589d1c5 - Browse repository at this point
Copy the full SHA 589d1c5View commit details
Commits on Apr 25, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 99ce0d4 - Browse repository at this point
Copy the full SHA 99ce0d4View commit details -
Configuration menu - View commit details
-
Copy full SHA for c872eec - Browse repository at this point
Copy the full SHA c872eecView commit details -
Configuration menu - View commit details
-
Copy full SHA for 58a32c8 - Browse repository at this point
Copy the full SHA 58a32c8View commit details -
lib/types-simple: remove
names
attribute`names` was originally intended to be able to match on the specific instance of a type, but it breaks the abstraction in a way. Since the function that used it was removed, we can remove the name attributes as well.
Configuration menu - View commit details
-
Copy full SHA for b7e4e0a - Browse repository at this point
Copy the full SHA b7e4e0aView commit details