From 17c056fa24cd332e064e561f7b3950fe22214120 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Fri, 3 Apr 2026 10:53:47 +0200 Subject: [PATCH] lib.types.optionDeclaration: test error --- lib/tests/modules.sh | 1 + lib/tests/modules/option.nix | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index f567c33d8d98..87b335a742d6 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -706,6 +706,7 @@ checkConfigError 'The option .group..*would be a parent of the following options # types.optionDeclaration checkConfigOutput '^10$' config.anOption ./option.nix +checkConfigError 'A definition for option .aBadOptionDef. is not of type .option declaration.' config.aBadOptionDef ./option.nix # Test that types.optionType merges types correctly checkConfigOutput '^10$' config.theOption.int ./optionTypeMerging.nix diff --git a/lib/tests/modules/option.nix b/lib/tests/modules/option.nix index 8bc992e987c9..43cef14aee2b 100644 --- a/lib/tests/modules/option.nix +++ b/lib/tests/modules/option.nix @@ -1,15 +1,27 @@ -{ config, lib, ... }: +{ + config, + lib, + options, + ... +}: { options = { theOption = lib.mkOption { type = lib.types.optionDeclaration; }; anOption = config.theOption; + aBadOptionDef = lib.mkOption { + type = lib.types.optionDeclaration; + description = '' + This option is perfectly fine, but will have a bad definition. + ''; + }; }; config = { theOption = lib.mkOption { type = lib.types.int; }; anOption = 10; + aBadOptionDef = options.theOption; # Not a declaration }; }