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