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

doc: don't recommend listing packages with nix-env #317392

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

fricklerhandwerk
Copy link
Contributor

Description of changes

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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

Copy link
Member

@sternenseemann sternenseemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just seems silly to me. There's nothing wrong with using nix-env in this way and the presented alternative is strictly worse?

@fricklerhandwerk
Copy link
Contributor Author

fricklerhandwerk commented Jun 5, 2024

Do we want to get people away from nix-env or not? I thought it was widely agreed-upon that using nix-env should not be encouraged, and that the only stable, reliable, and (mostly) sane interface to Nix is the Nix language.

@Atemu
Copy link
Member

Atemu commented Jun 5, 2024

Listing packages given a (possibly nested) attrset while ignoring any eval errors is one of the only sensible uses of nix-env. What we want to get away from is using nix-env for imperative package management because it really sucks quite a lot at that.

@fricklerhandwerk
Copy link
Contributor Author

@Atemu would I be missing something crucial if I claim this can be done in the 4-liner I added as an example?

@Atemu
Copy link
Member

Atemu commented Jun 5, 2024

Yes, it'd fall on its nose on the first attribute that doesn't eval or doesn't have a version. haskellPackages is quite well behaved in this regard but go I dare you to this on pkgs... The only way to get this sort of information reliably on pkgs is nix-env; I've been there.

@fricklerhandwerk
Copy link
Contributor Author

fricklerhandwerk commented Jun 6, 2024

Incredible... just ignore assertions?

https://github.com/NixOS/nix/blob/master/src/nix-env/nix-env.cc#L195
https://github.com/NixOS/nix/blob/master/src/libexpr/get-drvs.cc#L311-L330

How about we all forget that code ever existed, merge this PR, and focus on something else?

@Atemu
Copy link
Member

Atemu commented Jun 6, 2024

I don't have a strong opinion on this and I don't maintain this part of Nixpkgs. I also don't have anything more to contribute to this discussion, so I'm going to unsubscribe here.

@fricklerhandwerk
Copy link
Contributor Author

@maralorn @ncfavier opinions?

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-06-03-documentation-team-meeting-notes-131/46810/1

@maralorn
Copy link
Member

I have no strong opinion on this and I frankly don’t feel like arbitrating this on my free time. So I will just leave some thoughts:

I empathize with the desire to get rid of references to nix-env. I mean in general even mentioning that packages won’t get listed by nix-env -qa seems quite irrelevant because that workflow seems rather alien to me. I wonder if anyone ever actually needs this on the command line.

On the other hand the fact that this command becomes so much more complicated without it is annoying, eval errors will slip in from time to time and this usage of nix-env seems harmless in contrast to the usual critique of that command.

I think the biggest advantage of having the listing in the manual is that it makes the package set a bit more graspable.

My usual workflow is search.nixos.org or nix repl + tabcompletion, I don‘t know if that’s representative but if it is it might be the way to go also for the manual …

@sternenseemann
Copy link
Member

Incredible... just ignore assertions?

You fundamentally have to do this when dealing with how nixpkgs works. haskellPackages is a very tame corner of nixpkgs, but even here you'll need to deal with assertions if you want to know outPaths.

the only stable, reliable, and (mostly) sane interface to Nix is the Nix language.

It's frankly bizarre to state that to list packages you should

  1. Install jq,
  2. Copy and paste some code snippet that is specific to haskellPackages

instead of using a subcommand of nix-env(1) that is not problematic.

I thought it was widely agreed-upon that using nix-env should not be encouraged

Yes, nix-env for package management is to be discouraged, but that concerns nix-env -u and nix-env -i. I just don't see any alternative to nix-env -qP in this case.

this removes the hard-coded listing, which can later be replaced by
a dynamic one as for the Python interpreters
@maralorn
Copy link
Member

I like this in general.

I still think that having a few example packages listed in the Haskell section makes it easier to quickly grasp the structure of the package sets in question. But overall this change is already an improvement.

@fricklerhandwerk
Copy link
Contributor Author

@maralorn I'd prefer to generate these examples automatically. For instance, we could list all compilers, and show a small subset of packages. As noted in the commit message, we have precedence with Python. It just needs time to sit down and get it into shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants