summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2022-03-18 00:32:53 +0100
committerSilvan Mosberger <contact@infinisil.com>2022-03-18 04:51:27 +0100
commit96698efe0cd9e0ffe38d95e043acafa926fa5e0d (patch)
tree1e2280053c7ae3eaa24b5d87265a941fc8765425 /lib
parent6cc306ec23b7b63835be7277647554d14a869f28 (diff)
downloadnixpkgs-96698efe0cd9e0ffe38d95e043acafa926fa5e0d.tar
nixpkgs-96698efe0cd9e0ffe38d95e043acafa926fa5e0d.tar.gz
nixpkgs-96698efe0cd9e0ffe38d95e043acafa926fa5e0d.tar.bz2
nixpkgs-96698efe0cd9e0ffe38d95e043acafa926fa5e0d.tar.lz
nixpkgs-96698efe0cd9e0ffe38d95e043acafa926fa5e0d.tar.xz
nixpkgs-96698efe0cd9e0ffe38d95e043acafa926fa5e0d.tar.zst
nixpkgs-96698efe0cd9e0ffe38d95e043acafa926fa5e0d.zip
lib/modules: Finally remove deprecated types.optionSet
types.optionSet has been deprecated for almost 10 years now
(0e333688cea468a28516bf6935648c03ed62a7bb)! A removal
was already attempted in 2019
(27982b408e465554b8831f492362bc87ed0ec02a), but it was promptly
reinstantiated since some third-party uses were discovered
(f531ce75e4178c6867cc1d0f7fec96b2d5c3f1cb).

It's finally time to remove it for good :)
Diffstat (limited to 'lib')
-rw-r--r--lib/modules.nix34
-rw-r--r--lib/options.nix2
-rw-r--r--lib/types.nix8
3 files changed, 6 insertions, 38 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 01ba914ca80..735cb3c967a 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; };