diff options
author | Silvan Mosberger <contact@infinisil.com> | 2022-03-25 17:41:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-25 17:41:57 +0100 |
commit | 99d9d45630cc82449d8ac29048117f3a7203ac96 (patch) | |
tree | 725fbb08c4aaffc2c391dceab0595ed7f445564b | |
parent | de23459252f7708643c62fd2822157f28898c2a5 (diff) | |
parent | 7b32b8b66f80c10e7d509d62051dfd64470b3ebb (diff) | |
download | nixpkgs-99d9d45630cc82449d8ac29048117f3a7203ac96.tar nixpkgs-99d9d45630cc82449d8ac29048117f3a7203ac96.tar.gz nixpkgs-99d9d45630cc82449d8ac29048117f3a7203ac96.tar.bz2 nixpkgs-99d9d45630cc82449d8ac29048117f3a7203ac96.tar.lz nixpkgs-99d9d45630cc82449d8ac29048117f3a7203ac96.tar.xz nixpkgs-99d9d45630cc82449d8ac29048117f3a7203ac96.tar.zst nixpkgs-99d9d45630cc82449d8ac29048117f3a7203ac96.zip |
Merge pull request #164651 from Infinisil/remove-optionSet
lib/modules: Finally remove deprecated types.optionSet
-rw-r--r-- | doc/contributing/reviewing-contributions.chapter.md | 4 | ||||
-rw-r--r-- | lib/modules.nix | 34 | ||||
-rw-r--r-- | lib/options.nix | 2 | ||||
-rw-r--r-- | lib/types.nix | 8 | ||||
-rw-r--r-- | pkgs/test/mkOption/declare.nix | 53 | ||||
-rw-r--r-- | pkgs/test/mkOption/keep.nix | 11 | ||||
-rw-r--r-- | pkgs/test/mkOption/keep.ref | 57 | ||||
-rw-r--r-- | pkgs/test/mkOption/merge.nix | 15 | ||||
-rw-r--r-- | pkgs/test/mkOption/merge.ref | 20 | ||||
-rwxr-xr-x | pkgs/test/mkOption/test.sh | 9 |
10 files changed, 8 insertions, 205 deletions
diff --git a/doc/contributing/reviewing-contributions.chapter.md b/doc/contributing/reviewing-contributions.chapter.md index 7a13a3f3b40..3417854730e 100644 --- a/doc/contributing/reviewing-contributions.chapter.md +++ b/doc/contributing/reviewing-contributions.chapter.md @@ -122,7 +122,7 @@ Reviewing process: - [CODEOWNERS](https://help.github.com/articles/about-codeowners/) will make GitHub notify users based on the submitted changes, but it can happen that it misses some of the package maintainers. - Ensure that the module tests, if any, are succeeding. - Ensure that the introduced options are correct. - - Type should be appropriate (string related types differs in their merging capabilities, `optionSet` and `string` types are deprecated). + - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated). - Description, default and example should be provided. - Ensure that option changes are backward compatible. - `mkRenamedOptionModuleWith` provides a way to make option changes backward compatible. @@ -157,7 +157,7 @@ Reviewing process: - Ensure that the module tests, if any, are succeeding. - Ensure that the introduced options are correct. - - Type should be appropriate (string related types differs in their merging capabilities, `optionSet` and `string` types are deprecated). + - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated). - Description, default and example should be provided. - Ensure that module `meta` field is present - Maintainers should be declared in `meta.maintainers`. diff --git a/lib/modules.nix b/lib/modules.nix index 35c93d22baf..894104cc579 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -609,17 +609,9 @@ rec { throw "The option `${showOption loc}' in `${opt._file}' is already declared in ${showFiles res.declarations}." else let - /* Add the modules of the current option to the list of modules - already collected. The options attribute except either a list of - submodules or a submodule. For each submodule, we add the file of the - current option declaration as the file use for the submodule. If the - submodule defines any filename, then we ignore the enclosing option file. */ - options' = toList opt.options.options; - getSubModules = opt.options.type.getSubModules or null; submodules = if getSubModules != null then map (setDefaultModuleLocation opt._file) getSubModules ++ res.options - else if opt.options ? options then map (coerceOption opt._file) options' ++ res.options else res.options; in opt.options // res // { declarations = res.declarations ++ [opt._file]; @@ -802,27 +794,13 @@ rec { compare = a: b: (a.priority or 1000) < (b.priority or 1000); in sort compare defs'; + # This calls substSubModules, whose entire purpose is only to ensure that + # option declarations in submodules have accurate position information. + # TODO: Merge this into mergeOptionDecls fixupOptionType = loc: opt: - let - options = opt.options or - (throw "Option `${showOption loc}' has type optionSet but has no option attribute, in ${showFiles opt.declarations}."); - - # Hack for backward compatibility: convert options of type - # optionSet to options of type submodule. FIXME: remove - # eventually. - f = tp: - if tp.name == "option set" || tp.name == "submodule" then - throw "The option ${showOption loc} uses submodules without a wrapping type, in ${showFiles opt.declarations}." - else if (tp.functor.wrapped.name or null) == "optionSet" then - if tp.name == "attrsOf" then types.attrsOf (types.submodule options) - else if tp.name == "listOf" then types.listOf (types.submodule options) - else if tp.name == "nullOr" then types.nullOr (types.submodule options) - else tp - else tp; - in - if opt.type.getSubModules or null == null - then opt // { type = f (opt.type or types.unspecified); } - else opt // { type = opt.type.substSubModules opt.options; options = []; }; + if opt.type.getSubModules or null == null + then opt // { type = opt.type or types.unspecified; } + else opt // { type = opt.type.substSubModules opt.options; options = []; }; /* Properties. */ diff --git a/lib/options.nix b/lib/options.nix index 9efc1249e58..8d0801775c4 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -79,8 +79,6 @@ rec { visible ? null, # Whether the option can be set only once readOnly ? null, - # Deprecated, used by types.optionSet. - options ? null } @ attrs: attrs // { _type = "option"; }; diff --git a/lib/types.nix b/lib/types.nix index 00d97bf5723..5c4b9631061 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -749,14 +749,6 @@ rec { nestedTypes.finalType = finalType; }; - # Obsolete alternative to configOf. It takes its option - # declarations from the ‘options’ attribute of containing option - # declaration. - optionSet = mkOptionType { - name = "optionSet"; - description = "option set"; - deprecationMessage = "Use `types.submodule' instead"; - }; # Augment the given type with an additional type check function. addCheck = elemType: check: elemType // { check = x: elemType.check x && check x; }; diff --git a/pkgs/test/mkOption/declare.nix b/pkgs/test/mkOption/declare.nix deleted file mode 100644 index 9e89a1c096d..00000000000 --- a/pkgs/test/mkOption/declare.nix +++ /dev/null @@ -1,53 +0,0 @@ -# sets of small configurations: -# Each configuration -rec { - # has 2 arguments pkgs and this. - configA = pkgs: this: { - # Can depends on other configuration - require = configB; - - # Defines new options - optionA = pkgs.lib.mkOption { - # With default values - default = false; - # And merging functions. - merge = pkgs.lib.mergeEnableOption; - }; - - # Add a new definition to other options. - optionB = this.optionA; - }; - - # Can be used for option header. - configB = pkgs: this: { - # Can depends on more than one configuration. - require = [ configC configD ]; - - optionB = pkgs.lib.mkOption { - default = false; - }; - - # Is not obliged to define other options. - }; - - configC = pkgs: this: { - require = [ configA ]; - - optionC = pkgs.lib.mkOption { - default = false; - }; - - # Use the default value if it is not overwritten. - optionA = this.optionC; - }; - - # Can also be used as option configuration only. - # without any arguments (backward compatibility) - configD = { - # Is not forced to specify the require attribute. - - # Is not force to make new options. - optionA = true; - optionD = false; - }; -} diff --git a/pkgs/test/mkOption/keep.nix b/pkgs/test/mkOption/keep.nix deleted file mode 100644 index 26fb8c28dd5..00000000000 --- a/pkgs/test/mkOption/keep.nix +++ /dev/null @@ -1,11 +0,0 @@ -let - pkgs = import ../../.. {}; - config = import ./declare.nix; -in - with (pkgs.lib); - - finalReferenceOptionSets - filterOptionSets - pkgs - # List of main configurations. - [ config.configB config.configC ] diff --git a/pkgs/test/mkOption/keep.ref b/pkgs/test/mkOption/keep.ref deleted file mode 100644 index a3a051eb48c..00000000000 --- a/pkgs/test/mkOption/keep.ref +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<expr> - <attrs> - <attr name="optionA"> - <list> - <attrs> - <attr name="_type"> - <string value="option" /> - </attr> - <attr name="default"> - <bool value="false" /> - </attr> - <attr name="merge"> - <unevaluated /> - </attr> - <attr name="name"> - <string value="optionA" /> - </attr> - </attrs> - </list> - </attr> - <attr name="optionB"> - <list> - <attrs> - <attr name="_type"> - <string value="option" /> - </attr> - <attr name="default"> - <bool value="false" /> - </attr> - <attr name="name"> - <string value="optionB" /> - </attr> - </attrs> - </list> - </attr> - <attr name="optionC"> - <list> - <attrs> - <attr name="_type"> - <string value="option" /> - </attr> - <attr name="default"> - <bool value="false" /> - </attr> - <attr name="name"> - <string value="optionC" /> - </attr> - </attrs> - </list> - </attr> - <attr name="optionD"> - <attrs> - </attrs> - </attr> - </attrs> -</expr> diff --git a/pkgs/test/mkOption/merge.nix b/pkgs/test/mkOption/merge.nix deleted file mode 100644 index bbf68218aa0..00000000000 --- a/pkgs/test/mkOption/merge.nix +++ /dev/null @@ -1,15 +0,0 @@ -let - pkgs = import ../../.. {}; - config = import ./declare.nix; - - # Define the handler of unbound options. - noOption = name: values: - builtins.trace "Attribute named '${name}' does not match any option declaration." values; -in - with (pkgs.lib); - - finalReferenceOptionSets - (mergeOptionSets noOption) - pkgs - # List of main configurations. - [ config.configB config.configC ] diff --git a/pkgs/test/mkOption/merge.ref b/pkgs/test/mkOption/merge.ref deleted file mode 100644 index 6956f65dbbc..00000000000 --- a/pkgs/test/mkOption/merge.ref +++ /dev/null @@ -1,20 +0,0 @@ -trace: Str("Attribute named 'optionD' does not match any option declaration.",[]) -<?xml version='1.0' encoding='utf-8'?> -<expr> - <attrs> - <attr name="optionA"> - <bool value="true" /> - </attr> - <attr name="optionB"> - <bool value="true" /> - </attr> - <attr name="optionC"> - <bool value="false" /> - </attr> - <attr name="optionD"> - <list> - <bool value="false" /> - </list> - </attr> - </attrs> -</expr> diff --git a/pkgs/test/mkOption/test.sh b/pkgs/test/mkOption/test.sh deleted file mode 100755 index 5478846d563..00000000000 --- a/pkgs/test/mkOption/test.sh +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/sh -e - -echo 1>&2 "Test: Merge of option bindings." -nix-instantiate merge.nix --eval-only --strict --xml >& merge.out -diff merge.ref merge.out - -echo 1>&2 "Test: Filter of option declarations." -nix-instantiate keep.nix --eval-only --strict --xml >& keep.out -diff keep.ref keep.out |