nix-doom-emacs icon indicating copy to clipboard operation
nix-doom-emacs copied to clipboard

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

Open remi-gelinas opened this issue 3 years ago • 3 comments

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.

remi-gelinas avatar May 13 '22 21:05 remi-gelinas

Try this:

From 99b749e1c5e6d061b376d789c1756ce9b3241ad0 Mon Sep 17 00:00:00 2001
From: ckie <[email protected]>
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)

ckiee avatar Jun 10 '22 14:06 ckiee

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

ratsclub avatar Jun 28 '22 17:06 ratsclub

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

  • https://github.com/nix-community/nix-doom-emacs/blob/master/default.nix#L110-L118: here we get an Emacs for building doom-emacs packages
  • https://github.com/nix-community/nix-doom-emacs/blob/master/default.nix#L209-L220: here we get another Emacs for building the final derivation

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.

thiagokokada avatar Sep 13 '22 21:09 thiagokokada