2017-05-24 22:55:12 +02:00
|
|
|
# info.nix -- install texinfo, set INFOPATH, create `dir` file
|
|
|
|
|
|
|
|
# This is a helper for the GNU info documentation system. By default,
|
|
|
|
# the `info` command (and the Info subsystem within Emacs) gives easy
|
|
|
|
# access to the info files stored system-wide, but not info files in
|
|
|
|
# your ~/.nix-profile.
|
|
|
|
|
|
|
|
# We set $INFOPATH to include `/run/current-system/sw/share/info` and
|
|
|
|
# `~/.nix-profile/share/info` but it's not enough. Although info can
|
|
|
|
# then find files when you explicitly ask for them, it doesn't show
|
|
|
|
# them to you in the table of contents on startup. To do that requires
|
|
|
|
# a `dir` file. NixOS keeps the system-wide `dir` file up to date, but
|
|
|
|
# ignores home-installed packages.
|
|
|
|
|
|
|
|
# So this module contains an activation script that generates the
|
|
|
|
# `dir` for your home profile. Then when you start info (and both
|
|
|
|
# `dir` files are in your $INFOPATH), it will *merge* the contents of
|
|
|
|
# the two files, showing you a unified table of contents for all
|
|
|
|
# packages. This is really nice.
|
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2017-10-15 16:03:35 +02:00
|
|
|
|
2017-05-24 22:55:12 +02:00
|
|
|
cfg = config.programs.info;
|
|
|
|
|
|
|
|
# Indexes info files found in this location
|
2018-07-29 18:15:50 +02:00
|
|
|
homeInfoPath = "${config.home.profileDirectory}/share/info";
|
2017-05-24 22:55:12 +02:00
|
|
|
|
|
|
|
# Installs this package -- the interactive just means that it
|
|
|
|
# includes the curses `info` program. We also use `install-info`
|
|
|
|
# from this package in the activation script.
|
|
|
|
infoPkg = pkgs.texinfoInteractive;
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2017-05-24 22:55:12 +02:00
|
|
|
options = {
|
|
|
|
programs.info = {
|
|
|
|
enable = mkEnableOption "GNU Info";
|
|
|
|
|
|
|
|
homeInfoDirLocation = mkOption {
|
2017-08-26 12:10:14 +02:00
|
|
|
default = "\${XDG_CACHE_HOME:-$HOME/.cache}/info";
|
2017-05-24 22:55:12 +02:00
|
|
|
description = ''
|
|
|
|
Directory in which to store the info <filename>dir</filename>
|
|
|
|
file within your home.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.sessionVariables.INFOPATH =
|
|
|
|
"${cfg.homeInfoDirLocation}\${INFOPATH:+:}\${INFOPATH}";
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
home.activation.createHomeInfoDir =
|
|
|
|
hm.dag.entryAfter [ "installPackages" ] ''
|
|
|
|
oPATH=$PATH
|
|
|
|
export PATH="${lib.makeBinPath [ pkgs.gzip ]}''${PATH:+:}$PATH"
|
|
|
|
$DRY_RUN_CMD mkdir -p "${cfg.homeInfoDirLocation}"
|
|
|
|
$DRY_RUN_CMD rm -f "${cfg.homeInfoDirLocation}/dir"
|
|
|
|
if [[ -d "${homeInfoPath}" ]]; then
|
|
|
|
find -L "${homeInfoPath}" \( -name '*.info' -o -name '*.info.gz' \) \
|
|
|
|
-exec $DRY_RUN_CMD ${infoPkg}/bin/install-info '{}' \
|
|
|
|
"${cfg.homeInfoDirLocation}/dir" \;
|
|
|
|
fi
|
|
|
|
export PATH="$oPATH"
|
|
|
|
unset oPATH
|
|
|
|
'';
|
2017-05-24 22:55:12 +02:00
|
|
|
|
2017-10-15 16:03:35 +02:00
|
|
|
home.packages = [ infoPkg ];
|
|
|
|
|
|
|
|
home.extraOutputsToInstall = [ "info" ];
|
2017-05-24 22:55:12 +02:00
|
|
|
};
|
|
|
|
}
|