Add the tool "nixos-typecheck" that can check an option declaration to:

- Enforce that an option declaration has a "defaultText" if and only if the
   type of the option derives from "package", "packageSet" or "nixpkgsConfig"
   and if a "default" attribute is defined.

 - Enforce that the value of the "example" attribute is wrapped with "literalExample"
   if the type of the option derives from "package", "packageSet" or "nixpkgsConfig".

 - Warn if a "defaultText" is defined in an option declaration if the type of
   the option does not derive from "package", "packageSet" or "nixpkgsConfig".

 - Warn if no "type" is defined in an option declaration.
This commit is contained in:
Thomas Strobel
2016-02-29 01:09:00 +01:00
parent c483224c82
commit cad8957eab
24 changed files with 703 additions and 127 deletions
+1
View File
@@ -20,6 +20,7 @@ in
options = {
boot.kernelPackages = mkOption {
type = types.packageSet;
default = pkgs.linuxPackages;
# We don't want to evaluate all of linuxPackages for the manual
# - some of it might not even evaluate correctly.
@@ -17,14 +17,15 @@ in rec {
unitOption = mkOptionType {
name = "systemd option";
merge = loc: defs:
typerep = "(systemdOption)";
merge = _module: loc: defs:
let
defs' = filterOverrides defs;
defs'' = getValues defs';
in
if isList (head defs'')
then concatLists defs''
else mergeOneOption loc defs';
else mergeOneOption _module loc defs';
};
sharedOptions = {