Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: improve readability of meta using "with lib;" #373548

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zeuner
Copy link
Contributor

@zeuner zeuner commented Jan 13, 2025

This PR changes a lot of packages treewide where meta refers to lib to the form meta = with lib; [...].

This improves readability of the attr expression. Furthermore, in many PRs that add a package there is a review that asks for adding or removing with lib; from the meta expression (I encountered both requests). It would be more efficient if there was one way to write meta on which we can all agree. There is https://nix.dev/guides/best-practices.html#with-scopes stating that with scopes should not be used for large scopes. meta could be considered a small scope, though.

There is also the opposite done in #373573. Of course, it only makes sense to merge either this PR or the other one. I can live with either choice, but the codebase should reflect that choice (which is what this PR aims for), and it should be documented.

For now, I only consider .nix files that are already formatted with nixfmt.

Things done

  • Verified all patches leave the value of the meta attr they touch unchanged.
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 13, 2025
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: qt/kde 6.topic: kernel The Linux kernel 6.topic: emacs Text editor 6.topic: vim 6.topic: java Including JDK, tooling, other languages, other VMs 6.topic: vscode 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Jan 13, 2025
@fabaff
Copy link
Member

fabaff commented Jan 13, 2025

#371665 goes for the removal of with lib;

@emilazy
Copy link
Member

emilazy commented Jan 13, 2025

See #208242 for a bunch of discussion, #208242 (comment) for a general argument against with, and #208242 (comment) for a pitfall that meta = with lib; specifically has run into in practice.

(I personally dislike with in all contexts but that’s just me. I think the overall direction of stuff we’ve merged and reviews that have happened are firmly pointed at less meta = with lib; though, even though I dislike when people nitpick it in the contributions of others, especially on unrelated changes. I doubt we are going to resolve this by warring PRs, though.)

@drupol
Copy link
Contributor

drupol commented Jan 13, 2025

Hello,

I'm surprised with this PR, we (the maintainers) are trying to get rid of with lib; in every PR we review, especially when they are in front of an attribute set.

It may improve readability (and I'm not sure of that, this is opinionated), but it may mess with any kind of static analysis tools the Nix language might have.

So, I don't agree with this PR, at all.

@zeuner
Copy link
Contributor Author

zeuner commented Jan 14, 2025

No intent to go against a consensus of writing meta without with lib;. This is why there is also #373573. Personally, I don't care which route to take. Just thinking that it doesn't make sense to say we don't want that pattern, while keeping more than 20.000 occurrences of it in the codebase. Making the codebase more uniform reduces the probability of contributors taking an existing (read: having been positively reviewed at some point) package as a basis for their own package, and having reviewers complain about a pattern they just took from the existing package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: emacs Text editor 6.topic: java Including JDK, tooling, other languages, other VMs 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab 6.topic: kernel The Linux kernel 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: qt/kde 6.topic: vim 6.topic: vscode 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants