danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
1.22k stars 159 forks source link

emacs, home-manager: theme is unable to be set when using package made with `emacsWithPackagesFromUsePackage` #453

Open amadalusia opened 4 months ago

amadalusia commented 4 months ago

Issue?

The module provided by Stylix for Emacs is trying to override the extraConfig provided by my custom Emacs package. This however fails as the latter takes precedence over Stylix, resulting in an unthemed Emacs.

Is this fixable?

I am guessing you can try an override, however an override will probably not work out because it overrides that part of the package, instead of [app/prep]ending to it. Maybe adding prev will fix this?

Example?

This is what is happening to me right now, however it could happen to more people.

trueNAHO commented 4 months ago

The module provided by Stylix for Emacs is trying to override the extraConfig provided by my custom Emacs package.

This however fails as the latter takes precedence over Stylix, resulting in an unthemed Emacs.

This is a somewhat already acknowledged problem:

the use of extraConfig might cause other potentially related issues. As discussed in #159 (comment), it makes it harder to override options, and as discussed in #388 (comment), it makes it easier to accidentally override Stylix options.

-- https://github.com/danth/stylix/issues/395

gusgibbon commented 4 months ago

+1

gusgibbon commented 4 months ago

Workaround for now:

programs.emacs = {
      enable = true;
      package = pkgs.emacsWithPackagesFromUsePackage {
        config = pkgs.writeTextFile {
          text = ''
            ${builtins.readFile <config file>}
            #+begin_src emacs-lisp
            ${config.home-manager.users.<username>.programs.emacs.extraConfig}
            #+end_src'';
          name = "config.org";
        };
        alwaysTangle = true;
        defaultInitFile = true;
        package = pkgs.emacs-pgtk;
        extraEmacsPackages = config.home-manager.users."<config file>".programs.emacs.extraPackages;
      };
};
amadalusia commented 4 months ago

Is there any alternative if pkgs.callPackage was called?