emacs: add extraConfig option
This commit is contained in:
parent
29ea37374d
commit
b0d769691c
5 changed files with 59 additions and 3 deletions
|
|
@ -13,6 +13,12 @@ let
|
|||
|
||||
emacsWithPackages = emacsPackages.emacsWithPackages;
|
||||
|
||||
createConfPackage = epkgs:
|
||||
epkgs.trivialBuild {
|
||||
pname = "default";
|
||||
src = pkgs.writeText "default.el" cfg.extraConfig;
|
||||
};
|
||||
|
||||
in {
|
||||
meta.maintainers = [ maintainers.rycee ];
|
||||
|
||||
|
|
@ -28,6 +34,23 @@ in {
|
|||
description = "The Emacs package to use.";
|
||||
};
|
||||
|
||||
# NOTE: The config is placed in default.el instead of ~/.emacs.d so that
|
||||
# it won't conflict with Emacs configuration frameworks. Users of these
|
||||
# frameworks would still benefit from this option as it would easily allow
|
||||
# them to have Nix-computed paths in their configuration.
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
example = ''
|
||||
(setq standard-indent 2)
|
||||
'';
|
||||
description = ''
|
||||
Configuration to include in the Emacs default init file. See
|
||||
<link xlink:href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Init-File.html"/>
|
||||
for more.
|
||||
'';
|
||||
};
|
||||
|
||||
extraPackages = mkOption {
|
||||
default = self: [ ];
|
||||
type = hm.types.selectorFunction;
|
||||
|
|
@ -68,6 +91,10 @@ in {
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.finalPackage ];
|
||||
programs.emacs.finalPackage = emacsWithPackages cfg.extraPackages;
|
||||
programs.emacs = {
|
||||
finalPackage = emacsWithPackages cfg.extraPackages;
|
||||
extraPackages = epkgs:
|
||||
optional (cfg.extraConfig != "") (createConfPackage epkgs);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue