about summary refs log tree commit diff
path: root/lib/tests/modules.sh
AgeCommit message (Collapse)AuthorFilesLines
2022-11-03lib/tests/modules: Test doRenameRobert Hensing1-0/+7
2022-10-23lib/strings: Update docs and restructured code to improve readability of ↵Jacob Abel1-1/+1
toInt and toIntBase10.
2022-10-23lib/strings: Refactor toInt into toInt and toIntBase10Jacob Abel1-1/+1
2022-10-23lib/strings: Update toInt to handle intermixed ws and zeros. Added testsJacob Abel1-1/+1
2022-10-07lib/types: always use `<function body>` instead of `[function body]` to ↵Maximilian Bosch1-2/+2
indicate a function inside an option structure The motivation is to have a single identifier for that. Useful for the next commit where I'll try to escape option-parts correctly (options can be any kind of strings, but unless these are Nix identifiers, they must be quoted). Since `<function body>` (or `<name>`/`*`) are special identifiers in error messages and the manual, we need a unique way to mark an option part as function call because these are not to be quoted.
2022-09-21lib/modules: Fix meta duplication in shorthand syntaxRobert Hensing1-0/+3
2022-08-31lib.modules: support strings with absolute paths in `disabledModules`Erik Arvstedt1-0/+1
This is particularly useful for disabling modules defined in a flake. Example: disabledModules = [ "${flake}/modules/mymodule.nix" ]; Previously, absolute string paths were internally prepended with `modulesPath`, which caused the module filtering to fail.
2022-06-14lib/modules: Throw earlier when module function does not return attrsRobert Hensing1-0/+1
`m` must always be an attrset at this point. It is basically always evaluated. This will make it throw when any of the attrs is accessed, rather than just `config`. We assume that this will improve the error message in more scenarios.
2022-06-14lib.types.deferredModule: Improve reported locationRobert Hensing1-1/+1
2022-06-14lib/test/modules.sh: Test deferredModule error location fileRobert Hensing1-1/+4
2022-06-14lib.types: Add deferredModuleRobert Hensing1-0/+3
2022-06-14lib/tests: Add submodule file propagation testSilvan Mosberger1-0/+4
2022-05-17Merge pull request #172813 from hercules-ci/functionTo-properlyRobert Hensing1-0/+2
`lib.types.functionTo` type merging and docs
2022-05-13lib/tests/modules: Test functionTo submodule merging tooRobert Hensing1-1/+2
2022-05-13lib.types.functionTo: Support type mergingRobert Hensing1-0/+1
2022-05-02lib/tests/modules.sh: Fix for singular type descriptionsRobert Hensing1-1/+1
2022-04-24lib.types.submoduleWith: Avoid _key collisions after extendModulesRobert Hensing1-1/+5
2022-03-16Merge pull request #156533 from ↵Silvan Mosberger1-0/+13
hercules-ci/issue-146882-transparent-submodule-options lib.modules: Let module declare options directly in bare submodule
2022-03-10lib.types.optionType: Only merge when necessaryRobert Hensing1-0/+3
2022-03-07lib/tests/modules: Add test case for duplicate option error file locationRobert Hensing1-0/+1
2022-03-03lib.modules: Make option injection work when shorthandOnlyDefinesConfigRobert Hensing1-0/+1
2022-03-03lib.modules: Improve option-is-prefix error messageRobert Hensing1-0/+6
2022-03-03lib.modules: Let module declare options directly in bare submoduleRobert Hensing1-0/+5
... where a bare submodule is an option that has a type like `submoduleWith x`, as opposed to `attrsOf (submoduleWith x)`. This makes migration unnecessary when introducing a freeform type in an existing option tree. Closes #146882
2022-03-01lib.modules: Use types.optionType for _module.freeformTypeSilvan Mosberger1-0/+5
This ensures that the module file locations are propagated to the freeform type, which makes it so that submodules in freeform types now have their declaration location shown in the manual, fixing https://github.com/NixOS/nixpkgs/issues/132085. In addition, this also newly allows freeformTypes to be declared multiple times and all declarations being merged together according to normal option merging. This also removes some awkwardness regarding the type of `freeformType`
2022-03-01lib.types: Introduce `types.optionType`Silvan Mosberger1-0/+7
This type correctly merges multiple option types together while also annotating them with file information. In a future commit this will be used for `_module.freeformType`
2022-02-22lib/types: Introduce types.raw for unprocessed valuesSilvan Mosberger1-0/+6
2022-02-17lib/tests: Add tests for emptyValueSilvan Mosberger1-0/+9
2021-11-26lib/tests: Use standard test syntaxVictor Engmark1-1/+1
For consistency.
2021-11-26lib/tests: Anchor config output regexesVictor Engmark1-98/+98
Strengthens the tests by making sure the whole line is matched.
2021-11-26lib/tests: Set hardening pragmasVictor Engmark1-4/+7
Makes any programming errors more likely to show up early. Non-obvious changes because of this: - Ignore the `evalConfig` result in `reportFailure`; we're not checking it at that point. - Pre-increment `$fail` and `$pass` to make sure the arithmetic doesn't result in a zero, which would result in a non-zero exit code for the expression.
2021-11-26lib/tests: Don't return non-zero values from checksVictor Engmark1-5/+0
The exit codes aren't used for anything.
2021-11-26lib/tests: Avoid assigning an array to a stringVictor Engmark1-2/+2
As per <https://github.com/koalaman/shellcheck/wiki/SC2124>.
2021-11-26lib/tests: Remove redundant semicolonsVictor Engmark1-6/+6
2021-11-26lib/tests: Clarify assignmentVictor Engmark1-1/+1
The extra equal sign was confusing, and doesn't seem to be relevant.
2021-11-26lib/tests: Use correct shebang lineVictor Engmark1-1/+1
The script uses plenty of non-POSIX features, such as referencing `$BASH_SOURCE`.
2021-11-22modules: Add moduleType to module argumentsRobert Hensing1-0/+5
2021-11-09lib/tests/modules.sh: update to Nix 2.4 syntaxBernardo Meurer1-12/+12
2021-11-01lib.evalModules: Add extendModules and type to resultRobert Hensing1-0/+7
Allows the simultaneous construction of top-level invocations and submodule types. This helps structure configuration systems integration code.
2021-10-02lib/types: Make types.anything merge functionsSilvan Mosberger1-1/+3
Previously it would give an error if there were multiple function definitions.
2021-05-05Revert "lib/tests: Add type deprecation tests"Robert Hensing1-6/+0
This reverts commit 8b957e3b301d748e6fbbed806d82bd9d4b9d4ac4.
2021-05-03lib/tests: Add type deprecation testsSilvan Mosberger1-0/+6
2021-05-03lib/tests: Make sure the submodule type description can be evaluatedSilvan Mosberger1-0/+3
In 2d45a62899d47c109a0b8ce4ca9d33265b8a1a37, the submodule type description was amended with the freeformType description. This causes all the modules passed to the submodule to be evaluated once on their own, without any extra definitions from the config section. This means that the specified modules need to be valid on their own, without any undeclared options. This commit adds a test that evaluates a submodules option description, which would trigger the above problem for one of the tests, if it were not fixed by this commit as well. This is done because the next commit makes option evaluation a bit more strict, which would also trigger this test failure, even though it's not related to the change at all.
2021-03-11lib/modules: better error message if an attr-set of options is expectedMaximilian Bosch1-1/+1
I recently wrote some Nix code where I wrongly set a value to an option which wasn't an actual option, but an attr-set of options. The mistake I made can be demonstrated with an expression like this: { foo = { lib, pkgs, config, ... }: with lib; { options.foo.bar.baz = mkOption { type = types.str; }; config.foo.bar = 23; }; } While it wasn't too hard to find the cause of the mistake for me, it was necessary to have some practice in reading stack traces from the module system since the eval-error I got was not very helpful: error: --- TypeError --------------------------------------------------------- nix-build at: (323:25) in file: /nix/store/3nm31brdz95pj8gch5gms6xwqh0xx55c-source/lib/modules.nix 322| foldl' (acc: module: 323| acc // (mapAttrs (n: v: | ^ 324| (acc.${n} or []) ++ f module v value is an integer while a set was expected (use '--show-trace' to show detailed location information) I figured that such an error can be fairly confusing for someone who's new to NixOS, so I decided to catch this case in th `byName` function in `lib/modules.nix` by checking if the value to map through is an actual attr-set. If not, a different error will be thrown.
2021-01-27lib/tests: More functionTo testsSilvan Mosberger1-2/+6
2021-01-24lib/tests/modules: add a test for the functionTo typeBas van Dijk1-0/+3
(cherry picked from commit 478af112e83df806bd8a51174834d2a130fbdeb9)
2020-12-18Revert "Module-builtin assertions, disabling assertions and submodule ↵Silvan Mosberger1-57/+21
assertions"
2020-12-17lib/modules: Introduce _module.checks.*.checkSilvan Mosberger1-1/+2
Previously the .enable option was used to encode the condition as well, which lead to some oddness: - In order to encode an assertion, one had to invert it - To disable a check, one had to mkForce it By introducing a separate .check option this is solved because: - It can be used to encode assertions - Disabling is done separately with .enable option, whose default can be overridden without a mkForce
2020-11-30lib/modules: Remove _module.checks.*.triggerPath as it's not necessarySilvan Mosberger1-15/+0
Previously this option was thought to be necessary to avoid infinite recursion, but it actually isn't, since the check evaluation isn't fed back into the module fixed-point.
2020-11-30lib/modules: Rename _module.assertions to _module.checksSilvan Mosberger1-8/+8
2020-11-30lib/tests: Add tests for module-builtin assertionsSilvan Mosberger1-0/+37