From 665344f14839ea286a7aeb329fbf4f44da268ce4 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 2 Aug 2021 21:42:45 +0200 Subject: [PATCH] lib/types: Introduce types.raw for unprocessed values --- lib/tests/modules.sh | 6 ++++ lib/tests/modules/raw.nix | 30 +++++++++++++++++++ lib/types.nix | 7 +++++ .../development/option-types.section.md | 11 +++++++ .../development/option-types.section.xml | 19 ++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 lib/tests/modules/raw.nix diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 88d152d39352..a1c592cf4ef0 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -293,6 +293,12 @@ checkConfigOutput "{ }" config.submodule.a ./emptyValues.nix checkConfigError 'The option .int.a. is used but not defined' config.int.a ./emptyValues.nix checkConfigError 'The option .nonEmptyList.a. is used but not defined' config.nonEmptyList.a ./emptyValues.nix +## types.raw +checkConfigOutput "{ foo = ; }" config.unprocessedNesting ./raw.nix +checkConfigOutput "10" config.processedToplevel ./raw.nix +checkConfigError "The option .multiple. is defined multiple times" config.multiple ./raw.nix +checkConfigOutput "bar" config.priorities ./raw.nix + cat < + + + types.raw + + + + A type which doesn’t do any checking, merging or nested + evaluation. It accepts a single arbitrary value that is not + recursed into, making it useful for values coming from + outside the module system, such as package sets or arbitrary + data. Options of this type are still evaluated according to + priorities and conditionals, so mkForce, + mkIf and co. still work on the option + value itself, but not for any value nested within it. This + type should only be used when checking, merging and nested + evaluation are not desirable. + + + types.attrs