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.


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 - Loading...) 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.


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.


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.