summary refs log tree commit diff
path: root/lib/modules.nix
AgeCommit message (Collapse)AuthorFilesLines
2022-11-03lib.modules.doRename: Don't define warning, even as undefined, if not warning.Shea Levy1-2/+2
This fixes mkAliasOptionModule in systems with no warning option.
2022-10-01Merge pull request #193132 from figsoda/clean-upfigsoda1-9/+1
treewide: clean up
2022-09-28Merge pull request #191540 from hercules-ci/nixosTest-modularRobert Hensing1-1/+2
nixosTest: make modular
2022-09-26lib/modules.nix: remove unused bindingsfigsoda1-9/+1
2022-09-21lib/modules: Fix meta duplication in shorthand syntaxRobert Hensing1-1/+2
2022-09-05lib/modules: add `definitionsWithLocations` to evaluated optionsErik Arvstedt1-0/+1
This attr provides the location of each definition. This is particularly useful for introspecting options of type `attrsOf`. E.g., it allows finding the location of a systemd service definition by parsing `options.systemd.services.definitionsWithLocations`.
2022-09-01Merge branch 'master' into option-docs-mdpennae1-1/+3
2022-08-31lib/modules: convert option description to MDpennae1-77/+43
2022-08-31lib.modules: support strings with absolute paths in `disabledModules`Erik Arvstedt1-1/+3
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-07-21lib/modules: Add _module.specialArgsRobert Hensing1-0/+10
2022-06-14lib/modules: Throw earlier when module function does not return attrsRobert Hensing1-3/+2
`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: Add deferredModuleWithRobert Hensing1-1/+3
2022-06-14lib/types, lib/modules: Remove unused extensionOffsetRobert Hensing1-7/+1
2022-06-10lib/modules: Fix missing prefix in extendModules when unset in both eval- ↵Robert Hensing1-1/+1
and extend-
2022-04-30Merge pull request #167776 from ↵Robert Hensing1-1/+4
hercules-ci/lib-modules-allow-disable-_modules.args-docs-internal lib.modules: Allow making _module.args internal
2022-04-24lib.types.submoduleWith: Avoid _key collisions after extendModulesRobert Hensing1-1/+7
2022-04-11lib.modules: Allow making _module.args internalRobert Hensing1-1/+4
This allows other module system consumers to disable these docs via option merging. For instance arion uses asciidoc instead of docbook so that would look awful.
2022-04-05Merge pull request #165540 from Infinisil/module-args-docsRobert Hensing1-3/+87
lib/modules: Document `_module.args`
2022-04-05lib/modules: Document _module.argsSilvan Mosberger1-3/+87
Documents the _module.args option, motivated by many usages in Flakes, especially with the deprecation of extraArgs (https://github.com/NixOS/nixpkgs/commit/78ada833615d241ed76463aa5a024b614150eb4d) The documentation rendering for this option had to be handled a bit specially, since it's not declared in nixos/modules like all the other NixOS options. Co-Authored-By: pennae <github@quasiparticle.net> Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2022-03-25Merge pull request #164651 from Infinisil/remove-optionSetSilvan Mosberger1-28/+6
lib/modules: Finally remove deprecated types.optionSet
2022-03-21Merge remote-tracking branch 'upstream/master' into tests-restrict-argumentsRobert Hensing1-12/+82
2022-03-21lib: applyIfFunction -> applyModuleArgsIfFunctionRobert Hensing1-3/+3
2022-03-21Merge pull request #163451 from hercules-ci/stop-premature-warningsKevin Cox1-0/+20
Stop premature warnings, including `nix.settings` migration
2022-03-21lib.mkRenamedOptionModuleWith: Remove warnWhenReadRobert Hensing1-9/+1
Let's keep things simple and not poke holes in the improved migration process.
2022-03-18lib/modules: Finally remove deprecated types.optionSetSilvan Mosberger1-28/+6
types.optionSet has been deprecated for almost 10 years now (0e333688cea468a28516bf6935648c03ed62a7bb)! A removal was already attempted in 2019 (27982b408e465554b8831f492362bc87ed0ec02a), but it was promptly reinstantiated since some third-party uses were discovered (f531ce75e4178c6867cc1d0f7fec96b2d5c3f1cb). It's finally time to remove it for good :)
2022-03-16Merge pull request #156533 from ↵Silvan Mosberger1-12/+62
hercules-ci/issue-146882-transparent-submodule-options lib.modules: Let module declare options directly in bare submodule
2022-03-09lib: Add mkRenamedOptionModuleWithRobert Hensing1-0/+28
Adds support for sinceRelease
2022-03-07lib/modules.nix: Add comment about internal shorthand null valueRobert Hensing1-0/+3
2022-03-07lib/modules.nix: Move comment to the actual legacy codeRobert Hensing1-3/+4
2022-03-07lib/modules.nix: Optimize optionSet legacy compat codeRobert Hensing1-5/+5
It's still in the hot path.
2022-03-07Revert "lib.modules: Remove redundant fixupOptionType in option injection"Robert Hensing1-1/+1
This reverts commit 6b077c47ff14cb9a4a8f5cb8986fa83ff626c732. Thanks Infinisil for discovering this problem: > After a lot of trial and error, trying to prove why fixupOptionType should > be used here or not, I figured it out: It's needed for the sake of file > locations in error messages.
2022-03-03lib.modules: Remove redundant fixupOptionType in option injectionRobert Hensing1-1/+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-3/+21
2022-03-03lib.modules: Explain why options can only be merged into submodulesRobert Hensing1-0/+9
2022-03-03lib.modules: Refactor option scanning slightlyRobert Hensing1-10/+8
This scans the options with fewer function calls, improving performance. It also removes a let Env from the happy flow of the new logic.
2022-03-03lib.types.submodule: Remove redundant isSubmodule attrRobert Hensing1-1/+1
2022-03-03lib.modules: Let module declare options directly in bare submoduleRobert Hensing1-1/+21
... 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-2/+1
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-02-22lib/modules: Use types.raw for _module.argsSilvan Mosberger1-1/+1
Fixes https://github.com/NixOS/nixpkgs/issues/53458, as types.raw doesn't allow setting multiple values
2022-01-27lib/modules: introduce setDefaultModuleLocationNaïm Favier1-5/+7
Wraps a module with a default location for reporting errors.
2021-12-28lib/modules: extract multiply-used value in byNamepennae1-4/+4
module.${attr} is used at least twice, so it must be evaluated at least twice (and since it's a function argument, be turned into a thunk twice).
2021-12-25lib/modules: optimize byNamepennae1-6/+5
the foldl is equivalent to a zip with concat. list concatenation in nix is an O(n) operation, which makes this operation extremely inefficient when large numbers of modules are involved. this change reduces the number of list elements by 7 million on the system used to write this, total memory spent on lists by 58MB, and total memory allocated on the GC heap by almost 100MB (with a similar reduction in GC heap size). it's also slightly faster.
2021-12-17Merge pull request #148785 from pennae/more-option-doc-staticizingGraham Christensen1-0/+2
treewide: more defaultText for options
2021-12-08nixos/modules: Allow options to be coerced to a string for convenienceSilvan Mosberger1-0/+2
2021-12-07Merge pull request #144022 from hercules-ci/lib-modules-optimize-unmatchedDefnsSilvan Mosberger1-13/+18
lib/modules: Short-circuit unmatchedDefns when configs is empty
2021-12-02lib/modules: Deprecate args and checkRobert Hensing1-1/+6
2021-12-02lib/modules: Pass legacy args argument along through extendModulesRobert Hensing1-4/+21
2021-11-22modules: Add moduleType to module argumentsRobert Hensing1-0/+3
2021-11-22modules: Document that extendModules is also a module argumentRobert Hensing1-0/+2