fix: specialArgs & _module.args

This commit is contained in:
Ryan Yin 2024-08-28 12:15:35 +08:00
parent 889d848005
commit d8914059f9
2 changed files with 3 additions and 2 deletions

View file

@ -95,8 +95,7 @@ submodules. The difference between them is:
passed through `_module.args` in `imports = [ ... ];`, it will result in an passed through `_module.args` in `imports = [ ... ];`, it will result in an
`infinite recursion` error**. In this case, you must use `specialArgs` instead. `infinite recursion` error**. In this case, you must use `specialArgs` instead.
The NixOS community generally recommends prioritizing the use of the `_module.args` option I personally prefer `specialArgs` because it is more straightforward and easier to use.
and resorting to `specialArgs` only when `_module.args` cannot be used.
Suppose you want to pass a certain dependency to a submodule for use. You can use the Suppose you want to pass a certain dependency to a submodule for use. You can use the
`specialArgs` parameter to pass the `inputs` to all submodules: `specialArgs` parameter to pass the `inputs` to all submodules:

View file

@ -87,6 +87,8 @@ Nixpkgs 的模块系统提供了两种方式来传递非默认参数:
NixOS 社区比较推荐优先使用 `_module.args` 这个 options仅在无法使用 `_module.args` 时才改 NixOS 社区比较推荐优先使用 `_module.args` 这个 options仅在无法使用 `_module.args` 时才改
`specialArgs` `specialArgs`
我个人更喜欢 `specialArgs`,因为它更简单直接,用起来顺手些。
假设你想将某个依赖项传递到子模块中使用,可以使用 `specialArgs` 参数将 `inputs` 传递到所有 假设你想将某个依赖项传递到子模块中使用,可以使用 `specialArgs` 参数将 `inputs` 传递到所有
子模块中: 子模块中: