Porting emacs config to Nixos (using home-manager)


I’m in the process of switching to NixOS, and started porting my config. I decided to go with home-manager and I’m more or less following the recommendations found on this blog. However, I’m hitting a wall with emacs, for which many plugins are broken. Here is my current config and here is what I see on startup:

Loading /nix/store/gd16zhzic956appadcj80sf18an9h5d7-emacs-26.3/share/emacs/site-lisp/site-start.el (source)...done
Loading /home/corentin/.emacs.d/custom.el (source)...
Loading /home/corentin/.emacs.d/custom.el (source)...done
Key Chord mode on
[Treemacs] Warning: couldn’t find hl-line-mode’s background color for icons, falling back on unspecified-bg.
[Treemacs] Python3 not found, advanced git-mode and directory flattening features will be disabled.
Error (use-package): auto-dim-other-buffers/:init: Symbol’s function definition is void: auto-dim-other-buffers-mode
Error (use-package): company/:catch: Symbol’s function definition is void: company-tng-configure-default
Error (use-package): projectile/:init: Symbol’s function definition is void: projectile-mode
Error (use-package): flycheck/:init: Symbol’s function definition is void: global-flycheck-mode

I’m using the emacs overlay project to install the plugins, since I’ve seen it being recommended.

Does anyone know why these plugins are broken for me? I have also tries not using the emacs overlay, and install everything from MELPA (this is what I do on my non-NixOS machines) but most plugins failed to install :frowning:

I’m not sure what

Error (use-package): company/:catch: Symbol’s function definition is void: company-tng-configure-default

is about but the others I assume you can resolve by letting use-package know that the functions exists. E.g. for flycheck try changing

(use-package flycheck


(use-package flycheck
  :commands global-flycheck-mode
1 Like

Thanks you so much @rycee that fixes it !
Out of curiosity do you know why this happen only on NixOS?
I seems that I should have seen that on the other distros as well.

And thank you for home-manager, it is amazing!

1 Like

Unfortunately, I don’t know why that is. My knowledge of Emacs is limited to using it and hacking together a configuration that mostly works :slightly_smiling_face:

You might also like his emacs-init stuff. I love it.


@rycee @bbigras do you have any more info about emacs-init?
Is there any docs / comparisons to other nix based emacs configurations?

I’m busy right now, but you can check my emacs.nix config:

There is some documentation of the options but nothing more general. There is not much to say, though. The module more or less generates a configuration with some arbitrary code in the beginning and end, with a list of use-package calls in between.

It shouldn’t - it looks like perhaps the load order changes (so other packages’ symbols aren’t in scope anymore before your packages load), or perhaps you had cached compiled files that never updated somehow.

Personally I like using matthewbauer’s use-package scanner to generate that long list of use-package’d packages automatically, too: bauer/use-package-list.el at b624570c8f76d4f0a0be8fd1f358b2a3d3746a4b · matthewbauer/bauer · GitHub.