summary refs log tree commit diff
path: root/modules/programs/info.nix
blob: 30c25cf34206beda496c4f46805296f81badc6a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{config, pkgs, ...}:

let

  # Quick hack to make the `info' command work properly.  `info' needs
  # a "dir" file containing all the installed Info files, which we
  # don't have (it would be impure to have a package installation
  # update some global "dir" file).  So this wrapper script around
  # "info" builds a temporary "dir" file on the fly.  This is a bit
  # slow (on a cold cache) but not unacceptably so.
  infoWrapper = pkgs.writeScriptBin "info"
    ''
      #! ${pkgs.stdenv.shell}

      dir=$(mktemp --tmpdir -d "info.dir.XXXXXX")

      if test -z "$dir"; then exit 1; fi

      trap 'rm -rf "$dir"' EXIT

      shopt -s nullglob

      for i in $(IFS=:; echo $INFOPATH); do
          for j in $i/*.info; do
              ${pkgs.texinfo}/bin/install-info --quiet $j $dir/dir
          done
      done

      INFOPATH=$dir:$INFOPATH ${pkgs.texinfo}/bin/info "$@"
    ''; # */

in

{
  environment.systemPackages = [ infoWrapper pkgs.texinfo ];
}