Why does a package shows up on NixOS Search page, but not in `nix search`?

There are multiple results for fourmolu on both 21.11 and the unstable channels.

https://search.nixos.org/packages?channel=21.11&from=0&size=50&sort=relevance&type=packages&query=fourmolu

But when I do nix search nixpkgs fourmolu, it comes out to be empty.
Any idea why this is happening?

I have enabled flakes support. Is it because of this?

Whereas, ormolu appears on both the search page (NixOS Search) and nix search nixpkgs ormolu.

1 Like

fourmolu exists within the haskellPackages package set. Which isn’t recursed for derivations:

haskellPackages = dontRecurseIntoAttrs haskell.packages.ghc8107;

nix search respects this setting.

4 Likes

To elaborate on that, the search uses this extra configuration file to index sub package sets that are skipped normally.

The sub package sets are skipped at the moment since they usually take quite some time to evaluate which slows down nix-env considerably. In the future this may be not as big a concern as nix search caches its result.

4 Likes

Is this also the reason nix-env -i haskellPackages.fourmolu -f '<nixpkgs>' doesn’t work whereas nix-env -iA haskellPackages.fourmolu -f '<nixpkgs>' does?

What does -A flag do here?

-A means attr. It’s looking specifically for haskellPackages.fourmolu.

just -i means install, and it use fuzzy logic to find a package named haskellPackages.fourmolu, however, it’s name is fourmolu.

Also, nix-env I believe honors dontRecurseIntoAttrs as well, so it won’t be aware of haskellPackages.fourmolu unless specifically referenced by -A.

That being said, nix-env should be avoided, it was developed as a stop-gap for user installation of packages early in the development of nix. Most experienced users of nix will use configuration.nix, home-manager, nix-shell, or flakes for package consumption. These all have the benefit that you can version control the file, and not rely on the state of user installed files.

4 Likes