Skip to content

Commit

Permalink
doc: add styleguide on use of with to CONTRIBUTING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
binarycat committed Mar 9, 2024
1 parent 2be8f78 commit aab7baf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,23 @@ Names of files and directories should be in lowercase, with dashes between words
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)`.
#### Use of `with`
`with` is a somewhat controversial feature of nix syntax, it can reduce repition, but easily can make code unreadable or buggy if used carelessly.
recommended uses:
- `meta.maintainers = with lib.maintainers; [ ... ]`
- for packages with **multiple** licenses: `meta.license = with lib.licenses; [ ... ]`
acceptable uses:
- `meta = with lib; { ... }`
this allows you to not have to write `lib` twice for `licenses` and `maintainers`, at the cost of nesting `with`.
unaccaptable uses:
- `with lib;` anywhere outside of `meta`
- nested `with` anywhere outside of `meta`
- `with` at the top of a file
- `with` at the start of an expression that spans
uses of `with` other than those listed here are left up to the discretion of PR reviewers.

0 comments on commit aab7baf

Please sign in to comment.