Cannot enable "nix search"

I have a freshly installed system, 24.11, using the minimal install ISO.

user@nixos ~> nix search connect
error: experimental Nix feature 'nix-command' is disabled; add '--extra-experimental-features nix-command' to enable it
user@nixos ~ [1]> nix --extra-experimental-features nix-command
error: no subcommand specified
Try 'nix --help' for more information.
user@nixos ~ [1]> nix --extra-experimental-features nix-command search
path '/home/user' does not contain a 'flake.nix', searching up
error: could not find a flake.nix file

What is your goal?
Are you trying to search connect in nixpkgs?

Close but no cigar:

nix --extra-experimental-features nix-command search nixpkgs#connect

The --extra-experimental-features is a flag, and you’re giving it the value nix-command. The rest of the command should stay the same.

You can make that setting permanent by adding to your configuration.nix:

nix.settings.experimental-features = [ "nix-command" ];

… and rebuilding. You won’t need to faff around with that flag anymore afterwards, but note that this is an experimental feature, and it may change.

1 Like

Read nix search --help

Thanks, adding it to the config is a good solution!

This is not easy to find! And using that silly flag every time cant honestly be the recommended solution!

UX issue guys! Users need to be able to search for packages…

Yes, it’s deliberately not streamlined, it’s experimental. That’s why the flag is in your way. The UX is deliberately poor to prevent uninformed use.

An unexpected change to the nix search CLI is in fact why that flag exists; users got upset when it changed because they didn’t realize it was considered experimental.

The non-experimental equivalent is variants of nix-env -Q, which can be used without any additional configuration.

There’s also search.nixos.org which is very nice if you’re ok with a non-TUI option.

1 Like

Interesting! Gotta dig more into the nix thing to understand that background.

Yes, I used the website and found a ton of cool stuff

if commands such as this are experimental, then why do they show up so many places (e.g the nix man page)?
It’s incredibly frustrating to open a man page (which ought to match the command very well) and be confronted immediately with misinformation. I think I tried half of the main commands listed, only for every one of them to fail with this dumb warning. Either stabilize these subcommands so the flag is unnecessary, or remove them from the top of the manpage.

1 Like

That’s because the entire nix 3.0 interface is experimental. If you use man nix you’re looking at the manual for the experimental commands - they are effectively a redesign of all nix commands, making them use the modern subcommand-style of CLI design, which yeah, that has the major benefit of cleaner man indexing.

Basically everybody agrees that it’d be nice to stabilize this, but since they were introduced alongside the massive flakes feature, and parts of them were tightly coupled to aspects of this feature, and that feature in turn has significant blockers, there’s been some gridlock. There’s a plan to divorce these concepts, but it has barely started, and there isn’t sufficient funding to pay folks to do it, so mostly this is chugging along sluggishly. It’s quite the can of worms.

If you want manuals for the non-experimental commands, those still follow a very mid-2000s CLI design, and are split into multiple commands. The main ones are nix-shell, nix-build, nix-store and nix-env, though there are a few others.

Since I’ve mentioned nix-env a few times, I should point out that it really ought to only be used for package search. It has lots of UX issues.

Really, I’d suggest reading the (official, under the nix.dev and nixos.org domains) online manuals for a while, until you’re more familiar with how things work. After that the man pages are reasonable reference works.

2 Likes

Thanks, I wasn’t aware. It’d be nice if the man page said it was experimental and recommended the other resources :slight_smile:

1 Like

It does, you just missed it. Everything in and around nix warns about this, I still can’t understand how people miss it.

1 Like

I see it now, at the very top. Could be my brain said “banner ad!” and skipped it. Given the insidious nature of advertising, I try to completely ignore ads; this was probably collateral damage. Unfortunately not the first…

1 Like