How to use Emacs packages installed via Home Manager?

#1

I"ve the following snippet in ~/.config/nixpkgs/home.nix:

programs.emacs = {
  enable = true;
  extraPackages = epkgs: with epkgs; [
    use-package
  ];
};

And this at the beginning of ~/.emacs.d/init.el:

(eval-when-compile
  (require 'use-package))

But when I start Emacs I get the following error message

Warning (initialization): An error occurred while loading ‘/home/user/.emacs.d/init.el’:

File is missing: Cannot open load file, No such file or directory, use-package

I based this snippet on what I found in John Wiegley’s Emacs dotfiles and the documentation for use-package.

What should I do to get Emacs recognize packages installed with Home Manager?

0 Likes

#2

I’m not exactly sure what’s wrong, but here are some suggestions:

  1. Make sure the emacs you are running was installed with home-manager
  2. Try (require 'package)(package-initialize) before requiring use-package.
0 Likes

#3

I’m tempted to just delete this thread…

I forgot to run home-manager switch. Only built the derivation earlier.

2 Likes