NixOS / nixos-search

Search NixOS packages and options
https://search.nixos.org
MIT License
401 stars 100 forks source link

Allow defaulting to nixpkgs (non-NixOS) instead of nixos #427

Open geofft opened 2 years ago

geofft commented 2 years ago

The search site is super useful for us at my site, except that since we're running Nix on top of Debian instead of NixOS, users need to use the "On non-NixOS" tab instead of the "On NixOS" one, and it isn't particularly obvious to a casual user that they need to notice the tab and click on it.

I'm not asking to change the overall default (and I'm betting you don't want to), but it would be helpful if there's some way we could present our users a view that defaults to the non-NixOS view. Some possible thoughts:

I'm happy to contribute a patch if any of these seem like a good idea to you. Thanks!

ncfavier commented 2 years ago

I'd much rather unify what we currently have than split things further. The only difference between the two tabs is changing a channel name from nixpkgs to nixos, surely we can convey both instructions on a single screen.

Something like

$ nix-env -iA nixpkgsOrNixos.hello

or

$ nix-env -iA channel.hello   # `channel` is usually `nixos` on NixOS and `nixpkgs` on non-NixOS

or

$ nix-env -iA nixos.hello     # on NixOS
$ nix-env -iA nixpkgs.hello   # on non-NixOS
ysndr commented 2 years ago

I agree with these. Its basically the same command More so, with the new nix command we have the additional (but mutually exclusive) way to install using profiles

nix profile install nixpkgs#hello

And what still bothers me is that we do not mention configuration.nix but encourage the non-nix'y way of installing software. For quick use of software telling people about nix shell appears quite important to me as well..

ncfavier commented 2 years ago

The whole idea of having those instructions there feels a lot like "giving a man a fish" anyway. I think Nix users should be expected to know how to install a package (using the method of their choice) given its attribute name. Perhaps we should then somehow clarify that the blue linky thing is the attribute name while the thing after "Name:" is the package name.

samueldr commented 2 years ago

In before either of yours' time, and before this was redone in Elm, we had discussed about the problem, and what we ended up deciding was to wait on the redesign of the search app, and on the redesign of the Nix CLI to decide how to approach this.

The solution should probably avoid using nix-env on NixOS, and prefer recommending any other way (nix-shell, configuration.nix) so it makes things really awkward to convey through a small snippet in the search.

My gut feeling is the search should probably not describe any way to use the data, but provide a link to a ressource explaining what to do with the attribute name. This way we only need to put the attribute name at the center of the stage, and provide educational resources.

ysndr commented 2 years ago

As a contrary example, sites like npm or pip or crates all show an instruction on how to install. Linking to a place that discern the different methods would be important nonetheless but having a copy able snippet to just get a shell with the program I still consider most useful.

garbas commented 2 years ago

This is going to be solved with Nix 3.0 namely with flakes.

Until then lets persist the selection in localstorage for each user.