Skip to content

Add nixpkgsFlake.lib.lib#398332

Draft
roberth wants to merge 2 commits intoNixOS:masterfrom
roberth:lib.lib
Draft

Add nixpkgsFlake.lib.lib#398332
roberth wants to merge 2 commits intoNixOS:masterfrom
roberth:lib.lib

Conversation

@roberth
Copy link
Member

@roberth roberth commented Apr 13, 2025

Best reviewed commit-by-commit due to reformatting.

A simple preparation for plans discussed in

Crucially, without these changes, the identifier lib has too many
meanings and therefore doesn't mean anything, making it unmaintainable.

Things done

  • 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.

roberth added 2 commits April 13, 2025 13:06
A simple preparation for plans discussed in
- NixOS#376033

Crucially, without these changes, the identifier `lib` has too many
meanings and therefore doesn't mean anything, making it unmaintainable.
This will make future changes to the `lib` attribute easier to
reason about.
@github-actions github-actions bot added 6.topic: flakes The experimental Nix feature 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Apr 13, 2025
@roberth roberth requested review from arianvp, infinisil, lf- and r-vdp April 27, 2025 14:00
@roberth
Copy link
Member Author

roberth commented Apr 27, 2025

Alternative idea: maybe recognizing lib as a "known but unchecked" flake attribute was a mistake and all flakes should use a different attribute name, library if possible. Nixpkgs would then have

(or libraries, or libs)

@lf-
Copy link
Member

lf- commented Apr 27, 2025

I think the alternative idea sounds maybe better. It's certainly really confusing that nixpkgs lib just has some random nixos bits overlaid on top of it but only when using it from a flake. Without those bits it's pretty clear what lib is in nixpkgs.

Part of why this is so weird is precisely because of the rigid flake output schema and the flake output schema requiring that you call the library stuff lib which is confusable with nixpkgs lib, the thing that everyone knows about. So it seems to me that the less confusing solution is to remove the namespace collision, perhaps by making lib in the flake just the normal nixpkgs lib and moving the nixos bits into a different attribute name that violates the flake spec, which, whatever, loads of violations of that thing around; I grant I have little care for strictly following the flake output schema given the numerous other design flaws. Alternatively they could both be moved into a libraries output and thus break more people.

Having the libraries output (with a lib subattribute) be called lib is confusing because most people see nixpkgs.lib and they think pkgs.lib, not a secret other thing called lib. There's multiple things called lib in nixpkgs to be sure, like haskell.lib, but that one's called hlib conventionally and thus isn't particularly confusing.

@roberth roberth mentioned this pull request Jun 2, 2025
13 tasks
@roberth roberth marked this pull request as draft June 2, 2025 10:31
@roberth
Copy link
Member Author

roberth commented Jun 2, 2025

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jun 25, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 6, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: flakes The experimental Nix feature 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants