home-manager/modules/programs/emacs.nix

74 lines
1.9 KiB
Nix
Raw Normal View History

2017-01-07 18:16:26 +00:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.emacs;
# Copied from all-packages.nix, with modifications to support
# overrides.
emacsPackages = let epkgs = pkgs.emacsPackagesFor cfg.package;
2020-05-24 22:45:51 +00:00
in epkgs.overrideScope' cfg.overrides;
2017-09-19 21:32:01 +00:00
2020-05-24 22:45:51 +00:00
emacsWithPackages = emacsPackages.emacsWithPackages;
2017-01-07 18:16:26 +00:00
2020-05-24 22:45:51 +00:00
in {
meta.maintainers = [ maintainers.rycee ];
2017-01-07 18:16:26 +00:00
options = {
programs.emacs = {
enable = mkEnableOption "Emacs";
2017-09-19 21:32:01 +00:00
package = mkOption {
type = types.package;
default = pkgs.emacs;
defaultText = literalExample "pkgs.emacs";
2017-09-19 21:32:01 +00:00
example = literalExample "pkgs.emacs25-nox";
description = "The Emacs package to use.";
};
2017-01-07 18:16:26 +00:00
extraPackages = mkOption {
2020-05-24 22:45:51 +00:00
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>.
'';
2017-01-07 18:16:26 +00:00
};
overrides = mkOption {
2020-05-24 22:45:51 +00:00
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.
'';
};
2017-01-07 18:16:26 +00:00
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.finalPackage ];
programs.emacs.finalPackage = emacsWithPackages cfg.extraPackages;
2017-01-07 18:16:26 +00:00
};
}