nix-community / nix-doom-emacs

doom-emacs packaged for Nix [maintainers=@thiagokokada]
MIT License
213 stars 43 forks source link

missing 'version' attribute with custom emacsWithPackages from emacs-overlay #141

Open remi-gelinas opened 2 years ago

remi-gelinas commented 2 years ago

I'm trying to set up emacs package management in Nix specifically rather than using the builtin nix-straight management, and I noticed the emacsPackage option allows you to provide a custom emacs package to use to derive doom-emacs.

I've added the community emacs-overlay as a flake input (and made sure nix-doom-emacs follows the same pinned version). I've set emacsPackage to a custom build with flycheck installed here. Building that results in a missing version attribute, presumably from the emacs package that's now the base for doom-emacs.

error: attribute 'version' missing

       at /nix/store/m2vv0bxfchzrjngx8wi0i7dhzb9q2g50-source/pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix:67:39:

           66|             else super.seq;
           67|       project = if lib.versionAtLeast self.emacs.version "28"
             |                                       ^
           68|                 then null
(use '--show-trace' to show detailed location information)

Tracing the custom base package however shows that the version is set to "28.1" - expected, since the base emacsUnstable from emacs-overlay being used is 28.1.

Does emacsPackage require a base non-derived emacs package for doom-emacs to build correctly? Or am I missing a key part of the process to build a custom emacs package?

For reference, I am using the NixOS wiki Emacs article and the source from the home-manager module option here.

I've tested the custom base package in environment.systemPackages and home.packages without issue, so the error is isolated to using it as a base for doom-emacs.

ckiee commented 2 years ago

Try this:

From 99b749e1c5e6d061b376d789c1756ce9b3241ad0 Mon Sep 17 00:00:00 2001
From: ckie <git-525ff67@ckie.dev>
Date: Fri, 10 Jun 2022 17:50:53 +0300
Subject: [PATCH] home/doom-emacs: maybe fix nix-community/nix-doom-emacs#141

---
 home/doom-emacs/default.nix | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/home/doom-emacs/default.nix b/home/doom-emacs/default.nix
index 1ca9ebb..1f46aab 100644
--- a/home/doom-emacs/default.nix
+++ b/home/doom-emacs/default.nix
@@ -10,7 +10,8 @@ lib.mkMerge [
       {
         enable = true;
         doomPrivateDir = ./doom.d;
-        emacsPackage = ((emacsPackagesFor emacsUnstable).emacsWithPackages (epkgs: with epkgs.melpaStablePackages; [ flycheck ]));
+        emacsPackage = emacsPackagesFor emacsUnstable;
+        extraPkgs = epkgs: [ epkgs.melpaStablePackages.flycheck ];
       };
   }
   (lib.mkIf isLinux {
--
2.36.0

If that still doesn't work you might need to overrideAttrs it a bit like some of these.

(naming your repository nixpkgs is incredibly confusing :P)

ratsclub commented 2 years ago

I'm facing the same problem but the solution above did not work for me... @remi-gelinas were you able to fix it?

thiagokokada commented 1 year ago

I was taking a look on our code where we get the Emacs derivation to be used... And well, it is complicated:

This behavior may/may not explains the issue you're seeing, and also explain another issue that I saw when trying vterm module from Emacs. See: https://github.com/thiagokokada/nix-configs/commit/4f845d4766fa5d29b6c178beaf73a3596fe0ca91

I did this emacsPackagesOverlay because Emacs was build with the wrong source code it seems, and know that I took a look at the code this makes sense why it happened.