Search code examples
emacsspacemacsnixos

How do I add additional packages in scope for Spacemacs in Nixos?


I'm trying to setup Spacemacs on my Nixos system. I installed Emacs using the nixos.emacs package. One of the spacemacs layers that I'm trying to install requires the command-line program aclocal, but it can't find it on my system.

I believe one solution would be to just add the Nix package that contains aclocal (I believe it's autoconf) to my environment.systemPackages. However, I don't like this solution because it adds the autoconf package to my global scope. I would rather that only Emacs have access to autoconf, so that (1) it keeps my global list of packages clean, and (2) I don't accidentally delete it in the future, if I forget why I installed it.

Is there a way to do this in Nixos? I think it might involve overriding some attributes of the emacs derivation.

EDIT: To be clear, I don't need the autoconf package to be an input to building Emacs---I want Emacs to be built exactly as it currently is---but I want the autoconf library to be accessible to any of the binaries, and the child processes, of emacs, emacsclient, etc. when I run them.


Solution

  • you can wrap emacs binary with wrapProgram and prefix the $PATH with list of packages you want (you will need to add makeWrapper to buildInputs). eg.

    postInstall = ''
      wrapProgram "$out/bin/emacs" --prefix PATH : "${autoconf}/bin"
    '';
    

    an example from nixpkgs would be here but there are more examples (grep wrapProgram pkgs -R | grep '\-\-prefix PATH').