summary refs log tree commit diff
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2017-03-01 18:20:22 +0100
committerVladimír Čunát <vcunat@gmail.com>2017-03-01 21:56:01 +0100
commitfcec3e1c72ad7ac7eaacd00c8fc87dc04696fdb0 (patch)
treeb4a375a8a105886206cc6646128c283a6d8f6680
parent4150920a51c911b45a39f512b4292c1de63990c3 (diff)
downloadnixpkgs-fcec3e1c72ad7ac7eaacd00c8fc87dc04696fdb0.tar
nixpkgs-fcec3e1c72ad7ac7eaacd00c8fc87dc04696fdb0.tar.gz
nixpkgs-fcec3e1c72ad7ac7eaacd00c8fc87dc04696fdb0.tar.bz2
nixpkgs-fcec3e1c72ad7ac7eaacd00c8fc87dc04696fdb0.tar.lz
nixpkgs-fcec3e1c72ad7ac7eaacd00c8fc87dc04696fdb0.tar.xz
nixpkgs-fcec3e1c72ad7ac7eaacd00c8fc87dc04696fdb0.tar.zst
nixpkgs-fcec3e1c72ad7ac7eaacd00c8fc87dc04696fdb0.zip
Revert "modules: add support for module replacement with disabledModules"
This reverts commit 3f2566689d14f1d7778d55ca807d1dad2f4695d1 for now.
Evaluation of the tested job got broken, blocking nixos-unstable.
-rw-r--r--lib/modules.nix24
-rwxr-xr-xlib/tests/modules.sh8
-rw-r--r--lib/tests/modules/default.nix1
-rw-r--r--lib/tests/modules/disable-declare-enable.nix5
-rw-r--r--lib/tests/modules/disable-define-enable.nix5
-rw-r--r--lib/tests/modules/disable-enable-modules.nix5
-rw-r--r--nixos/doc/manual/development/replace-modules.xml75
-rw-r--r--nixos/doc/manual/development/writing-modules.xml1
-rw-r--r--nixos/doc/manual/release-notes/rl-1703.xml10
9 files changed, 7 insertions, 127 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index de9cfc637ae..4eee41306cd 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -20,8 +20,7 @@ rec {
                 , prefix ? []
                 , # This should only be used for special arguments that need to be evaluated
                   # when resolving module structure (like in imports). For everything else,
-                  # there's _module.args. If specialArgs.modulesPath is defined it will be
-                  # used as the base path for disabledModules.
+                  # there's _module.args.
                   specialArgs ? {}
                 , # This would be remove in the future, Prefer _module.args option instead.
                   args ? {}
@@ -59,7 +58,10 @@ rec {
 
       closed = closeModules (modules ++ [ internalModule ]) ({ inherit config options; lib = import ./.; } // specialArgs);
 
-      options = mergeModules prefix (filterModules (specialArgs.modulesPath or "") closed);
+      # Note: the list of modules is reversed to maintain backward
+      # compatibility with the old module system.  Not sure if this is
+      # the most sensible policy.
+      options = mergeModules prefix (reverseList closed);
 
       # Traverse options and extract the option values into the final
       # config set.  At the same time, check whether all option
@@ -85,16 +87,6 @@ rec {
       result = { inherit options config; };
     in result;
 
-
- # Filter disabled modules. Modules can be disabled allowing
- # their implementation to be replaced.
- filterModules = modulesPath: modules:
-   let
-     moduleKey = m: if isString m then toString modulesPath + "/" + m else toString m;
-     disabledKeys = map moduleKey (concatMap (m: m.disabledModules) modules);
-   in
-     filter (m: !(elem m.key disabledKeys)) modules;
-
   /* Close a set of modules under the ‘imports’ relation. */
   closeModules = modules: args:
     let
@@ -119,13 +111,12 @@ rec {
       else {};
     in
     if m ? config || m ? options then
-      let badAttrs = removeAttrs m ["_file" "key" "disabledModules" "imports" "options" "config" "meta"]; in
+      let badAttrs = removeAttrs m ["imports" "options" "config" "key" "_file" "meta"]; in
       if badAttrs != {} then
         throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by assignments to the top-level attributes `config' or `options'."
       else
         { file = m._file or file;
           key = toString m.key or key;
-          disabledModules = m.disabledModules or [];
           imports = m.imports or [];
           options = m.options or {};
           config = mkMerge [ (m.config or {}) metaSet ];
@@ -133,10 +124,9 @@ rec {
     else
       { file = m._file or file;
         key = toString m.key or key;
-        disabledModules = m.disabledModules or [];
         imports = m.require or [] ++ m.imports or [];
         options = {};
-        config = mkMerge [ (removeAttrs m ["_file" "key" "disabledModules" "require" "imports"]) metaSet ];
+        config = mkMerge [ (removeAttrs m ["key" "_file" "require" "imports"]) metaSet ];
       };
 
   applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh
index ba0c67fb7d4..8b476a5d3dc 100755
--- a/lib/tests/modules.sh
+++ b/lib/tests/modules.sh
@@ -99,14 +99,6 @@ checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-if-foo-enabl
 checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-if-enable.nix
 checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-enable-if.nix
 
-# Check disabledModules with config definitions and option declarations.
-set -- config.enable ./define-enable.nix ./declare-enable.nix
-checkConfigOutput "true" "$@"
-checkConfigOutput "false" "$@" ./disable-define-enable.nix
-checkConfigError "The option .*enable.* defined in .* does not exist" "$@" ./disable-declare-enable.nix
-checkConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-define-enable.nix ./disable-declare-enable.nix
-checkConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-enable-modules.nix
-
 # Check _module.args.
 set -- config.enable ./declare-enable.nix ./define-enable-with-custom-arg.nix
 checkConfigError 'while evaluating the module argument .*custom.* in .*define-enable-with-custom-arg.nix.*:' "$@"
diff --git a/lib/tests/modules/default.nix b/lib/tests/modules/default.nix
index 5b094710419..c5ce9cb3e3b 100644
--- a/lib/tests/modules/default.nix
+++ b/lib/tests/modules/default.nix
@@ -3,6 +3,5 @@
 {
   inherit (lib.evalModules {
     inherit modules;
-    specialArgs.modulesPath = ./.;
   }) config options;
 }
diff --git a/lib/tests/modules/disable-declare-enable.nix b/lib/tests/modules/disable-declare-enable.nix
deleted file mode 100644
index a373ee7e550..00000000000
--- a/lib/tests/modules/disable-declare-enable.nix
+++ /dev/null
@@ -1,5 +0,0 @@
-{ lib, ... }:
-
-{
-  disabledModules = [ ./declare-enable.nix ];
-}
diff --git a/lib/tests/modules/disable-define-enable.nix b/lib/tests/modules/disable-define-enable.nix
deleted file mode 100644
index 0d84a7c3cb6..00000000000
--- a/lib/tests/modules/disable-define-enable.nix
+++ /dev/null
@@ -1,5 +0,0 @@
-{ lib, ... }:
-
-{
-  disabledModules = [ ./define-enable.nix ];
-}
diff --git a/lib/tests/modules/disable-enable-modules.nix b/lib/tests/modules/disable-enable-modules.nix
deleted file mode 100644
index c325f4e0743..00000000000
--- a/lib/tests/modules/disable-enable-modules.nix
+++ /dev/null
@@ -1,5 +0,0 @@
-{ lib, ... }:
-
-{
-  disabledModules = [ "define-enable.nix" "declare-enable.nix" ];
-}
diff --git a/nixos/doc/manual/development/replace-modules.xml b/nixos/doc/manual/development/replace-modules.xml
deleted file mode 100644
index cc0539ec510..00000000000
--- a/nixos/doc/manual/development/replace-modules.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-        xmlns:xlink="http://www.w3.org/1999/xlink"
-        xmlns:xi="http://www.w3.org/2001/XInclude"
-        version="5.0"
-        xml:id="sec-replace-modules">
-
-<title>Replace Modules</title>
-
-<para>Modules that are imported can also be disabled.  The option
-  declarations and config implementation of a disabled module will be
-  ignored, allowing another to take it's place.  This can be used to
-  import a set of modules from another channel while keeping the rest
-  of the system on a stable release.</para>
-<para><literal>disabledModules</literal> is a top level attribute like
-  <literal>imports</literal>, <literal>options</literal> and
-  <literal>config</literal>.  It contains a list of modules that will
-  be disabled. This can either be the full path to the module or a
-  string with the filename relative to the modules path
-  (eg. &lt;nixpkgs/nixos/modules&gt; for nixos).
-  </para>
-
-<para>This example will replace the existing postgresql module with
-  the version defined in the nixos-unstable channel while keeping the
-  rest of the modules and packages from the original nixos channel.
-  This only overrides the module definition, this won't use postgresql
-  from nixos-unstable unless explicitly configured to do so.</para>
-
-<programlisting>
-{ config, lib, pkgs, ... }:
-
-{
-  disabledModules = [ "services/databases/postgresql.nix" ];
-
-  imports =
-    [ # Use postgresql service from nixos-unstable channel.
-      # sudo nix-channel --add http://nixos.org/channels/nixos-unstable nixos-unstable
-      &lt;nixos-unstable/nixos/modules/services/databases/postgresql.nix&gt;
-    ];
-
-  services.postgresql.enable = true;
-}
-</programlisting>
-
-<para>This example shows how to define a custom module as a
-  replacement for an existing module. Importing this module will
-  disable the original module without having to know it's
-  implementation details.</para>
-
-<programlisting>
-{ config, lib, pkgs, ... }:
-
-with lib;
-
-let
-  cfg = config.programs.man;
-in
-
-{
-  disabledModules = [ "services/programs/man.nix" ];
-
-  options = {
-    programs.man.enable = mkOption {
-      type = types.bool;
-      default = true;
-      description = "Whether to enable manual pages.";
-    };
-  };
-
-  config = mkIf cfg.enabled {
-    warnings = [ "disabled manpages for production deployments." ];
-  };
-}
-</programlisting>
-
-</section>
diff --git a/nixos/doc/manual/development/writing-modules.xml b/nixos/doc/manual/development/writing-modules.xml
index 5bdcad5ceb5..ef6920160e6 100644
--- a/nixos/doc/manual/development/writing-modules.xml
+++ b/nixos/doc/manual/development/writing-modules.xml
@@ -179,6 +179,5 @@ in {
 <xi:include href="option-types.xml" />
 <xi:include href="option-def.xml" />
 <xi:include href="meta-attributes.xml" />
-<xi:include href="replace-modules.xml" />
 
 </chapter>
diff --git a/nixos/doc/manual/release-notes/rl-1703.xml b/nixos/doc/manual/release-notes/rl-1703.xml
index cea8b93b075..fda46217144 100644
--- a/nixos/doc/manual/release-notes/rl-1703.xml
+++ b/nixos/doc/manual/release-notes/rl-1703.xml
@@ -263,16 +263,6 @@ following incompatible changes:</para>
 
   <listitem>
     <para>
-      Modules can now be disabled by using <link
-      xlink:href="https://nixos.org/nixpkgs/manual/#sec-replace-modules">
-      disabledModules</link>, allowing another to take it's place.  This can be
-      used to import a set of modules from another channel while keeping the
-      rest of the system on a stable release.
-    </para>
-  </listitem>
-
-  <listitem>
-    <para>
       Python 2.7, 3.5 and 3.6 are now built deterministically and 3.4 mostly.
       Minor modifications had to be made to the interpreters in order to generate
       deterministic bytecode. This has security implications and is relevant for