A Nix function for configuring Emacs

Posted on 2019-07-15

I used to use a small nix function for getting an emacs distribution given a configuration file. I stopped using it; and decided to put it on GitHub before I delete it from my system, hoping someone to find it useful.

pkgs = import <nixpkgs> {};
emacsWithConfig = pkgs.callPackage 
  (builtins.fetchTarball "")
emacsWithConfig ''
  (require 'use-package)

  (use-package doom-themes
    (load-theme 'doom-molokai t))

  (use-package undo-tree
    :defer 2
    (setq undo-tree-visualizer-timestamps t)

  (use-package magit
    ("C-x m" . magit-status))

The above code will:

  1. Parse the given script to find the use-package usages and collect the required packages.
  2. Use pkgs.emacsWithPackages to get an emacs distribution with the required packages.
  3. Bytecompile the script.
  4. Wrap pkgs.emacs to load given script by default.

It is not terribly useful, since it is just a shorthand syntax for pkgs.emacsWithPackages. But still it makes you not worry about keeping two package lists in sync.

As I said before, I am not using it anymore; so please feel free to fork or vendor it.

You can find the code on

Powered by Zola.
© Utku Demir, 2019