From 84b1b017026bb1d0a37a8d3ef553f073225b4e8d Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 10 Apr 2023 17:26:25 +0200 Subject: lib/modules: Only interpret class declaration in non-shorthand mode This is to avoid stealing keys from submodules. `class` might be common enough that reinterpreting existing `class` attributes in configurations as a declaration leads to fairly widespread problems. --- lib/tests/modules/class-check.nix | 1 + lib/tests/modules/define-freeform-keywords-shorthand.nix | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 lib/tests/modules/define-freeform-keywords-shorthand.nix (limited to 'lib/tests/modules') diff --git a/lib/tests/modules/class-check.nix b/lib/tests/modules/class-check.nix index 6e02f8c30920..f492c844abfb 100644 --- a/lib/tests/modules/class-check.nix +++ b/lib/tests/modules/class-check.nix @@ -25,6 +25,7 @@ ./module-class-is-nixos.nix { _file = "foo.nix#darwinModules.default"; class = "darwin"; + config = {}; imports = []; } ]; diff --git a/lib/tests/modules/define-freeform-keywords-shorthand.nix b/lib/tests/modules/define-freeform-keywords-shorthand.nix new file mode 100644 index 000000000000..8de1ec6a7475 --- /dev/null +++ b/lib/tests/modules/define-freeform-keywords-shorthand.nix @@ -0,0 +1,15 @@ +{ config, ... }: { + class = { "just" = "data"; }; + a = "one"; + b = "two"; + meta = "meta"; + + _module.args.result = + let r = builtins.removeAttrs config [ "_module" ]; + in builtins.trace (builtins.deepSeq r r) (r == { + a = "one"; + b = "two"; + class = { "just" = "data"; }; + meta = "meta"; + }); +} -- cgit 1.4.1