summary refs log tree commit diff
path: root/lib/modules.nix
Commit message (Collapse)AuthorAge
* Merge pull request #156533 from ↵Silvan Mosberger2022-03-16
|\ | | | | | | | | hercules-ci/issue-146882-transparent-submodule-options lib.modules: Let module declare options directly in bare submodule
| * lib/modules.nix: Add comment about internal shorthand null valueRobert Hensing2022-03-07
| |
| * lib/modules.nix: Move comment to the actual legacy codeRobert Hensing2022-03-07
| |
| * Revert "lib.modules: Remove redundant fixupOptionType in option injection"Robert Hensing2022-03-07
| | | | | | | | | | | | | | | | | | | | 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.
| * lib.modules: Remove redundant fixupOptionType in option injectionRobert Hensing2022-03-03
| |
| * lib.modules: Make option injection work when shorthandOnlyDefinesConfigRobert Hensing2022-03-03
| |
| * lib.modules: Improve option-is-prefix error messageRobert Hensing2022-03-03
| |
| * lib.modules: Explain why options can only be merged into submodulesRobert Hensing2022-03-03
| |
| * lib.modules: Refactor option scanning slightlyRobert Hensing2022-03-03
| | | | | | | | | | | | This scans the options with fewer function calls, improving performance. It also removes a let Env from the happy flow of the new logic.
| * lib.types.submodule: Remove redundant isSubmodule attrRobert Hensing2022-03-03
| |
| * lib.modules: Let module declare options directly in bare submoduleRobert Hensing2022-03-03
| | | | | | | | | | | | | | | | | | | | ... 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
* | lib/modules.nix: Optimize optionSet legacy compat codeRobert Hensing2022-03-07
|/ | | | It's still in the hot path.
* lib.modules: Use types.optionType for _module.freeformTypeSilvan Mosberger2022-03-01
| | | | | | | | | | | | | 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`
* lib/modules: Use types.raw for _module.argsSilvan Mosberger2022-02-22
| | | | | Fixes https://github.com/NixOS/nixpkgs/issues/53458, as types.raw doesn't allow setting multiple values
* lib/modules: introduce setDefaultModuleLocationNaïm Favier2022-01-27
| | | | Wraps a module with a default location for reporting errors.
* lib/modules: extract multiply-used value in byNamepennae2021-12-28
| | | | | | 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).
* lib/modules: optimize byNamepennae2021-12-25
| | | | | | | | | | | 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.
* Merge pull request #148785 from pennae/more-option-doc-staticizingGraham Christensen2021-12-17
|\ | | | | treewide: more defaultText for options
| * nixos/modules: Allow options to be coerced to a string for convenienceSilvan Mosberger2021-12-08
| |
* | Merge pull request #144022 from hercules-ci/lib-modules-optimize-unmatchedDefnsSilvan Mosberger2021-12-07
|\ \ | | | | | | lib/modules: Short-circuit unmatchedDefns when configs is empty
| * | lib/modules: Use strict fold' as recursiveUpdate is also strictRobert Hensing2021-11-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | recursiveUpdate does not produce an attrset until it has evaluated both its arguments to weak head normal form. nix-repl> lib.recursiveUpdate (throw "a") (throw "b") error: b nix-repl> lib.recursiveUpdate (throw "a") {} error: a
| * | lib/modules: Fix import* commentsRobert Hensing2021-11-03
| | | | | | | | | | | | Very confusing otherwise.
| * | lib/modules: Remove a lib.flipRobert Hensing2021-11-03
| | | | | | | | | | | | In hot code, the overhead (envs, applies) can matter.
| * | lib/modules: Short-circuit unmatchedDefns earlierRobert Hensing2021-11-03
| | |
| * | lib/modules: Short-circuit unmatchedDefns when configs is emptyRobert Hensing2021-10-31
| | |
* | | lib/modules: Deprecate args and checkRobert Hensing2021-12-02
| | |
* | | lib/modules: Pass legacy args argument along through extendModulesRobert Hensing2021-12-02
| |/ |/|
* | modules: Add moduleType to module argumentsRobert Hensing2021-11-22
| |
* | modules: Document that extendModules is also a module argumentRobert Hensing2021-11-22
| |
* | lib.modules: add mkDerivedConfigTaeer Bar-Yam2021-11-15
| | | | | | | | | | | | | | | | | | | | | | mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b Create config definitions with the same priority as the definition of another option. This should be used for option definitions where one option sets the value of another as a convenience. For instance a config file could be set with a `text` or `source` option, where text translates to a `source` value using `mkDerivedConfig options.text (pkgs.writeText "filename.conf")`. It takes care of setting the right priority using `mkOverride`.
* | modules: Update evalModules docRobert Hensing2021-11-01
| |
* | modules: Add extendModules to module argsRobert Hensing2021-11-01
| |
* | lib.evalModules: Add extendModules and type to resultRobert Hensing2021-11-01
|/ | | | | | | Allows the simultaneous construction of top-level invocations and submodule types. This helps structure configuration systems integration code.
* lib/modules: grammar fix in error msgMaximilian Bosch2021-08-26
|
* lib/modules: fix error-message when declaring an option inside `config'Maximilian Bosch2021-08-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The message I originally implemented here was to catch a mixup of `config' and `options' in a `types.submodule'[1]. However it looks rather weird for a wrongly declared top-level option. So I decided to throw error: The option `foo' does not exist. Definition values: - In `<unknown-file>': { bar = { _type = "option"; type = { _type = "option-type"; ... It seems as you're trying to declare an option by placing it into `config' rather than `options'! for an expression like with import ./lib; evalModules { modules = [ { foo.bar = mkOption { type = types.str; }; } ]; } [1] fa30c9abed61f30218a211842204705986d486f9
* lib/modules: add mkImageMediaOverrideDavid Arnold2021-08-03
| | | | | | | | | so the underlaying use case of the preceding commit is so generic, that we gain a lot in reasoning to give it an appropriate name. As the comment states: image media needs to override host config short of mkForce
* lib.mkFixStrictness: DeprecateRobert Hensing2021-07-12
|
* Partially revert "lib/modules: Drop mkStrict and mkFixStrictness"Robert Hensing2021-07-12
| | | | | | | mkFixStrictness was never properly deprecated and should only be removed after warning for some time. This partially reverts commit 8fb9984690c878fcd768e967190957441de05d11.
* lib/modules: Drop mkStrict and mkFixStrictnessJanne Heß2021-06-06
| | | | This was deprecated in 2014 and is not used anywhere in the tree.
* Merge pull request #121870 from Pacman99/pass-specialargsRobert Hensing2021-05-07
|\ | | | | lib/modules: pass specialArgs to modules
| * lib/modules: pass specialArgs as a module argumentPacman992021-05-06
| |
* | lib/modules: Small optimizationSilvan Mosberger2021-05-06
| |
* | Merge pull request #114955 from berbiche/fix/modules-imports-listSilvan Mosberger2021-05-05
|\ \ | | | | | | lib/modules: provide a better error message when "imports" contains a list
| * | lib/modules: provide error message when imports contains a listNicolas Berbiche2021-05-05
| | |
* | | Revert "lib/modules: Issue type deprecation warnings recursively"Robert Hensing2021-05-05
|/ / | | | | | | This reverts commit 4b54aedee5e05aaf2838f6d951508b83e33d2baa.
* / lib/modules: Issue type deprecation warnings recursivelySilvan Mosberger2021-05-03
|/ | | | | | | | | | | | | | Previously, an option of type attrsOf string wouldn't throw a deprecation warning, even though the string type is deprecated. This was because the deprecation warning trigger only looked at the type of the option itself, not any of its subtypes. This commit fixes this, causing each of the types deprecationMessages to trigger for the option. This relies on the subtypes mkOptionType attribute introduced in 26607a5a2e06653fec453c83d063cdfc4b59185f
* treewide: use lib.warnIf where appropriateAlyssa Ross2021-04-28
|
* lib/modules: better error message if an attr-set of options is expectedMaximilian Bosch2021-03-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* lib/modules: Set submodule type for renamed option setsSilvan Mosberger2021-01-21
| | | | | | | | | | | | | For renames like mkAliasOptionModule [ "services" "compton" ] [ "services" "picom" ] where the target is an option set (like services.picom) instead of a single option (like services.picom.enable), previously the renamed option type was unset, leading to it being `types.unspecified`. This changes it to be `types.submodule {}` instead, which makes more sense.
* Revert "Module-builtin assertions, disabling assertions and submodule ↵Silvan Mosberger2020-12-18
| | | | assertions"