Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
Shell
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775#!/usr/bin/env bash
# This script is used to test that the module system is working as expected.# Executing it runs tests for `lib.modules`, `lib.options` and `lib.types`.# By default it test the version of nixpkgs which is defined in the NIX_PATH.## Run:# [nixpkgs]$ lib/tests/modules.sh# or:# [nixpkgs]$ nix-build lib/tests/release.nix
set -o errexit -o noclobber -o nounset -o pipefailshopt -s failglob inherit_errexit
# https://stackoverflow.com/a/246128/6605742DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd "$DIR"/modules
pass=0fail=0
local-nix-instantiate() { nix-instantiate --timeout 1 --eval-only --show-trace --read-write-mode --json "$@"}
# loc# prints the location of the call of to the function that calls it# loc n# prints the location n levels up the call stackloc() { local caller depth depth=1 if [[ $# -gt 0 ]]; then depth=$1 fi # ( lineno fnname file ) of the caller caller=( $(caller $depth) ) echo "${caller[2]}:${caller[0]}"}
line() { echo "----------------------------------------"}logStartFailure() { line}logEndFailure() { line echo}
logFailure() { # bold red printf '\033[1;31mTEST FAILED\033[0m at %s\n' "$(loc 2)"}
evalConfig() { local attr=$1 shift local script="import ./default.nix { modules = [ $* ];}" local-nix-instantiate -E "$script" -A "$attr"}
reportFailure() { local attr=$1 shift local script="import ./default.nix { modules = [ $* ];}" echo "$ nix-instantiate -E '$script' -A '$attr' --eval-only --json" evalConfig "$attr" "$@" || true ((++fail))}
checkConfigOutput() { local outputContains=$1 shift if evalConfig "$@" 2>/dev/null | grep -E --silent "$outputContains" ; then ((++pass)) else logStartFailure echo "ACTUAL:" reportFailure "$@" echo "EXPECTED: result matching '$outputContains'" logFailure logEndFailure fi}
invertIfUnset() { gate="$1" shift if [[ -n "${!gate:-}" ]]; then "$@" else ! "$@" fi}
globalErrorLogCheck() { invertIfUnset "REQUIRE_INFINITE_RECURSION_HINT" \ grep -i 'if you get an infinite recursion here' \ <<<"$err" >/dev/null \ || { if [[ -n "${REQUIRE_INFINITE_RECURSION_HINT:-}" ]]; then echo "Unexpected infinite recursion hint" else echo "Expected infinite recursion hint, but none found" fi return 1 }}
checkExpression() { local path=$1 local output { output="$(local-nix-instantiate --strict "$path" 2>&1)" && ((++pass)) } || { logStartFailure echo "$output" ((++fail)) logFailure logEndFailure }}
checkConfigError() { local errorContains=$1 local err="" shift if err="$(evalConfig "$@" 2>&1 >/dev/null)"; then logStartFailure echo "ACTUAL: exit code 0, output:" reportFailure "$@" echo "EXPECTED: non-zero exit code" logFailure logEndFailure else if ! globalErrorLogCheck "$err"; then logStartFailure echo "LOG:" reportFailure "$@" echo "GLOBAL ERROR LOG CHECK FAILED" logFailure logEndFailure fi if echo "$err" | grep -zP --silent "$errorContains" ; then ((++pass)) else logStartFailure echo "ACTUAL:" reportFailure "$@" echo "EXPECTED: error matching '$errorContains'" logFailure logEndFailure fi fi}
# Shorthand meta attribute does not duplicate the configcheckConfigOutput '^"one two"$' config.result ./shorthand-meta.nix
checkConfigOutput '^true$' config.result ./test-mergeAttrDefinitionsWithPrio.nix
# Check that a module argument is passed, also when a default is available# (but not needed)## When the default is needed, we currently fail to do what the users expect, as# we pass our own argument anyway, even if it *turns out* not to exist.## The reason for this is that we don't know at invocation time what is in the# _module.args option. That value is only available *after* all modules have been# invoked.## Hypothetically, Nix could help support this by giving access to the default# values, through a new built-in function.# However the default values are allowed to depend on other arguments, so those# would have to be passed in somehow, making this not just a getter but# something more complicated.## At that point we have to wonder whether the extra complexity is worth the cost.# Another - subjective - reason not to support it is that default values# contradict the notion that an option has a single value, where _module.args# is the option.checkConfigOutput '^true$' config.result ./module-argument-default.nix
# gvariantcheckConfigOutput '^true$' config.assertion ./gvariant.nix
checkConfigOutput '"ok"' config.result ./specialArgs-lib.nix
# https://github.com/NixOS/nixpkgs/pull/131205# We currently throw this error already in `config`, but throwing in `config.wrong1` would be acceptable.checkConfigError 'It seems as if you.re trying to declare an option by placing it into .config. rather than .options.' config.wrong1 ./error-mkOption-in-config.nix# We currently throw this error already in `config`, but throwing in `config.nest.wrong2` would be acceptable.checkConfigError 'It seems as if you.re trying to declare an option by placing it into .config. rather than .options.' config.nest.wrong2 ./error-mkOption-in-config.nixcheckConfigError 'The option .sub.wrong2. does not exist. Definition values:' config.sub ./error-mkOption-in-submodule-config.nixcheckConfigError '.*This can happen if you e.g. declared your options in .types.submodule.' config.sub ./error-mkOption-in-submodule-config.nixcheckConfigError '.*A definition for option .bad. is not of type .non-empty .list of .submodule...\.' config.bad ./error-nonEmptyListOf-submodule.nix
# types.attrTagcheckConfigOutput '^true$' config.okChecks ./types-attrTag.nixcheckConfigError 'A definition for option .intStrings\.syntaxError. is not of type .attribute-tagged union' config.intStrings.syntaxError ./types-attrTag.nixcheckConfigError 'A definition for option .intStrings\.syntaxError2. is not of type .attribute-tagged union' config.intStrings.syntaxError2 ./types-attrTag.nixcheckConfigError 'A definition for option .intStrings\.syntaxError3. is not of type .attribute-tagged union' config.intStrings.syntaxError3 ./types-attrTag.nixcheckConfigError 'A definition for option .intStrings\.syntaxError4. is not of type .attribute-tagged union' config.intStrings.syntaxError4 ./types-attrTag.nixcheckConfigError 'A definition for option .intStrings\.mergeError. is not of type .attribute-tagged union' config.intStrings.mergeError ./types-attrTag.nixcheckConfigError 'A definition for option .intStrings\.badTagError. is not of type .attribute-tagged union' config.intStrings.badTagError ./types-attrTag.nixcheckConfigError 'A definition for option .intStrings\.badTagTypeError\.left. is not of type .signed integer.' config.intStrings.badTagTypeError.left ./types-attrTag.nixcheckConfigError 'A definition for option .nested\.right\.left. is not of type .signed integer.' config.nested.right.left ./types-attrTag.nixcheckConfigError 'In attrTag, each tag value must be an option, but tag int was a bare type, not wrapped in mkOption.' config.opt.int ./types-attrTag-wrong-decl.nix
# types.pathInStorecheckConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nixcheckConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./types.nixcheckConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15/bin/bash"' config.pathInStore.ok3 ./types.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ""' config.pathInStore.bad1 ./types.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store"' config.pathInStore.bad2 ./types.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store/"' config.pathInStore.bad3 ./types.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store/.links"' config.pathInStore.bad4 ./types.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: "/foo/bar"' config.pathInStore.bad5 ./types.nix
# Check boolean option.checkConfigOutput '^false$' config.enable ./declare-enable.nixcheckConfigError 'The option .* does not exist. Definition values:\n\s*- In .*: true' config.enable ./define-enable.nixcheckConfigError 'The option .* does not exist. Definition values:\n\s*- In .*' config.enable ./define-enable-throw.nixcheckConfigError 'while evaluating a definition from `.*/define-enable-abort.nix' config.enable ./define-enable-abort.nixcheckConfigError 'while evaluating the error message for definitions for .enable., which is an option that does not exist' config.enable ./define-enable-abort.nix
# Check boolByOr type.checkConfigOutput '^false$' config.value.falseFalse ./boolByOr.nixcheckConfigOutput '^true$' config.value.trueFalse ./boolByOr.nixcheckConfigOutput '^true$' config.value.falseTrue ./boolByOr.nixcheckConfigOutput '^true$' config.value.trueTrue ./boolByOr.nix
checkConfigOutput '^1$' config.bare-submodule.nested ./declare-bare-submodule.nix ./declare-bare-submodule-nested-option.nixcheckConfigOutput '^2$' config.bare-submodule.deep ./declare-bare-submodule.nix ./declare-bare-submodule-deep-option.nixcheckConfigOutput '^42$' config.bare-submodule.nested ./declare-bare-submodule.nix ./declare-bare-submodule-nested-option.nix ./declare-bare-submodule-deep-option.nix ./define-bare-submodule-values.nixcheckConfigOutput '^420$' config.bare-submodule.deep ./declare-bare-submodule.nix ./declare-bare-submodule-nested-option.nix ./declare-bare-submodule-deep-option.nix ./define-bare-submodule-values.nixcheckConfigOutput '^2$' config.bare-submodule.deep ./declare-bare-submodule.nix ./declare-bare-submodule-deep-option.nix ./define-shorthandOnlyDefinesConfig-true.nixcheckConfigError 'The option .bare-submodule.deep. in .*/declare-bare-submodule-deep-option.nix. is already declared in .*/declare-bare-submodule-deep-option-duplicate.nix' config.bare-submodule.deep ./declare-bare-submodule.nix ./declare-bare-submodule-deep-option.nix ./declare-bare-submodule-deep-option-duplicate.nix
# Check that strMatching can be mergedcheckConfigOutput '^"strMatching.*"$' options.sm.type.name ./strMatching-merge.nix
# Check integer types.# unsignedcheckConfigOutput '^42$' config.value ./declare-int-unsigned-value.nix ./define-value-int-positive.nixcheckConfigError 'A definition for option .* is not of type.*unsigned integer.*. Definition values:\n\s*- In .*: -23' config.value ./declare-int-unsigned-value.nix ./define-value-int-negative.nix# positivecheckConfigError 'A definition for option .* is not of type.*positive integer.*. Definition values:\n\s*- In .*: 0' config.value ./declare-int-positive-value.nix ./define-value-int-zero.nix# betweencheckConfigOutput '^42$' config.value ./declare-int-between-value.nix ./define-value-int-positive.nixcheckConfigError 'A definition for option .* is not of type.*between.*-21 and 43.*inclusive.*. Definition values:\n\s*- In .*: -23' config.value ./declare-int-between-value.nix ./define-value-int-negative.nix
# Check either types# types.eithercheckConfigOutput '^42$' config.value ./declare-either.nix ./define-value-int-positive.nixcheckConfigOutput '^"24"$' config.value ./declare-either.nix ./define-value-string.nix# types.oneOfcheckConfigOutput '^42$' config.value ./declare-oneOf.nix ./define-value-int-positive.nixcheckConfigOutput '^\[\]$' config.value ./declare-oneOf.nix ./define-value-list.nixcheckConfigOutput '^"24"$' config.value ./declare-oneOf.nix ./define-value-string.nix
# Check mkForce without submodules.set -- config.enable ./declare-enable.nix ./define-enable.nixcheckConfigOutput '^true$' "$@"checkConfigOutput '^false$' "$@" ./define-force-enable.nixcheckConfigOutput '^false$' "$@" ./define-enable-force.nix
# Check mkForce with option and submodules.checkConfigError 'attribute .*foo.* .* not found' config.attrsOfSub.foo.enable ./declare-attrsOfSub-any-enable.nixcheckConfigOutput '^false$' config.attrsOfSub.foo.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo.nixset -- config.attrsOfSub.foo.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo-enable.nixcheckConfigOutput '^true$' "$@"checkConfigOutput '^false$' "$@" ./define-force-attrsOfSub-foo-enable.nixcheckConfigOutput '^false$' "$@" ./define-attrsOfSub-force-foo-enable.nixcheckConfigOutput '^false$' "$@" ./define-attrsOfSub-foo-force-enable.nixcheckConfigOutput '^false$' "$@" ./define-attrsOfSub-foo-enable-force.nix
# Check overriding effect of mkForce on submodule definitions.checkConfigError 'attribute .*bar.* .* not found' config.attrsOfSub.bar.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo.nixcheckConfigOutput '^false$' config.attrsOfSub.bar.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo.nix ./define-attrsOfSub-bar.nixset -- config.attrsOfSub.bar.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo.nix ./define-attrsOfSub-bar-enable.nixcheckConfigOutput '^true$' "$@"checkConfigError 'attribute .*bar.* .* not found' "$@" ./define-force-attrsOfSub-foo-enable.nixcheckConfigError 'attribute .*bar.* .* not found' "$@" ./define-attrsOfSub-force-foo-enable.nixcheckConfigOutput '^true$' "$@" ./define-attrsOfSub-foo-force-enable.nixcheckConfigOutput '^true$' "$@" ./define-attrsOfSub-foo-enable-force.nix
# Check mkIf with submodules.checkConfigError 'attribute .*foo.* .* not found' config.attrsOfSub.foo.enable ./declare-enable.nix ./declare-attrsOfSub-any-enable.nixset -- config.attrsOfSub.foo.enable ./declare-enable.nix ./declare-attrsOfSub-any-enable.nixcheckConfigError 'attribute .*foo.* .* not found' "$@" ./define-if-attrsOfSub-foo-enable.nixcheckConfigError 'attribute .*foo.* .* not found' "$@" ./define-attrsOfSub-if-foo-enable.nixcheckConfigError 'attribute .*foo.* .* not found' "$@" ./define-attrsOfSub-foo-if-enable.nixcheckConfigOutput '^false$' "$@" ./define-attrsOfSub-foo-enable-if.nixcheckConfigOutput '^true$' "$@" ./define-enable.nix ./define-if-attrsOfSub-foo-enable.nixcheckConfigOutput '^true$' "$@" ./define-enable.nix ./define-attrsOfSub-if-foo-enable.nixcheckConfigOutput '^true$' "$@" ./define-enable.nix ./define-attrsOfSub-foo-if-enable.nixcheckConfigOutput '^true$' "$@" ./define-enable.nix ./define-attrsOfSub-foo-enable-if.nix
# Check importApplycheckConfigOutput '"abc"' config.value ./importApply.nix# importApply does not set a key.# Disabling the function file is not sufficient, because importApply can't reasonably assume that the key is unique.# e.g. user may call it multiple times with different arguments and expect each of the module to apply.# While this is excusable for the disabledModules aspect, it is not for the deduplication of modules.checkConfigOutput '"abc"' config.value ./importApply-disabling.nix
# Check disabledModules with config definitions and option declarations.set -- config.enable ./define-enable.nix ./declare-enable.nixcheckConfigOutput '^true$' "$@"checkConfigOutput '^false$' "$@" ./disable-define-enable.nixcheckConfigOutput '^false$' "$@" ./disable-define-enable-string-path.nixcheckConfigError "The option .*enable.* does not exist. Definition values:\n\s*- In .*: true" "$@" ./disable-declare-enable.nixcheckConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-define-enable.nix ./disable-declare-enable.nixcheckConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-enable-modules.nix
checkConfigOutput '^true$' 'config.positive.enable' ./disable-module-with-key.nixcheckConfigOutput '^false$' 'config.negative.enable' ./disable-module-with-key.nixcheckConfigError 'Module ..*disable-module-bad-key.nix. contains a disabledModules item that is an attribute set, presumably a module, that does not have a .key. attribute. .*' 'config.enable' ./disable-module-bad-key.nix
# Not sure if we want to keep supporting module keys that aren't strings, paths or v?key, but we shouldn't remove support accidentally.checkConfigOutput '^true$' 'config.positive.enable' ./disable-module-with-toString-key.nixcheckConfigOutput '^false$' 'config.negative.enable' ./disable-module-with-toString-key.nix
# Check _module.args.set -- config.enable ./declare-enable.nix ./define-enable-with-custom-arg.nixcheckConfigError 'while evaluating the module argument .*custom.* in .*define-enable-with-custom-arg.nix.*:' "$@"checkConfigOutput '^true$' "$@" ./define-_module-args-custom.nix
# Check that using _module.args on imports cause infinite recursions, with# the proper error context.set -- "$@" ./define-_module-args-custom.nix ./import-custom-arg.nixREQUIRE_INFINITE_RECURSION_HINT=1 checkConfigError 'while evaluating the module argument .*custom.* in .*import-custom-arg.nix.*:' "$@"REQUIRE_INFINITE_RECURSION_HINT=1 checkConfigError 'infinite recursion encountered' "$@"
# Check _module.check.set -- config.enable ./declare-enable.nix ./define-enable.nix ./define-attrsOfSub-foo.nixcheckConfigError 'The option .* does not exist. Definition values:\n\s*- In .*' "$@"checkConfigOutput '^true$' "$@" ./define-module-check.nix
# Check coerced value.set --checkConfigOutput '^"42"$' config.value ./declare-coerced-value.nixcheckConfigOutput '^"24"$' config.value ./declare-coerced-value.nix ./define-value-string.nixcheckConfigError 'A definition for option .* is not.*string or signed integer convertible to it.*. Definition values:\n\s*- In .*: \[ \]' config.value ./declare-coerced-value.nix ./define-value-list.nix
# Check coerced option merging.checkConfigError 'The option .value. in .*/declare-coerced-value.nix. is already declared in .*/declare-coerced-value-no-default.nix.' config.value ./declare-coerced-value.nix ./declare-coerced-value-no-default.nix
# Check coerced value with unsound coercioncheckConfigOutput '^12$' config.value ./declare-coerced-value-unsound.nixcheckConfigError 'A definition for option .* is not of type .*. Definition values:\n\s*- In .*: "1000"' config.value ./declare-coerced-value-unsound.nix ./define-value-string-bigint.nixcheckConfigError 'toInt: Could not convert .* to int' config.value ./declare-coerced-value-unsound.nix ./define-value-string-arbitrary.nix
# Check `graph` attributecheckExpression './graph/test.nix'
# Check mkAliasOptionModule.checkConfigOutput '^true$' config.enable ./alias-with-priority.nixcheckConfigOutput '^true$' config.enableAlias ./alias-with-priority.nixcheckConfigOutput '^false$' config.enable ./alias-with-priority-can-override.nixcheckConfigOutput '^false$' config.enableAlias ./alias-with-priority-can-override.nix
# Check mkPackageOptioncheckConfigOutput '^"hello"$' config.package.pname ./declare-mkPackageOption.nixcheckConfigOutput '^"hello"$' config.namedPackage.pname ./declare-mkPackageOption.nixcheckConfigOutput '^".*Hello.*"$' options.namedPackage.description ./declare-mkPackageOption.nixcheckConfigOutput '^"literalExpression"$' options.namedPackage.defaultText._type ./declare-mkPackageOption.nixcheckConfigOutput '^"pkgs\.hello"$' options.namedPackage.defaultText.text ./declare-mkPackageOption.nixcheckConfigOutput '^"hello"$' config.namedPackageSingletonDefault.pname ./declare-mkPackageOption.nixcheckConfigOutput '^".*Hello.*"$' options.namedPackageSingletonDefault.description ./declare-mkPackageOption.nixcheckConfigOutput '^"pkgs\.hello"$' options.namedPackageSingletonDefault.defaultText.text ./declare-mkPackageOption.nixcheckConfigOutput '^"hello"$' config.pathPackage.pname ./declare-mkPackageOption.nixcheckConfigOutput '^"literalExpression"$' options.packageWithExample.example._type ./declare-mkPackageOption.nixcheckConfigOutput '^"pkgs\.hello\.override \{ stdenv = pkgs\.clangStdenv; \}"$' options.packageWithExample.example.text ./declare-mkPackageOption.nixcheckConfigOutput '^"literalExpression"$' options.packageWithPathExample.example._type ./declare-mkPackageOption.nixcheckConfigOutput '^"pkgs\.hello"$' options.packageWithPathExample.example.text ./declare-mkPackageOption.nixcheckConfigOutput '^".*Example extra description\..*"$' options.packageWithExtraDescription.description ./declare-mkPackageOption.nixcheckConfigError 'The option .undefinedPackage. was accessed but has no value defined. Try setting the option.' config.undefinedPackage ./declare-mkPackageOption.nixcheckConfigOutput '^null$' config.nullablePackage ./declare-mkPackageOption.nixcheckConfigOutput '^"null or package"$' options.nullablePackage.type.description ./declare-mkPackageOption.nixcheckConfigOutput '^"hello"$' config.nullablePackageWithDefault.pname ./declare-mkPackageOption.nixcheckConfigOutput '^"myPkgs\.hello"$' options.packageWithPkgsText.defaultText.text ./declare-mkPackageOption.nixcheckConfigOutput '^"hello-other"$' options.packageFromOtherSet.default.pname ./declare-mkPackageOption.nixcheckConfigOutput '^"hello"$' config.packageInvalidIdentifier.pname ./declare-mkPackageOption.nixcheckConfigOutput '^"pkgs\.\\"123\\"\.\\"with\\\\\\"quote\\"\.hello"$' options.packageInvalidIdentifier.defaultText.text ./declare-mkPackageOption.nixcheckConfigOutput '^"pkgs\.\\"123\\"\.\\"with\\\\\\"quote\\"\.hello"$' options.packageInvalidIdentifierExample.example.text ./declare-mkPackageOption.nix
# submoduleWith
## specialArgs should workcheckConfigOutput '^"foo"$' config.submodule.foo ./declare-submoduleWith-special.nix
## shorthandOnlyDefines config behaves as expectedcheckConfigOutput '^true$' config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-shorthand.nixcheckConfigError 'is not of type `boolean' config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-noshorthand.nixcheckConfigError "In module ..*define-submoduleWith-shorthand.nix., you're trying to define a value of type \`bool'\n\s*rather than an attribute set for the option" config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-shorthand.nixcheckConfigOutput '^true$' config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-noshorthand.nix
## submoduleWith should merge all modules in one swoopcheckConfigOutput '^true$' config.submodule.inner ./declare-submoduleWith-modules.nixcheckConfigOutput '^true$' config.submodule.outer ./declare-submoduleWith-modules.nix# Should also be able to evaluate the type name (which evaluates freeformType,# which evaluates all the modules defined by the type)checkConfigOutput '^"submodule"$' options.submodule.type.description ./declare-submoduleWith-modules.nix
## submodules can be declared using (evalModules {...}).typecheckConfigOutput '^true$' config.submodule.inner ./declare-submodule-via-evalModules.nixcheckConfigOutput '^true$' config.submodule.outer ./declare-submodule-via-evalModules.nix# Should also be able to evaluate the type name (which evaluates freeformType,# which evaluates all the modules defined by the type)checkConfigOutput '^"submodule"$' options.submodule.type.description ./declare-submodule-via-evalModules.nix
## Paths should be allowed as values and work as expectedcheckConfigOutput '^true$' config.submodule.enable ./declare-submoduleWith-path.nix
## _prefix module argument is available at import time and contains the prefixcheckConfigOutput '^true$' config.foo.ok ./prefix-module-argument.nix
## deferredModule# default module is merged into nodes.foocheckConfigOutput '"beta"' config.nodes.foo.settingsDict.c ./deferred-module.nix# errors from the default module are reported with accurate locationcheckConfigError 'In `the-file-that-contains-the-bad-config.nix, via option default'\'': "bogus"' config.nodes.foo.bottom ./deferred-module.nixcheckConfigError '.*lib/tests/modules/deferred-module-error.nix, via option deferred [(]:anon-1:anon-1:anon-1[)] does not look like a module.' config.result ./deferred-module-error.nix
# Check the file location information is propagated into submodulescheckConfigOutput the-file.nix config.submodule.internalFiles.0 ./submoduleFiles.nix
# Check that disabledModules works recursively and correctlycheckConfigOutput '^true$' config.enable ./disable-recursive/main.nixcheckConfigOutput '^true$' config.enable ./disable-recursive/{main.nix,disable-foo.nix}checkConfigOutput '^true$' config.enable ./disable-recursive/{main.nix,disable-bar.nix}checkConfigError 'The option .* does not exist. Definition values:\n\s*- In .*: true' config.enable ./disable-recursive/{main.nix,disable-foo.nix,disable-bar.nix}
# Check that imports can depend on derivationscheckConfigOutput '^true$' config.enable ./import-from-store.nix
# Check that configs can be conditional on option existencecheckConfigOutput '^true$' config.enable ./define-option-dependently.nix ./declare-enable.nix ./declare-int-positive-value.nixcheckConfigOutput '^360$' config.value ./define-option-dependently.nix ./declare-enable.nix ./declare-int-positive-value.nixcheckConfigOutput '^7$' config.value ./define-option-dependently.nix ./declare-int-positive-value.nixcheckConfigOutput '^true$' config.set.enable ./define-option-dependently-nested.nix ./declare-enable-nested.nix ./declare-int-positive-value-nested.nixcheckConfigOutput '^360$' config.set.value ./define-option-dependently-nested.nix ./declare-enable-nested.nix ./declare-int-positive-value-nested.nixcheckConfigOutput '^7$' config.set.value ./define-option-dependently-nested.nix ./declare-int-positive-value-nested.nix
# Check attrsOf and lazyAttrsOf. Only lazyAttrsOf should be lazy, and only# attrsOf should work with conditional definitions# In addition, lazyAttrsOf should honor an options emptyValuecheckConfigError "is not lazy" config.isLazy ./declare-attrsOf.nix ./attrsOf-lazy-check.nixcheckConfigOutput '^true$' config.isLazy ./declare-lazyAttrsOf.nix ./attrsOf-lazy-check.nixcheckConfigOutput '^true$' config.conditionalWorks ./declare-attrsOf.nix ./attrsOf-conditional-check.nixcheckConfigOutput '^false$' config.conditionalWorks ./declare-lazyAttrsOf.nix ./attrsOf-conditional-check.nixcheckConfigOutput '^"empty"$' config.value.foo ./declare-lazyAttrsOf.nix ./attrsOf-conditional-check.nix
# Check attrsWith type mergingcheckConfigError 'The option `mergedLazyNonLazy'\'' in `.*'\'' is already declared in `.*'\''\.' options.mergedLazyNonLazy ./lazy-attrsWith.nixcheckConfigOutput '^11$' config.lazyResult ./lazy-attrsWith.nixcheckConfigError 'infinite recursion encountered' config.nonLazyResult ./lazy-attrsWith.nix
# AttrsWith placeholder testscheckConfigOutput '^"mergedName.<id>.nested"$' config.result ./name-merge-attrsWith-1.nixcheckConfigError 'The option .mergedName. in .*\.nix. is already declared in .*\.nix' config.mergedName ./name-merge-attrsWith-2.nix
# Test type.functor.wrapped deprecation warning# should emit the warning on:# - merged types# - non-merged types# - nestedTypes elemType# attrsWithNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.attrsWith.type.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedAttrsWith.type.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.attrsWith.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedAttrsWith.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix# listOfNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.listOf.type.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedListOf.type.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.listOf.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedListOf.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix# unique / uniqNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.unique.type.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedUnique.type.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.unique.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedUnique.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix# nullOrNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.nullOr.type.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedNullOr.type.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.nullOr.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedNullOr.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix# functionToNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.functionTo.type.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedFunctionTo.type.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.functionTo.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedFunctionTo.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix
# coercedTo# Note: test 'nestedTypes.finalType' and 'nestedTypes.coercedType'NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.coercedTo.type.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.coercedTo.type.nestedTypes.finalType.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.coercedTo.type.nestedTypes.coercedType.functor.wrapped ./deprecated-wrapped.nix# eitherNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.either.type.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedEither.type.functor.wrapped ./deprecated-wrapped.nix
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.either.type.nestedTypes.left.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.either.type.nestedTypes.right.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedEither.type.nestedTypes.left.functor.wrapped ./deprecated-wrapped.nixNIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedEither.type.nestedTypes.right.functor.wrapped ./deprecated-wrapped.nix
# Even with multiple assignments, a type error should be thrown if any of them aren't validcheckConfigError 'A definition for option .* is not of type .*' \ config.value ./declare-int-unsigned-value.nix ./define-value-list.nix ./define-value-int-positive.nix
## Freeform modules# Assigning without a declared option should workcheckConfigOutput '^"24"$' config.value ./freeform-attrsOf.nix ./define-value-string.nix# Shorthand modules interpret `meta` and `class` as config itemscheckConfigOutput '^true$' options._module.args.value.result ./freeform-attrsOf.nix ./define-freeform-keywords-shorthand.nix# No freeform assignments shouldn't make it errorcheckConfigOutput '^{}$' config ./freeform-attrsOf.nix# but only if the type matchescheckConfigError 'A definition for option .* is not of type .*' config.value ./freeform-attrsOf.nix ./define-value-list.nix# and properties should be appliedcheckConfigOutput '^"yes"$' config.value ./freeform-attrsOf.nix ./define-value-string-properties.nix# Options should still be declarable, and be able to have a type that doesn't match the freeform typecheckConfigOutput '^false$' config.enable ./freeform-attrsOf.nix ./define-value-string.nix ./declare-enable.nixcheckConfigOutput '^"24"$' config.value ./freeform-attrsOf.nix ./define-value-string.nix ./declare-enable.nix# and this should work too with nested valuescheckConfigOutput '^false$' config.nest.foo ./freeform-attrsOf.nix ./freeform-nested.nixcheckConfigOutput '^"bar"$' config.nest.bar ./freeform-attrsOf.nix ./freeform-nested.nix# Check whether a declared option can depend on an freeform-typed onecheckConfigOutput '^null$' config.foo ./freeform-attrsOf.nix ./freeform-str-dep-unstr.nixcheckConfigOutput '^"24"$' config.foo ./freeform-attrsOf.nix ./freeform-str-dep-unstr.nix ./define-value-string.nix# Check whether an freeform-typed value can depend on a declared option, this can only work with lazyAttrsOfREQUIRE_INFINITE_RECURSION_HINT=1 checkConfigError 'infinite recursion encountered' config.foo ./freeform-attrsOf.nix ./freeform-unstr-dep-str.nixcheckConfigError 'The option .* was accessed but has no value defined. Try setting the option.' config.foo ./freeform-lazyAttrsOf.nix ./freeform-unstr-dep-str.nixcheckConfigOutput '^"24"$' config.foo ./freeform-lazyAttrsOf.nix ./freeform-unstr-dep-str.nix ./define-value-string.nix# submodules in freeformTypes should have their locations annotatedcheckConfigOutput '/freeform-submodules.nix"$' config.fooDeclarations.0 ./freeform-submodules.nix# freeformTypes can get merged using `types.type`, including submodulescheckConfigOutput '^10$' config.free.xxx.foo ./freeform-submodules.nixcheckConfigOutput '^10$' config.free.yyy.bar ./freeform-submodules.nix
## types.anything# Check that attribute sets are merged recursivelycheckConfigOutput '^null$' config.value.foo ./types-anything/nested-attrs.nixcheckConfigOutput '^null$' config.value.l1.foo ./types-anything/nested-attrs.nixcheckConfigOutput '^null$' config.value.l1.l2.foo ./types-anything/nested-attrs.nixcheckConfigOutput '^null$' config.value.l1.l2.l3.foo ./types-anything/nested-attrs.nix# Attribute sets that are coercible to strings shouldn't be recursed intocheckConfigOutput '^"foo"$' config.value.outPath ./types-anything/attrs-coercible.nix# Multiple lists aren't concatenated together if their definitions are not equalcheckConfigError 'The option .* has conflicting definition values' config.value ./types-anything/lists.nix# Check that all equalizable atoms can be used as long as all definitions are equalcheckConfigOutput '^0$' config.value.int ./types-anything/equal-atoms.nixcheckConfigOutput '^false$' config.value.bool ./types-anything/equal-atoms.nixcheckConfigOutput '^""$' config.value.string ./types-anything/equal-atoms.nixcheckConfigOutput '^"/[^"]+"$' config.value.path ./types-anything/equal-atoms.nixcheckConfigOutput '^null$' config.value.null ./types-anything/equal-atoms.nixcheckConfigOutput '^0.1$' config.value.float ./types-anything/equal-atoms.nixcheckConfigOutput '^\[1,"a",{"x":null}\]$' config.value.list ./types-anything/equal-atoms.nix# Functions can't be merged togethercheckConfigError "The option .value.multiple-lambdas.<function body>. has conflicting option types" config.applied.multiple-lambdas ./types-anything/functions.nixcheckConfigOutput '^true$' config.valueIsFunction.single-lambda ./types-anything/functions.nixcheckConfigOutput '^null$' config.applied.merging-lambdas.x ./types-anything/functions.nixcheckConfigOutput '^null$' config.applied.merging-lambdas.y ./types-anything/functions.nix# Check that all mk* modifiers are appliedcheckConfigError 'attribute .* not found' config.value.mkiffalse ./types-anything/mk-mods.nixcheckConfigOutput '^{}$' config.value.mkiftrue ./types-anything/mk-mods.nixcheckConfigOutput '^1$' config.value.mkdefault ./types-anything/mk-mods.nixcheckConfigOutput '^{}$' config.value.mkmerge ./types-anything/mk-mods.nixcheckConfigOutput '^true$' config.value.mkbefore ./types-anything/mk-mods.nixcheckConfigOutput '^1$' config.value.nested.foo ./types-anything/mk-mods.nixcheckConfigOutput '^"baz"$' config.value.nested.bar.baz ./types-anything/mk-mods.nix
## types.functionTocheckConfigOutput '^"input is input"$' config.result ./functionTo/trivial.nixcheckConfigOutput '^"a b"$' config.result ./functionTo/merging-list.nixcheckConfigError 'A definition for option .fun.<function body>. is not of type .string.. Definition values:\n\s*- In .*wrong-type.nix' config.result ./functionTo/wrong-type.nixcheckConfigOutput '^"b a"$' config.result ./functionTo/list-order.nixcheckConfigOutput '^"a c"$' config.result ./functionTo/merging-attrs.nixcheckConfigOutput '^"a bee"$' config.result ./functionTo/submodule-options.nixcheckConfigOutput '^"fun.<function body>.a fun.<function body>.b"$' config.optionsResult ./functionTo/submodule-options.nix
# moduleTypecheckConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nixcheckConfigOutput '^"a b y z"$' config.resultFooBar ./declare-variants.nix ./define-variant.nixcheckConfigOutput '^"a b c"$' config.resultFooFoo ./declare-variants.nix ./define-variant.nix
## emptyValue'scheckConfigOutput "\[\]" config.list.a ./emptyValues.nixcheckConfigOutput "{}" config.attrs.a ./emptyValues.nixcheckConfigOutput "null" config.null.a ./emptyValues.nixcheckConfigOutput "{}" config.submodule.a ./emptyValues.nix# These types don't have empty valuescheckConfigError 'The option .int.a. was accessed but has no value defined. Try setting the option.' config.int.a ./emptyValues.nixcheckConfigError 'The option .nonEmptyList.a. was accessed but has no value defined. Try setting the option.' config.nonEmptyList.a ./emptyValues.nix
# types.unique# requires a single definitioncheckConfigError 'The option .examples\.merged. is defined multiple times while it.s expected to be unique' config.examples.merged.a ./types-unique.nix# user message is printedcheckConfigError 'We require a single definition, because seeing the whole value at once helps us maintain critical invariants of our system.' config.examples.merged.a ./types-unique.nix# let the inner merge function check the values (on demand)checkConfigError 'A definition for option .examples\.badLazyType\.a. is not of type .string.' config.examples.badLazyType.a ./types-unique.nix# overriding still works (unlike option uniqueness)checkConfigOutput '^"bee"$' config.examples.override.b ./types-unique.nix
## types.rawcheckConfigOutput '^true$' config.unprocessedNestingEvaluates.success ./raw.nixcheckConfigOutput "10" config.processedToplevel ./raw.nixcheckConfigError "The option .multiple. is defined multiple times" config.multiple ./raw.nixcheckConfigOutput "bar" config.priorities ./raw.nix
## Option collisioncheckConfigError \ 'The option .set. in module .*/declare-set.nix. would be a parent of the following options, but its type .attribute set of signed integer. does not support nested options.\n\s*- option[(]s[)] with prefix .set.enable. in module .*/declare-enable-nested.nix.' \ config.set \ ./declare-set.nix ./declare-enable-nested.nix
# Options: accidental use of an option-type instead of option (or other tagged type; unlikely)checkConfigError 'In module .*/options-type-error-typical.nix: expected an option declaration at option path .result. but got an attribute set with type option-type' config.result ./options-type-error-typical.nixcheckConfigError 'In module .*/options-type-error-typical-nested.nix: expected an option declaration at option path .result.here. but got an attribute set with type option-type' config.result.here ./options-type-error-typical-nested.nixcheckConfigError 'In module .*/options-type-error-configuration.nix: expected an option declaration at option path .result. but got an attribute set with type configuration' config.result ./options-type-error-configuration.nix
# Check that that merging of option collisions doesn't depend on type being setcheckConfigError 'The option .group..*would be a parent of the following options, but its type .<no description>. does not support nested options.\n\s*- option.s. with prefix .group.enable..*' config.group.enable ./merge-typeless-option.nix
# Test that types.optionType merges types correctlycheckConfigOutput '^10$' config.theOption.int ./optionTypeMerging.nixcheckConfigOutput '^"hello"$' config.theOption.str ./optionTypeMerging.nix
# Test that types.optionType correctly annotates option locationscheckConfigError 'The option .theOption.nested. in .other.nix. is already declared in .optionTypeFile.nix.' config.theOption.nested ./optionTypeFile.nix
# Test that types.optionType leaves types untouched as long as they don't need to be mergedcheckConfigOutput 'ok' config.freeformItems.foo.bar ./adhoc-freeformType-survives-type-merge.nix
# Test that specifying both functor.wrapped and functor.payload isn't allowedcheckConfigError 'Type foo defines both `functor.payload` and `functor.wrapped` at the same time, which is not supported.' config.result ./default-type-merge-both.nix
# Anonymous submodules don't get nixed by import resolution/deduplication# because of an `extendModules` bug, issue 168767.checkConfigOutput '^1$' config.sub.specialisation.value ./extendModules-168767-imports.nix
# Class checks, evalModulescheckConfigOutput '^{}$' config.ok.config ./class-check.nixcheckConfigOutput '"nixos"' config.ok.class ./class-check.nixcheckConfigError 'The module `.*/module-class-is-darwin.nix`.*?expects class "nixos".' config.fail.config ./class-check.nixcheckConfigError 'The module `foo.nix#darwinModules.default`.*?expects class "nixos".' config.fail-anon.config ./class-check.nix
# Class checks, submoduleWithcheckConfigOutput '^{}$' config.sub.nixosOk ./class-check.nixcheckConfigError 'The module `.*/module-class-is-darwin.nix`.*?expects class "nixos".' config.sub.nixosFail.config ./class-check.nix
# submoduleWith type merge with different classcheckConfigError 'A submoduleWith option is declared multiple times with conflicting class values "darwin" and "nixos".' config.sub.mergeFail.config ./class-check.nix
# _type checkcheckConfigError 'Expected a module, but found a value of type .*"flake".*, while trying to load a module into .*/module-imports-_type-check.nix' config.ok.config ./module-imports-_type-check.nixcheckConfigOutput '^true$' config.enable ./declare-enable.nix ./define-enable-with-top-level-mkIf.nixcheckConfigError 'Expected a module, but found a value of type .*"configuration".*, while trying to load a module into .*/import-configuration.nix.' config ./import-configuration.nixcheckConfigError 'please only import the modules that make up the configuration' config ./import-configuration.nixcheckConfigError 'Expected a module, but found a value of type "configuration", while trying to load a module into .*/import-error-submodule.nix, while trying to load a module into .*foo.*\.' config.foo ./import-error-submodule.nix
# doRename works when `warnings` does not exist.checkConfigOutput '^1234$' config.c.d.e ./doRename-basic.nix# doRename adds a warning.checkConfigOutput '^"The option `a\.b. defined in `.*/doRename-warnings\.nix. has been renamed to `c\.d\.e.\."$' \ config.result \ ./doRename-warnings.nixcheckConfigOutput "^true$" config.result ./doRename-condition.nix ./doRename-condition-enable.nixcheckConfigOutput "^true$" config.result ./doRename-condition.nix ./doRename-condition-no-enable.nixcheckConfigOutput "^true$" config.result ./doRename-condition.nix ./doRename-condition-migrated.nix
# Anonymous modules get deduplicated by keycheckConfigOutput '^"pear"$' config.once.raw ./merge-module-with-key.nixcheckConfigOutput '^"pear\\npear"$' config.twice.raw ./merge-module-with-key.nix
# Declaration positions# Line should be present for direct optionscheckConfigOutput '^14$' options.imported.line14.declarationPositions.0.line ./declaration-positions.nixcheckConfigOutput '/declaration-positions.nix"$' options.imported.line14.declarationPositions.0.file ./declaration-positions.nix# Generated options may not have line numbers but they will at least get the# right filecheckConfigOutput '/declaration-positions.nix"$' options.generated.line22.declarationPositions.0.file ./declaration-positions.nixcheckConfigOutput '^null$' options.generated.line22.declarationPositions.0.line ./declaration-positions.nix# Submodules don't break itcheckConfigOutput '^45$' config.submoduleLine38.submodDeclLine45.0.line ./declaration-positions.nixcheckConfigOutput '/declaration-positions.nix"$' config.submoduleLine38.submodDeclLine45.0.file ./declaration-positions.nix# New options under freeform submodules get collected into the parent submodule# (consistent with .declarations behaviour, but weird; notably appears in system.build)checkConfigOutput '^38|27$' options.submoduleLine38.declarationPositions.0.line ./declaration-positions.nixcheckConfigOutput '^38|27$' options.submoduleLine38.declarationPositions.1.line ./declaration-positions.nix# nested options workcheckConfigOutput '^34$' options.nested.nestedLine34.declarationPositions.0.line ./declaration-positions.nix
# types.pathWith { inStore = true; }checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./pathWith.nixcheckConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./pathWith.nixcheckConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15/bin/bash"' config.pathInStore.ok3 ./pathWith.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ""' config.pathInStore.bad1 ./pathWith.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store"' config.pathInStore.bad2 ./pathWith.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store/"' config.pathInStore.bad3 ./pathWith.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: ".*/store/.links"' config.pathInStore.bad4 ./pathWith.nixcheckConfigError 'A definition for option .* is not of type .path in the Nix store.. Definition values:\n\s*- In .*: "/foo/bar"' config.pathInStore.bad5 ./pathWith.nix
# types.pathWith { inStore = false; }checkConfigOutput '"/foo/bar"' config.pathNotInStore.ok1 ./pathWith.nixcheckConfigOutput '".*/store"' config.pathNotInStore.ok2 ./pathWith.nixcheckConfigOutput '".*/store/"' config.pathNotInStore.ok3 ./pathWith.nixcheckConfigOutput '""' config.pathNotInStore.ok4 ./pathWith.nixcheckConfigOutput '".*/store/.links"' config.pathNotInStore.ok5 ./pathWith.nixcheckConfigError 'A definition for option .* is not of type .path not in the Nix store.. Definition values:\n\s*- In .*: ".*/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathNotInStore.bad1 ./pathWith.nixcheckConfigError 'A definition for option .* is not of type .path not in the Nix store.. Definition values:\n\s*- In .*: ".*/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathNotInStore.bad2 ./pathWith.nixcheckConfigError 'A definition for option .* is not of type .path not in the Nix store.. Definition values:\n\s*- In .*: ".*/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15/bin/bash"' config.pathNotInStore.bad3 ./pathWith.nixcheckConfigError 'A definition for option .* is not of type .path not in the Nix store.. Definition values:\n\s*- In .*: .*/pathWith.nix' config.pathNotInStore.bad4 ./pathWith.nix
# types.pathWith { }checkConfigOutput '"/this/is/absolute"' config.anyPath.ok1 ./pathWith.nixcheckConfigOutput '"./this/is/relative"' config.anyPath.ok2 ./pathWith.nixcheckConfigError 'A definition for option .anyPath.bad1. is not of type .path.' config.anyPath.bad1 ./pathWith.nix
# types.pathWith { absolute = true; }checkConfigOutput '"/this/is/absolute"' config.absolutePathNotInStore.ok1 ./pathWith.nixcheckConfigError 'A definition for option .absolutePathNotInStore.bad1. is not of type .absolute path not in the Nix store.' config.absolutePathNotInStore.bad1 ./pathWith.nixcheckConfigError 'A definition for option .absolutePathNotInStore.bad2. is not of type .absolute path not in the Nix store.' config.absolutePathNotInStore.bad2 ./pathWith.nix
# types.pathWith failed type mergecheckConfigError 'The option .conflictingPathOptionType. in .*/pathWith.nix. is already declared in .*/pathWith.nix' config.conflictingPathOptionType ./pathWith.nix
# types.pathWith { inStore = true; absolute = false; }checkConfigError 'In pathWith, inStore means the path must be absolute' config.impossiblePathOptionType ./pathWith.nix
# mkDefinition# check that mkDefinition 'file' is printed in the error messagecheckConfigError 'Cannot merge definitions.*\n\s*- In .file.*\n\s*- In .other.*' config.conflict ./mkDefinition.nixcheckConfigError 'A definition for option .viaOptionDefault. is not of type .boolean.*' config.viaOptionDefault ./mkDefinition.nixcheckConfigOutput '^true$' config.viaConfig ./mkDefinition.nixcheckConfigOutput '^true$' config.mkMerge ./mkDefinition.nixcheckConfigOutput '^true$' config.mkForce ./mkDefinition.nix
# specialArgs._classcheckConfigOutput '"nixos"' config.nixos.config.foo ./specialArgs-class.nixcheckConfigOutput '"bar"' config.conditionalImportAsNixos.config.foo ./specialArgs-class.nixcheckConfigError 'attribute .*bar.* not found' config.conditionalImportAsNixos.config.bar ./specialArgs-class.nixcheckConfigError 'attribute .*foo.* not found' config.conditionalImportAsDarwin.config.foo ./specialArgs-class.nixcheckConfigOutput '"foo"' config.conditionalImportAsDarwin.config.bar ./specialArgs-class.nixcheckConfigOutput '"nixos"' config.sub.nixos.foo ./specialArgs-class.nixcheckConfigOutput '"bar"' config.sub.conditionalImportAsNixos.foo ./specialArgs-class.nixcheckConfigError 'attribute .*bar.* not found' config.sub.conditionalImportAsNixos.bar ./specialArgs-class.nixcheckConfigError 'attribute .*foo.* not found' config.sub.conditionalImportAsDarwin.foo ./specialArgs-class.nixcheckConfigOutput '"foo"' config.sub.conditionalImportAsDarwin.bar ./specialArgs-class.nix
cat <<EOF====== module tests ======$pass Pass$fail FailEOF
if [ "$fail" -ne 0 ]; then exit 1fiexit 0