1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-01 04:23:34 +02:00
home-manager/modules/programs/emacs.nix
Robert Helgesson 677f1f05df
emacs: remove custom emacsPackages
We can now directly use the existing package set since it supports
overrides.
2021-10-01 01:25:05 +02:00

97 lines
2.7 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.emacs;
emacsPackages = cfg.package.pkgs.overrideScope' cfg.overrides;
emacsWithPackages = emacsPackages.emacsWithPackages;
createConfPackage = epkgs:
epkgs.trivialBuild {
pname = "default";
src = pkgs.writeText "default.el" cfg.extraConfig;
};
in {
meta.maintainers = [ maintainers.rycee ];
options = {
programs.emacs = {
enable = mkEnableOption "Emacs";
package = mkOption {
type = types.package;
default = pkgs.emacs;
defaultText = literalExample "pkgs.emacs";
example = literalExample "pkgs.emacs25-nox";
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;
defaultText = "epkgs: []";
example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]";
description = ''
Extra packages available to Emacs. To get a list of
available packages run:
<command>nix-env -f '&lt;nixpkgs&gt;' -qaP -A emacsPackages</command>.
'';
};
overrides = mkOption {
default = self: super: { };
type = hm.types.overlayFunction;
defaultText = "self: super: {}";
example = literalExample ''
self: super: rec {
haskell-mode = self.melpaPackages.haskell-mode;
# ...
};
'';
description = ''
Allows overriding packages within the Emacs package set.
'';
};
finalPackage = mkOption {
type = types.package;
visible = false;
readOnly = true;
description = ''
The Emacs package including any overrides and extra packages.
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.finalPackage ];
programs.emacs = {
finalPackage = emacsWithPackages cfg.extraPackages;
extraPackages = epkgs:
optional (cfg.extraConfig != "") (createConfPackage epkgs);
};
};
}