emacs: allow extraConfig to reference extraPackages
This fixes the issue described in https://github.com/nix-community/home-manager/pull/1758#issuecomment-1113706592
This commit is contained in:
parent
51ea4217f7
commit
64831f938b
|
@ -13,11 +13,15 @@ let
|
||||||
|
|
||||||
emacsWithPackages = emacsPackages.emacsWithPackages;
|
emacsWithPackages = emacsPackages.emacsWithPackages;
|
||||||
|
|
||||||
createConfPackage = epkgs:
|
extraPackages = epkgs:
|
||||||
epkgs.trivialBuild {
|
let
|
||||||
pname = "default";
|
packages = cfg.extraPackages epkgs;
|
||||||
src = pkgs.writeText "default.el" cfg.extraConfig;
|
userConfig = epkgs.trivialBuild {
|
||||||
};
|
pname = "default";
|
||||||
|
src = pkgs.writeText "default.el" cfg.extraConfig;
|
||||||
|
packageRequires = packages;
|
||||||
|
};
|
||||||
|
in packages ++ optional (cfg.extraConfig != "") userConfig;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ maintainers.rycee ];
|
meta.maintainers = [ maintainers.rycee ];
|
||||||
|
@ -91,10 +95,6 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [ cfg.finalPackage ];
|
home.packages = [ cfg.finalPackage ];
|
||||||
programs.emacs = {
|
programs.emacs.finalPackage = emacsWithPackages extraPackages;
|
||||||
finalPackage = emacsWithPackages cfg.extraPackages;
|
|
||||||
extraPackages = epkgs:
|
|
||||||
optional (cfg.extraConfig != "") (createConfPackage epkgs);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,32 @@ let
|
||||||
testScript = pkgs.writeText "test.el" ''
|
testScript = pkgs.writeText "test.el" ''
|
||||||
;; Emacs won't automatically load default.el when --script is specified
|
;; Emacs won't automatically load default.el when --script is specified
|
||||||
(load "default")
|
(load "default")
|
||||||
(kill-emacs (if (eq hm 'home-manager) 0 1))
|
(let* ((test-load-config (eq hm 'home-manager))
|
||||||
|
(test-load-package (eq (hm-test-fn) 'success))
|
||||||
|
(is-ok (and test-load-config test-load-package)))
|
||||||
|
(kill-emacs (if is-ok 0 1)))
|
||||||
'';
|
'';
|
||||||
|
|
||||||
emacsBin = "${config.programs.emacs.finalPackage}/bin/emacs";
|
emacsBin = "${config.programs.emacs.finalPackage}/bin/emacs";
|
||||||
|
|
||||||
|
mkTestPackage = epkgs:
|
||||||
|
epkgs.trivialBuild {
|
||||||
|
pname = "hm-test";
|
||||||
|
src = pkgs.writeText "hm-test.el" ''
|
||||||
|
(defun hm-test-fn () 'success)
|
||||||
|
(provide 'hm-test)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
in lib.mkIf config.test.enableBig {
|
in lib.mkIf config.test.enableBig {
|
||||||
programs.emacs = {
|
programs.emacs = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.emacs-nox;
|
package = pkgs.emacs-nox;
|
||||||
extraConfig = "(setq hm 'home-manager)";
|
extraConfig = ''
|
||||||
|
(require 'hm-test)
|
||||||
|
(setq hm 'home-manager)
|
||||||
|
'';
|
||||||
|
extraPackages = epkgs: [ (mkTestPackage epkgs) ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# running emacs with --script would enable headless mode
|
# running emacs with --script would enable headless mode
|
||||||
|
|
Loading…
Reference in a new issue