From aab7baf5191946be4f37d0f65d3da51fa0a33eef Mon Sep 17 00:00:00 2001 From: binarycat Date: Fri, 8 Mar 2024 19:21:20 -0500 Subject: [PATCH 1/4] doc: add styleguide on use of `with` to CONTRIBUTING.md Closes #292468 --- CONTRIBUTING.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 115dd993ea62f..f9bfe81bdbd45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. From 8b27943ac8148be2783bc6de070bc15af2b4ab92 Mon Sep 17 00:00:00 2001 From: lolbinarycat Date: Mon, 11 Mar 2024 08:49:15 -0400 Subject: [PATCH 2/4] CONTRIBUTING.md: fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: éclairevoyant <848000+eclairevoyant@users.noreply.github.com> --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f9bfe81bdbd45..3d8c7ee1f3e51 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -753,7 +753,7 @@ 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: +unacceptable uses: - `with lib;` anywhere outside of `meta` - nested `with` anywhere outside of `meta` - `with` at the top of a file From 0e45fe72b7a701399ad4776909a22ef9ca23f216 Mon Sep 17 00:00:00 2001 From: lolbinarycat Date: Thu, 14 Mar 2024 16:03:25 -0400 Subject: [PATCH 3/4] Update CONTRIBUTING.md Co-authored-by: Silvan Mosberger --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3d8c7ee1f3e51..6ac7f24bfb594 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -757,6 +757,6 @@ unacceptable 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 +- `with` at the start of a longer expression that might not fit onto a single screen. uses of `with` other than those listed here are left up to the discretion of PR reviewers. From e3c0fdbc34f5399af3d1ca3011f46b6bf2f8e48f Mon Sep 17 00:00:00 2001 From: lolbinarycat Date: Thu, 14 Mar 2024 16:03:56 -0400 Subject: [PATCH 4/4] Update CONTRIBUTING.md (fix typo) Co-authored-by: Silvan Mosberger --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ac7f24bfb594..d0f91d3dccf42 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -743,7 +743,7 @@ Names of files and directories should be in lowercase, with dashes between words #### 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. +`with` is a somewhat controversial feature of nix syntax, it can reduce repetition, but easily can make code unreadable or buggy if used carelessly. recommended uses: - `meta.maintainers = with lib.maintainers; [ ... ]`