Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation request: Emacs packages installed via emacsWithPackagesFromUsePackage but configured via default.el or emacs.el using use-package #268

Open
573 opened this issue Dec 1, 2022 · 0 comments

Comments

@573
Copy link

573 commented Dec 1, 2022

{...}:{
overlays = [
 (final: prev: {
  somemore = prev.lib.composeManyExtensions [ inputs.emacs-overlay.overlays.default ] final prev;
  my-emacs = final.somemore.emacsWithPackagesFromUsePackage {
   config = "${rootPath}/home/misc/emacs.el";
   alwaysEnsure = true;
   defaultInitFile = final.substituteAll {
     name = "default.el";
     src = "${final.runCommand "emacs-config" {
      inherit rootPath;
      input = builtins.readFile "${rootPath}/home/misc/emacs.el";
     } ''
       mkdir -p "$out/"
       printf '%s\n' "
        ;; use-package.outPath is not writable
        (defun my-bytecomp-dest-file (source)
        (expand-file-name (file-name-nondirectory source) \"~/.cache/\"))
        (setq byte-compile-dest-file-function 'my-bytecomp-dest-file)
        (access-file \"${final.somemore.emacsUnstable-nox.pkgs.melpaPackages.use-package.outPath}\" \"use-package path not readable\")
        (add-to-list 'load-path \"~/.cache/\")
        (add-to-list 'load-path \"${final.somemore.emacsUnstable-nox.pkgs.melpaPackages.use-package.outPath}\")
        (eval-when-compile
         (package-initialize)
         (require 'use-package))" > $out/emacs.el
       printf '%s\n' "$input" >> $out/emacs.el
     ''}/emacs.el";
    };
   extraEmacsPackages = epkgs: (with epkgs.melpaPackages; [
      use-package
      company-emoji
   ]);
  };
 })
];
}
;; file $rootpath/home/misc/emacs.el
(use-package company-emoji
  :config (add-to-list 'company-backends 'company-emoji))

EDIT: I have use-package as well in the set and added a byte-compile helper to my elisp to circumvent nix trying to write *.elc files to the store path.
Building my flake with these edits now says default.el:18:12: Error: Cannot open load file: No such file or directory, use-package:

nix-repl> :u nixosConfigurations.DANIELKNB1.pkgs.my-emacs
warning: error: plugin-files set after plugins were loaded, you may need to move the flag before the subcommand
these 5 derivations will be built:
/nix/store/144vkiwdpr20v819m14gnsfwsjma9v63-emacs-config.drv
/nix/store/8ynkd1ny34df2gzbn12h1ynjz3y6ynas-default.el.drv
/nix/store/j3a9byj0ig8inrv8akhhgcjf8z82f31f-emacs-default-init-file.drv
/nix/store/i9nysbxpcis792vrwsmalkzsznhq7jl5-emacs-packages-deps.drv
/nix/store/09j84gimq61q57n3zbkp6maq3cyl3sss-emacs-unstable-with-packages-28.2-nox.drv
building '/nix/store/144vkiwdpr20v819m14gnsfwsjma9v63-emacs-config.drv'...
building '/nix/store/8ynkd1ny34df2gzbn12h1ynjz3y6ynas-default.el.drv'...
building '/nix/store/j3a9byj0ig8inrv8akhhgcjf8z82f31f-emacs-default-init-file.drv'...
unpacking sources
unpacking source archive /nix/store/rs4dfkvdcw1v8c94ys544mcf21pmwvdm-default.el
source root is .
patching sources
configuring
no configure script, doing nothing
building

In toplevel form:
default.el:18:12: Error: Cannot open load file: No such file or directory, use-package
error: builder for '/nix/store/j3a9byj0ig8inrv8akhhgcjf8z82f31f-emacs-default-init-file.drv' failed with exit code 1;
last 10 log lines:
> unpacking sources
> unpacking source archive /nix/store/rs4dfkvdcw1v8c94ys544mcf21pmwvdm-default.el
> source root is .
> patching sources
> configuring
> no configure script, doing nothing
> building
>
> In toplevel form:
> default.el:18:12: Error: Cannot open load file: No such file or directory, use-package
For full logs, run 'nix log /nix/store/j3a9byj0ig8inrv8akhhgcjf8z82f31f-emacs-default-init-file.drv'.
error: 1 dependencies of derivation '/nix/store/09j84gimq61q57n3zbkp6maq3cyl3sss-emacs-unstable-with-packages-28.2-nox.drv' failed to build
error: program 'nix-shell' failed with exit code 1

Also when starting built emacs it says:

>Warning (initialization): An error occurred while loading ‘/.emacs’:~
>
>Symbol's value as variable is void: company-emoji
>
>To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace. Disable showing Disable logging

I thought setting alwaysEnsure true (#43) would take care of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant