Skip to content

Commit

Permalink
feat: docs for _module.args
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan4yin committed Mar 16, 2024
1 parent 0091296 commit a15b7c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/nixos-with-flakes/nixos-with-flakes-enabled.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ The official documentation for these two parameters is buried deep and is vague
1. `specialArgs`: There are scattered mentions related to it in the NixOS Manual and the Nixpkgs Manual.
- Nixpkgs Manual: [Module System - Nixpkgs]
- NixOS Manual: [nixpkgs/nixos-23.11/nixos/doc/manual/development/option-types.section.md#L237-L244]
1. `_module.args`: Its only official documentation is in the source code below.
- [nixpkgs/nixos-23.11/lib/modules.nix - _module.args]
1. `_module.args`:
- NixOS Manual: [Appendix A. Configuration Options](https://nixos.org/manual/nixos/stable/options#opt-_module.args)
- Source Code: [nixpkgs/nixos-23.11/lib/modules.nix - _module.args]

In short, `specialArgs` and `_module.args` both require an attribute set as their value, and they serve the same purpose, passing all parameters in the attribute set to all submodules. The difference between them is:

Expand Down
5 changes: 3 additions & 2 deletions docs/zh/nixos-with-flakes/nixos-with-flakes-enabled.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ Nixpkgs 的模块系统提供了两种方式来传递非默认参数:
1. `specialArgs`: NixOS Manual 跟 Nixpkgs Manual 中分别有与它有关的只言片语
- Nixpkgs Manual: [Module System - Nixpkgs]
- NixOS Manual: [nixpkgs/nixos-23.11/nixos/doc/manual/development/option-types.section.md#L237-L244]
1. `_module.args`: 它唯一的官方文档在如下这份源码中
- [nixpkgs/nixos-23.11/lib/modules.nix - _module.args]
1. `_module.args`:
- NixOS Manual: [Appendix A. Configuration Options](https://nixos.org/manual/nixos/stable/options#opt-_module.args)
- Source Code: [nixpkgs/nixos-23.11/lib/modules.nix - _module.args]

总之,`specialArgs``_module.args` 需要的值都是一个 attribute set,它们的功能也相同,都是将其 attribute set 中的所有参数传递到所有子模块中。
这两者的区别在于:
Expand Down

0 comments on commit a15b7c7

Please sign in to comment.