Skip to content

Commit

Permalink
feat: lib.optionals
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan4yin committed Mar 8, 2024
1 parent 95e7833 commit 8cf2d85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/other-usage-of-flakes/module-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ The disadvantage of this method is that all Nix modules that require conditional

The main advantage of this method is that it is much simpler than the methods previously introduced, requiring no modification to the module content, just using `lib.optionals` in `imports` to decide whether to import a module or not.

> Details about how `lib.optionals` works: <https://noogle.dev/f/lib/optionals>
Let's look at an example directly:

```nix
Expand Down
2 changes: 2 additions & 0 deletions docs/zh/other-usage-of-flakes/module-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ Nixpkgs 中的模块系统提供了一系列类似 `lib.mkIf` 的函数,用于

这种方式的主要好处是,它要比前面介绍的方法简单许多,不需要对模块内容做任何修改,只需要在 `imports` 中使用 `lib.optionals` 来决定是否导入某个模块即可。

> `lib.optionals` 函数的详细文档: <https://noogle.dev/f/lib/optionals>
直接看例子:

```nix
Expand Down

0 comments on commit 8cf2d85

Please sign in to comment.