How to install local GNU info docs?

I mostly work within Emacs, and prefer to access documentation via Info. Setting programs.info.enable = true; in my home manager config gives me access to most installed Info files, but sometimes I also need to view docs for packages not installed/not available through nixpkgs.
I ran into this script in home-manager but still do not understand where I need to put my local info files and how I let home-manager know where to find them. Any help would be appreciated

Presumably you’d need to get them here. I think the easiest way would be to create a simple package that installs the files into $out/share/info/, and then add that package to home.packages, if I understood what it’s doing correctly.

Thanks for responding. I haven’t ever written a Nix package before, so I don’t really understand yet what this would look like. Could you maybe say more on what I need to do?

https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-runCommand

Something like

  (pkgs.runCommand "my-info-package" {} "install -Dm444 ${./path/to/your/file} -t $out/share/info")

I’ve been struggling and failing to follow this suggestion and add a builder to my home-manager that does this since yesterday. I have my info files in a folder ~/.local/share/info and I have also tried to use the script I linked to include these files but keep getting into error after error, so I have given up. If anyone else runs into this question and manages to make it work please reply or message me.

I can’t help without exact code and full errors.

Thanks. I’ve attempted to partially retrace my steps since yesterday.

I am using this starter config. As suggested I dropped in the line:

(pkgs.runCommand "my-info-package" {} "install -Dm444 ${/home/qawqaw/.local/share/jacal.info} -t $out/share/info")

and (after running home-manager switch in impure mode got the error

 at /nix/store/ic0l09ih5bnkj3a7cwl5sykrfl0ra7b8-source/home-manager/home.nix:58:3:
           57|     };
           58|   (pkgs.runCommand "my-info-package" {} "install -Dm444 ${/home/qawqaw/.local/share/jacal.info} -t $out/share/info")
             |   ^

Removing the parentheses and retrying I then got an error:

  error: syntax error, unexpected '"', expecting '.' or '='
       at /nix/store/gafi2ivk953jkfiv6pwmn8xhphlppd5i-source/home-manager/home.nix:53:17:
           52|   ];
           53| pkgs.runCommand "my-info-package" {} "install -Dm444 ${/home/qawqaw/.local/share/jacal.info} -t $out/share/info"
             |                 ^
           54|

I tried various other modifications, none of which worked. I went back to the original info.nix to see if I was missing something, and tried to add my local folder to the INFOPATH

sessionVariables = {
  INFOPATH = "~/.local/share/info:\${INFOPATH}";
};

running install-info manually on each file did produce an dir file, but it was not merged into the main one as the info.nix suggested, so running info gdb, for example failed even though the gdb info file was supposedly in the INFOPATH. I then tried modifying the script in info.nix to install the local files before reloading my profile:

home.activation.updateLocalInfoDir = lib.hm.dag.entryAfter ["installPackages"] ''
  $DRY_RUN_CMD mkdir -p "$HOME/.local/share/info"
  $DRY_RUN_CMD rm -f "$HOME/.local/share/info/dir"
  
  if [[ -d "$HOME/.local/share/info" ]]; then
    find -L "$HOME/.local/share/info" \( -name '*.info' -o -name '*.info.gz' \) \
      -exec ${pkgs.texinfo}/bin/install-info '{}' \
      "$HOME/.local/share/info/dir" \;
  fi
'';

Again, the dir file was correctly generated in my local folder, but not merged with the global one. Simply moving the info files into /.nix-profile/share/info/ either manually or with a home-manager script didn’t work: I didn’t have write access and do not want to change permissions for home-manager just for this. I went down many other frustrating rabbit holes that I cannot now trace, so if anyone can show me code that is able to, given a local folder of info files, make those files globally accessible after running home-manager switch I’d appreciate it. I’d also love to know how to make it pure.

This line needs to go inside the list provided to home.packages.
And keep the parens.

I may be doing something silly, but I had tried this, and my packages list looks something like this:

home.packages = with pkgs; [
    coreutils
    curl
    diskonaut 
...
    (pkgs.runCommand "my-info-package" {} "install -Dm444 ${/home/qawqaw/.local/share/jacal.info} -t $out/share/info")
  ];
}

An impure home-manager switch still produced the following error:

       error: syntax error, unexpected '('
       at /nix/store/pq7xkin4famvhw8gwiiv11vrpqbcm87b-source/home-manager/home.nix:58:3:
           57|     };
           58|   (pkgs.runCommand "my-info-package" {} "install -Dm444 ${/home/qawqaw/.local/share/info/jacal.info} -t $out/share/info")
             |   ^
           59|   # Nicely reload system units when changing configs

That sounds impossible. What’s in the ...? The error message clearly shows }; on the previous line.

And I’m guessing you copied a certian starter config, I’d somewhat advise against that in any case…

Just a big list of more similar packages, all one word.

Can you post the whole file? This is really difficult to diagnose with all the paraphrasing.

Sorry about that. I was trying not to disclose too much identifying information. You were right, there were additional issues (including my editor setting up additional git lock files!) so the switch command was running on old configurations.

I did just manage to get it to work with the following code:

(pkgs.runCommand "local-info-files" {
      src = ./info;
    } ''
      mkdir -p $out/share/info
      cp $src/*.info $out/share/info/
  
      for file in $out/share/info/*.info; do
        ${pkgs.texinfo}/bin/install-info "$file" $out/share/info/dir
      done
    '')

where the files to be added are in a folder ./info relative to home.nix
I would never have figured out how to do this without the help, so thank you!

1 Like