fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert Helgessoninfo: generate dir file directly in profileb3498ccc

master
2.1 KiB63 linesraw
1# info.nix -- install texinfo and create `dir` file
2
3# This is a helper for the GNU info documentation system. By default,
4# the `info` command (and the Info subsystem within Emacs) gives easy
5# access to the info files stored system-wide, but not info files in
6# your ~/.nix-profile.
7
8# Specifically, although info can then find files when you explicitly
9# ask for them, it doesn't show them to you in the table of contents
10# on startup. To do that requires a `dir` file. NixOS keeps the
11# system-wide `dir` file up to date, but ignores files installed in
12# user profiles.
13
14# This module contains extra profile commands that generate the `dir`
15# for your home profile. Then when you start info (and both `dir`
16# files are in your $INFOPATH), it will *merge* the contents of the
17# two files, showing you a unified table of contents for all packages.
18# This is really nice.
19
20{ config, lib, pkgs, ... }:
21
22with lib;
23
24let
25
26  cfg = config.programs.info;
27
28  # Installs this package -- the interactive just means that it
29  # includes the curses `info` program. We also use `install-info`
30  # from this package in the activation script.
31  infoPkg = pkgs.texinfoInteractive;
32
33in {
34  imports = [
35    (mkRemovedOptionModule [ "programs" "info" "homeInfoDirLocation" ] ''
36      The `dir` file is now generated as part of the Home Manager profile and
37      will no longer be placed in your home directory.
38    '')
39  ];
40
41  options.programs.info.enable = mkEnableOption "GNU Info";
42
43  config = mkIf cfg.enable {
44    home.packages = [
45      infoPkg
46
47      # Make sure the target directory is a real directory.
48      (pkgs.runCommandLocal "dummy-info-dir1" { } "mkdir -p $out/share/info")
49      (pkgs.runCommandLocal "dummy-info-dir2" { } "mkdir -p $out/share/info")
50    ];
51
52    home.extraOutputsToInstall = [ "info" ];
53
54    home.extraProfileCommands = let infoPath = "$out/share/info";
55    in ''
56      if [[ -w "${infoPath}" && ! -e "${infoPath}/dir" ]]; then
57        PATH="${lib.makeBinPath [ pkgs.gzip infoPkg ]}''${PATH:+:}$PATH" \
58        find -L "${infoPath}" \( -name '*.info' -o -name '*.info.gz' \) \
59          -exec install-info '{}' "${infoPath}/dir" ';'
60      fi
61    '';
62  };
63}