doc: add styleguide on use of with to CONTRIBUTING.md#294383
doc: add styleguide on use of with to CONTRIBUTING.md#294383lolbinarycat wants to merge 4 commits intoNixOS:masterfrom
with to CONTRIBUTING.md#294383Conversation
There was a problem hiding this comment.
I think as-is, this is too narrow of a scope (focusing on meta only). Perhaps this should be phrased to discourage with in any scope where its use may cause confusion. Clarifying the use in meta within a couple of bullets is fine to me, as long as we also explain (and focus on) the general policy.
CONTRIBUTING.md
Outdated
|
|
||
| #### 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. |
There was a problem hiding this comment.
perhaps link to the nix.dev documentation here?
There was a problem hiding this comment.
i considered it, but honestly, i don't think very highly of that guide, as it frankly lacks a lot of nuance, and feels like it might as well call with a deprecated feature. it doesn't provide any examples of times it would be ok or even encouraged to use.
There was a problem hiding this comment.
That guide can be improved too: https://github.com/NixOS/nix.dev
There was a problem hiding this comment.
I think it would be great to improve the article on with with acceptable uses and a better explanation of the problems. We can also link it from here for completeness already though.
I think this contributing section here is still valuable since it's more Nixpkgs specific and doesn't necessarily apply to Nix in general.
Co-authored-by: éclairevoyant <848000+eclairevoyant@users.noreply.github.com>
|
Voicing my opinion as a with-hater, I am against merging this pull request. If the technical merits of banishing |
|
@AndersonTorres this PR does not "banish" the use of for example, nested |
There was a problem hiding this comment.
Discussed in the docs team meeting today.
I don't have much of an opinion here, I'm also not a fan of with, and don't think it would be problematic to have it in the style guide, but I can also understand @AndersonTorres' arguments.
CONTRIBUTING.md
Outdated
|
|
||
| #### 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. |
There was a problem hiding this comment.
I think it would be great to improve the article on with with acceptable uses and a better explanation of the problems. We can also link it from here for completeness already though.
I think this contributing section here is still valuable since it's more Nixpkgs specific and doesn't necessarily apply to Nix in general.
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-03-14-documentation-team-meeting-notes-113/41462/1 |
Co-authored-by: Silvan Mosberger <github@infinisil.com>
Co-authored-by: Silvan Mosberger <github@infinisil.com>
| 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`. |
There was a problem hiding this comment.
With the big effort going on to move away from meta = with lib;, this is certainly not "acceptable" anymore, today.
Closes #292468
Add a 👍 reaction to pull requests you find important.