modules: add support for module replacement with disabledModules

This is based on a prototype Nicolas B. Pierron worked on during a
discussion we had at FOSDEM.

A new version with a workaround for problems of the reverted original.
Discussion: https://github.com/NixOS/nixpkgs/commit/3f2566689
This commit is contained in:
Daiderd Jordan
2017-03-03 13:45:22 +01:00
committed by Vladimír Čunát
parent bb9a37a2a5
commit d88721e440
9 changed files with 127 additions and 7 deletions
+8
View File
@@ -99,6 +99,14 @@ 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.*:' "$@"
+1
View File
@@ -3,5 +3,6 @@
{
inherit (lib.evalModules {
inherit modules;
specialArgs.modulesPath = ./.;
}) config options;
}
@@ -0,0 +1,5 @@
{ lib, ... }:
{
disabledModules = [ ./declare-enable.nix ];
}
@@ -0,0 +1,5 @@
{ lib, ... }:
{
disabledModules = [ ./define-enable.nix ];
}
@@ -0,0 +1,5 @@
{ lib, ... }:
{
disabledModules = [ "define-enable.nix" "declare-enable.nix" ];
}