1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-26 11:49:47 +01:00
home-manager/modules/programs/emacs.nix

106 lines
3.1 KiB
Nix
Raw Normal View History

2017-01-07 19:16:26 +01: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-25 00:45:51 +02:00
in epkgs.overrideScope' cfg.overrides;
2017-09-19 23:32:01 +02:00
2020-05-25 00:45:51 +02:00
emacsWithPackages = emacsPackages.emacsWithPackages;
2017-01-07 19:16:26 +01:00
extraPackages = epkgs:
let
packages = cfg.extraPackages epkgs;
userConfig = epkgs.trivialBuild {
pname = "default";
src = pkgs.writeText "default.el" cfg.extraConfig;
version = "0.1.0";
packageRequires = packages;
};
in packages ++ optional (cfg.extraConfig != "") userConfig;
2021-01-29 17:43:49 +01:00
2020-05-25 00:45:51 +02:00
in {
meta.maintainers = [ maintainers.rycee ];
2017-01-07 19:16:26 +01:00
options = {
programs.emacs = {
enable = mkEnableOption "Emacs";
2017-01-07 19:16:26 +01:00
2017-09-19 23:32:01 +02:00
package = mkOption {
type = types.package;
default = pkgs.emacs;
defaultText = literalExpression "pkgs.emacs";
example = literalExpression "pkgs.emacs25-nox";
description = "The Emacs package to use.";
2017-09-19 23:32:01 +02:00
};
2021-01-29 17:43:49 +01:00
# 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 = ''
2021-01-29 17:43:49 +01:00
Configuration to include in the Emacs default init file. See
<https://www.gnu.org/software/emacs/manual/html_node/elisp/Init-File.html>
2021-01-29 17:43:49 +01:00
for more.
Note, the `inhibit-startup-message` Emacs option
cannot be set here since Emacs disallows setting it from the default
initialization file.
2021-01-29 17:43:49 +01:00
'';
};
2017-01-07 19:16:26 +01:00
extraPackages = mkOption {
2020-05-25 00:45:51 +02:00
default = self: [ ];
type = hm.types.selectorFunction;
defaultText = "epkgs: []";
example = literalExpression "epkgs: [ epkgs.emms epkgs.magit ]";
description = ''
Extra packages available to Emacs. To get a list of
available packages run:
{command}`nix-env -f '<nixpkgs>' -qaP -A emacsPackages`.
'';
2017-01-07 19:16:26 +01:00
};
overrides = mkOption {
2020-05-25 00:45:51 +02:00
default = self: super: { };
type = hm.types.overlayFunction;
defaultText = "self: super: {}";
example = literalExpression ''
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 19:16:26 +01:00
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.finalPackage ];
programs.emacs.finalPackage = emacsWithPackages extraPackages;
2017-01-07 19:16:26 +01:00
};
}