mirror of
https://github.com/ryan4yin/nixos-and-flakes-book.git
synced 2025-02-16 10:29:55 +01:00
fix: optional imports
This commit is contained in:
parent
f3145b8143
commit
95e7833e71
@ -317,9 +317,10 @@ Let's look at an example directly:
|
||||
({config, lib, enableFoo ? false, ...}: {
|
||||
imports =
|
||||
[
|
||||
# Use lib.optionals to decide whether to import foo.nix
|
||||
(lib.optionals (enableFoo) ./foo.nix)
|
||||
];
|
||||
# Other Modules
|
||||
]
|
||||
# Use lib.optionals to decide whether to import foo.nix
|
||||
++ (lib.optionals (enableFoo) [./foo.nix]);
|
||||
})
|
||||
];
|
||||
};
|
||||
|
@ -328,9 +328,10 @@ Nixpkgs 中的模块系统提供了一系列类似 `lib.mkIf` 的函数,用于
|
||||
({config, lib, enableFoo ? false, ...}: {
|
||||
imports =
|
||||
[
|
||||
# 通过 lib.optionals 来决定是否导入 foo.nix
|
||||
(lib.optionals (enableFoo) ./foo.nix)
|
||||
];
|
||||
# 这里写其他模块
|
||||
]
|
||||
# 通过 lib.optionals 来决定是否foo.nix
|
||||
++ (lib.optionals (enableFoo) [./foo.nix]);
|
||||
})
|
||||
];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user