From a8d0d315de94b4e41041d100bdb66ec96b5d7527 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Tue, 18 Mar 2025 17:01:57 +0000 Subject: [PATCH] Revert "lib/modules: disallow setting config, options in specialArgs of evalModules" --- lib/modules.nix | 3 --- lib/tests/modules.sh | 3 --- lib/tests/modules/specialArgs-config.nix | 18 ------------------ lib/tests/modules/specialArgs-options.nix | 18 ------------------ 4 files changed, 42 deletions(-) delete mode 100644 lib/tests/modules/specialArgs-config.nix delete mode 100644 lib/tests/modules/specialArgs-options.nix diff --git a/lib/modules.nix b/lib/modules.nix index ef6a2339895a..935ef4baabad 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -5,7 +5,6 @@ let addErrorContext all any - assertMsg attrByPath attrNames catAttrs @@ -102,8 +101,6 @@ let , # This would be remove in the future, Prefer _module.check option instead. check ? true }: - assert assertMsg (!specialArgs?config) "Do not set config in the specialArgs argument to evalModules."; - assert assertMsg (!specialArgs?options) "Do not set options in the specialArgs argument to evalModules."; let withWarnings = x: warnIf (evalModulesArgs?args) "The args argument to evalModules is deprecated. Please set config._module.args instead." diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 60f7536d0d43..1505782547f5 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -137,9 +137,6 @@ checkConfigOutput '^true$' config.result ./module-argument-default.nix # gvariant checkConfigOutput '^true$' config.assertion ./gvariant.nix -# specialArgs checks for evalModules -checkConfigError 'Do not set config in the specialArgs argument to evalModules\.' config.fail.config ./specialArgs-config.nix -checkConfigError 'Do not set options in the specialArgs argument to evalModules\.' config.fail.config ./specialArgs-options.nix checkConfigOutput '"ok"' config.result ./specialArgs-lib.nix # https://github.com/NixOS/nixpkgs/pull/131205 diff --git a/lib/tests/modules/specialArgs-config.nix b/lib/tests/modules/specialArgs-config.nix deleted file mode 100644 index a392a870a1ee..000000000000 --- a/lib/tests/modules/specialArgs-config.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ lib, ... }: -{ - config = { - _module.freeformType = lib.types.anything; - - fail = lib.evalModules { - specialArgs = { - config = { }; - }; - modules = [ - { - options.a = lib.mkEnableOption "a"; - config.a = true; - } - ]; - }; - }; -} diff --git a/lib/tests/modules/specialArgs-options.nix b/lib/tests/modules/specialArgs-options.nix deleted file mode 100644 index 1a84770c9ef6..000000000000 --- a/lib/tests/modules/specialArgs-options.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ lib, ... }: -{ - config = { - _module.freeformType = lib.types.anything; - - fail = lib.evalModules { - specialArgs = { - options = { }; - }; - modules = [ - { - options.a = lib.mkEnableOption "a"; - config.a = true; - } - ]; - }; - }; -}