Apropos: Difference between revisions

Pigs (talk | contribs)
m add category configuration
QuBe (talk | contribs)
Add home-manager section
Tags: Mobile edit Mobile web edit
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
By default as of NixOS 21.05, <code>apropos</code>, <code>whatis</code> and <code>man -k</code> do not find anything when run, because the man page index cache is not generated.  
By default as of NixOS 21.05, <code>apropos</code>, <code>whatis</code> and <code>man -k</code> do not find anything when run, because the man page index cache is not generated.  


To generate it manually (and again to update it when new software is installed), run:
To build the cache automatically, you can set this in your system configuration:
<syntaxhighlight lang="console">
<syntaxhighlight lang="nix">
$ sudo mkdir -p /var/cache/man/nixos
{
$ sudo mandb
  documentation.man.cache.enable = true;
}
</syntaxhighlight>
Or in older versions:
<syntaxhighlight lang="nix">
{
  documentation.man.generateCaches = true;
}
</syntaxhighlight>
</syntaxhighlight>
This will create an immutable cache in sync with <code>environment.systemPackages</code>. Since it is immutable, the <code>mandb</code> command (see below) will fail.


To enable automatically building the immutable cache, you can set in your system configuration:
If you are using home-manager, the above will not populate the cache with the programs installed that way, instead add this to your <code>home.nix</code>:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{
{
   documentation.man.generateCaches = true;
   programs.man.generateCaches = true;
}
}
</syntaxhighlight>
</syntaxhighlight>
Note that this will rebuild the cache every time you change anything in <code>environment.systemPackages</code>, and will make the <code>mandb</code> command fail.
 
Some programs might set one of these options to true by default, in that case you might still need to set the other to true manually. An example of such a program is [[fish]], which uses it to automatically create completions (see [fish_update_completions](https://fishshell.com/docs/current/cmds/fish_update_completions.html)).
 
To generate it manually, run:
<syntaxhighlight lang="console">
$ sudo mkdir -p /var/cache/man/nixos
$ sudo mandb
</syntaxhighlight>
This will need to be re-run to update the cache when new software is installed.


[[Category:Configuration]]
[[Category:Configuration]]