mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
doc/contributing: add lib.optional (#121251)
Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
This commit is contained in:
parent
704b174d77
commit
f289d93a41
1 changed files with 15 additions and 0 deletions
|
@ -181,6 +181,21 @@
|
||||||
rev = "${version}";
|
rev = "${version}";
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- Filling lists condionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
buildInputs = lib.optional stdenv.isDarwin iconv;
|
||||||
|
```
|
||||||
|
|
||||||
|
instead of
|
||||||
|
|
||||||
|
```nix
|
||||||
|
buildInputs = if stdenv.isDarwin then [ iconv ] else null;
|
||||||
|
```
|
||||||
|
|
||||||
|
As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild.
|
||||||
|
If this is done a follow up pull request _should_ be created to change the code to `lib.optional(s)`.
|
||||||
|
|
||||||
- Arguments should be listed in the order they are used, with the exception of `lib`, which always goes first.
|
- Arguments should be listed in the order they are used, with the exception of `lib`, which always goes first.
|
||||||
|
|
||||||
## Package naming {#sec-package-naming}
|
## Package naming {#sec-package-naming}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue