How to use Nix emacs-overlay with nix-env?

272 views Asked by At

I use Nix on Darwin / Mac OS. The Nix Community provides and Emacs-Overlay that has the latest versions of many packages for Emacs packaged for Nix. When I apply the overlay by putting this into ~/.config/nixpkgs/overlays.nix ...

[
  (import (builtins.fetchTarball { url = "https://github.com/nix-community/emacs-overlay/archive/master.tar.gz"; })) ]; })
]

..., then, I'm able to install Emacs from master-branch with nix-env -i emacs-git. But still, I am not able to install the latest packages for Emacs with nix-env, e.g. Ement.el.

I found out, that I can install the latest version of Ement.el with this command:

nix-shell --expr 'with (import <nixpkgs> { overlays = [ (import (builtins.fetchTarball { url = "https://github.com/nix-community/emacs-overlay/archive/master.tar.gz"; })) ]; }); (emacsPackagesFor emacsGit).elpaPackages.ement'

But I would like to be able to install it conveniently with nix-env.

To achieve this, I tried to put this into my overlays.nix:

[
  (final: prev:
    (prev.lib.composeManyExtensions [
      (import (builtins.fetchTarball { url = "https://github.com/nix-community/emacs-overlay/archive/master.tar.gz"; }))
      (withBoth: withEmacsOverlay: withEmacsOverlay.emacsPackagesFor withEmacsOverlay.emacsGit)
    ] final prev)
  )
]

But it leads to this error:

$ nix-env -iA nixpkgs.elpaPackages.ement
error: infinite recursion encountered

       at /nix/store/lxyj36fz3fbjpzwxf2j852a8dim16vkv-nixpkgs/nixpkgs/pkgs/top-level/emacs-packages.nix:60:11:

           59|   pkgs ? pkgs'
           60|   , lib ? pkgs.lib
             |           ^
           61|   , elpaPackages ? mkElpaPackages { inherit pkgs lib; } self

So. How can I apply the overlay in such a way that I can install the packages for Emacs with nix-env?

0

There are 0 answers