summaryrefslogtreecommitdiff
path: root/lib/modules.nix (follow)
Commit message (Expand)AuthorAgeFilesLines
* lib/modules: add `class` to `specialArgs`•••Co-Authored-By: Johannes Kirschbauer <hsjobeki@gmail.com> Michael Hoang2025-04-101-0/+1
* lib.modules: init test for lib.mkDefinitionJohannes Kirschbauer2025-04-031-2/+0
* lib.modules: init lib.mkDefinition•••Free-floating definitions including file location. Robert Hensing2025-04-031-4/+18
* treewide: Format all Nix files•••Format all Nix files using the officially approved formatter, making the CI check introduced in the previous commit succeed: nix-build ci -A fmt.check This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153) of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166). This commit will lead to merge conflicts for a number of PRs, up to an estimated ~1100 (~33%) among the PRs with activity in the past 2 months, but that should be lower than what it would be without the previous [partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537). Merge conflicts caused by this commit can now automatically be resolved while rebasing using the [auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase). If you run into any problems regarding any of this, please reach out to the [formatting team](https://nixos.org/community/teams/formatting/) by pinging @NixOS/nix-formatting. Silvan Mosberger2025-04-011-683/+916
* lib.modules: simplified logic in zipAttrsWith and minor cleanuptoborwinner2025-03-101-7/+5
* Docs: migrate format of comments to doc-commentsJohannes Kirschbauer2025-02-121-173/+418
* lib/modules: improve mismatching class error mesageJohannes Kirschbauer2025-01-291-1/+8
* Revert "pkgs/top-level: make package sets composable"K9002025-01-261-2/+0
* nixos/nixpkgs: pass original system args instead of elaborated•••Passing the elaborated system defeats what pkgs/top-level/default.nix tries to do: Pass only the original args and let defaults be inferred. The underlying problem is that lib.systems.elaborate can not deal with arbitrary overrides, but will often return an inconsistent system description when partially overriding some values. This becomes most prominent if trying to override an already elaborated system. Wolfgang Walther2025-01-251-0/+2
* lib.collectModules: improve readability by replacing implicationJohannes Kirschbauer2024-12-311-1/+1
* lib/modules: Minor performance optimisation•••Co-Authored-By: Johannes Kirschbauer <hsjobeki@gmail.com> Silvan Mosberger2024-12-031-12/+19
* lib/types: Add deprecation to attrsWith•••Co-Authored-By: @infinisil Silvan Mosberger2024-12-031-3/+26
* Revert "lib/types: init {types.attrsWith}"K9002024-12-031-35/+5
* lib/modules: Minor performance optimisation•••Co-Authored-By: Johannes Kirschbauer <hsjobeki@gmail.com> Silvan Mosberger2024-12-021-12/+19
* lib/types: Add deprecation to attrsWith•••Co-Authored-By: @infinisil Silvan Mosberger2024-11-261-3/+26
* treewide: lib.isInOldestRelease -> lib.oldestSupportedReleaseIsAtLeastRobert Hensing2024-10-081-4/+4
* lib/modules: Improve error when loading a flake as a moduleRobert Hensing2024-09-261-6/+105
* lib/modules: improve error message when option is being accessed that isn't d...Robert Hensing2024-09-021-1/+1
|\
| * lib/modules: improve error message when option is being accessed that isn't d...Sandro Jäckel2024-09-011-1/+1
* | lib.importApply: init (#230588)•••* lib.modules.importApply: init Brings variables from rich scopes to modules defined in separate files. A helper for functions in files that return a module. * lib.modules.importApply: Edit doc Generally improve the quality. Notes: - Not rendered to the manual yet, so probably the syntax could be improved, but I have no way to test this now. - The docs use `arg` vs `staticArg` in the code. This is intentional, because the doc is pretty clear about the role of `arg` whereas the code exists in a context where ambiguities are more harmful. * FormatRobert Hensing2024-08-311-0/+53
|/
* lib/modules: Memoize remaining lookups into builtins•••Similar to the previous commit about lookups into lib Main benefits - consistent - faster - shorter Robert Hensing2024-07-031-11/+17
* lib/modules: Memoize remaining lookups into lib•••Benefits: - some lookups happened in the hot path, and will now be slightly faster, with only a variable lookup and no attribute selection - it's now harder to accidentally use args.lib aka specialArgs.lib, which has happened - shorter Robert Hensing2024-07-031-21/+25
* lib/modules: Memoize functionArgs lookup•••This would also make specialArgs-lib.nix pass. Robert Hensing2024-07-031-1/+2
* lib/modules: Memoize addErrorContext lookupRobert Hensing2024-07-031-6/+7
* lib/modules: Use fixed lib instead of args.lib•••The practical use for this should be very limited because I don't think anyone should change `lib`, let alone change `lib.functionArgs`, but, but it would be even stranger to rely on `args.lib` (or really `specialArgs.lib` for what's clearly a behavior of the current `evalModules`, which uses its own ambient lib for basically everything. The shadowing of `lib` by `args.lib` here seems to be a small mistake, which is easy to make. Robert Hensing2024-07-031-2/+2
* lib: remove all uses of lib.mdDoc•••this change is otherwise a no-op, as lib.mdDoc is already defined to be the identity function. stuebinm2024-04-131-4/+4
* Merge pull request #284551 from hercules-ci/types-attrTag•••Add `types.attrTag`Silvan Mosberger2024-04-091-1/+1
|\
| * lib.modules.evalOptionValue: Undeprecate for lib.types•••lib.types.attrTag needs it. Robert Hensing2024-04-041-1/+1
* | Merge pull request #286544 from hercules-ci/doRename-doc•••lib.modules.doRename: Add doc commentsValentin Gagarin2024-02-221-1/+72
|\ \
| * | lib.modules.doRename: Add doc comments•••I don't think these are rendered yet, but this at least provides the content. Follow-up to https://github.com/NixOS/nixpkgs/pull/285612 Robert Hensing2024-02-141-1/+72
| |/
* / lib.evalModules: Fix deprecation doc for args parameterBenoit de Chezelles2024-02-181-2/+2
|/
* lib.modules.doRename: Add condition parameter•••This is to support single-to-multi service migrations, so that the `to` (e.g. `foos.""`) isn't defined unconditionally. See test cases. Robert Hensing2024-02-021-3/+3
* lib/modules: Test optionless module errors from #131205Robert Hensing2023-12-091-0/+2
* Merge pull request #249243 from lf-/jade/declarationsWithLocations•••nixos/modules: Add declarationPositionsRobert Hensing2023-09-171-4/+11
|\
| * nixos/modules: Add declarationPositions•••What it does: line and column level *declaration* position information: $ nix repl . nix-repl> :p nixosConfigurations.micro.options.environment.systemPackages.declarationPositions [ { column = 7; file = "/nix/store/24aj3k7fgqv3ly7qkbf98qvphasrw9nb-source/nixos/modules/config/system-path.nix"; line = 63; } ] Use cases: - ctags over NixOS options, as will be presented at NixCon 2023 ;) - improving the documentation pages to go to the exact line of the declarations. Related work: - https://github.com/NixOS/nixpkgs/pull/65024 This one does it for all *definitions* rather than declarations, and it was not followed through with due to performance worries. - https://github.com/NixOS/nixpkgs/pull/208173 The basis for this change. This change is just a rebase of that one. I split it out to add the capability before adding users of it, in order to simplify review. However, the ctags script in there is a sample user of this feature. Benchmarks: conducted by evaluating my own reasonably complex NixOS configuration with the command: `hyperfine -S none -w 1 -- "nix eval .#nixosConfigurations.snowflake.config.system.build.toplevel.outPath"` ``` Benchmark 1: nix eval .#nixosConfigurations.snowflake.config.system.build.toplevel.outPath Time (mean ± σ): 8.971 s ± 0.254 s [User: 5.872 s, System: 1.388 s] Range (min … max): 8.574 s … 9.327 s 10 runs Benchmark 1: nix eval .#nixosConfigurations.snowflake.config.system.build.toplevel.outPath Time (mean ± σ): 8.766 s ± 0.160 s [User: 5.873 s, System: 1.346 s] Range (min … max): 8.496 s … 9.033 s 10 runs ``` Summary of results: it seems to be in the noise, this does not cause any visible regression in times. Jade Lovelace2023-09-081-4/+11
* | lib/modules: Report a better error when option tree has bare type•••Improves on 0d472a62012364d064f0b75f1da491242c6ae9c6 - https://github.com/NixOS/nixpkgs/pull/242339 We actually do have the file name. Thanks Shawn8901 for the [feedback]! feedback: https://github.com/NixOS/nixpkgs/pull/242339#issuecomment-1683107055 Robert Hensing2023-08-181-3/+3
* | lib/modules: Report a good error when option tree has bare type•••Note that this removes the possibility of declaring an option named `_type`. Robert Hensing2023-08-141-1/+33
|/
* Merge pull request #245271 from sternenseemann/module-system-merge-no-type•••lib/modules: handle typeless options in mergeModulesRobert Hensing2023-07-271-1/+1
|\
| * lib/modules: handle typeless options in mergeModules•••mkOption does not require a `type` argument and does not set the resulting attribute if it is not given. Consequently, we need to be prepared to merge options that have no type information. sternenseemann2023-07-261-1/+1
* | lib.mergeModules: Add context to error messageRobert Hensing2023-07-111-1/+4
* | lib/modules.nix: FormatRobert Hensing2023-07-111-19/+28
* | lib/modules.nix: Inline single-use `subtree` bindingsRobert Hensing2023-07-111-4/+4
* | lib/modules.nix: Make entire definition list strict in config check•••This is a non-trivial refactor that slightly changes the semantics of the internal definition lists. Whereas previously only individual list items would trigger the exception, now the error is promoted to the whole list. This is mostly ok, because we compute the value, it is wrong to ignore a definition. However, we don't always compute the value. For instance `readOnly` only needs to count definitions. That won't be possible anymore when the error is raised for one of the items. As a consequence, an error will be raised for the errant definition instead of the number of definitions. Robert Hensing2023-07-111-24/+21
* | lib/modules.nix: Rename defnsByName -> pushedDownDefinitionsByNameRobert Hensing2023-07-111-2/+2
* | lib/modules.nix: Rename defnsByName' -> rawDefinitionsByNameRobert Hensing2023-07-111-3/+3
* | lib/modules.nix: Apply argument `module` of old fRobert Hensing2023-07-111-9/+9
* | lib/modules.nix: Apply argument `modules` of old old old byNameRobert Hensing2023-07-111-6/+6
* | lib/modules.nix: Apply argument `f` of old old byNameRobert Hensing2023-07-111-15/+21
* | lib/modules.nix: Apply argument `attr` of old byNameRobert Hensing2023-07-111-31/+15
* | lib/modules.nix: Inline byName•••byName is not an abstraction. This is the first commit in a series that refactors it away. Robert Hensing2023-07-111-27/+43
|/