2017-01-07 19:16:26 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.emacs;
|
|
|
|
|
2018-12-17 23:01:43 +01:00
|
|
|
# Copied from all-packages.nix, with modifications to support
|
|
|
|
# overrides.
|
2020-06-06 14:12:45 +02:00
|
|
|
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
|
|
|
|
2022-04-30 11:04:08 +02:00
|
|
|
extraPackages = epkgs:
|
|
|
|
let
|
|
|
|
packages = cfg.extraPackages epkgs;
|
|
|
|
userConfig = epkgs.trivialBuild {
|
|
|
|
pname = "default";
|
|
|
|
src = pkgs.writeText "default.el" cfg.extraConfig;
|
|
|
|
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 {
|
2017-09-26 23:40:31 +02:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2017-01-07 19:16:26 +01:00
|
|
|
options = {
|
|
|
|
programs.emacs = {
|
2023-07-01 01:30:13 +02:00
|
|
|
enable = mkEnableOption (lib.mdDoc "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;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.emacs";
|
|
|
|
example = literalExpression "pkgs.emacs25-nox";
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc "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)
|
|
|
|
'';
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2021-01-29 17:43:49 +01:00
|
|
|
Configuration to include in the Emacs default init file. See
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://www.gnu.org/software/emacs/manual/html_node/elisp/Init-File.html>
|
2021-01-29 17:43:49 +01:00
|
|
|
for more.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
|
|
|
Note, the `inhibit-startup-message` Emacs option
|
2022-12-05 11:16:34 +01:00
|
|
|
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: [ ];
|
2020-01-26 11:26:33 +01:00
|
|
|
type = hm.types.selectorFunction;
|
2017-11-13 00:03:49 +01:00
|
|
|
defaultText = "epkgs: []";
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression "epkgs: [ epkgs.emms epkgs.magit ]";
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2019-08-18 13:33:34 +02:00
|
|
|
Extra packages available to Emacs. To get a list of
|
|
|
|
available packages run:
|
2023-07-01 01:30:13 +02:00
|
|
|
{command}`nix-env -f '<nixpkgs>' -qaP -A emacsPackages`.
|
2019-08-18 13:33:34 +02:00
|
|
|
'';
|
2017-01-07 19:16:26 +01:00
|
|
|
};
|
2018-09-11 21:23:11 +02:00
|
|
|
|
2018-12-17 23:01:43 +01:00
|
|
|
overrides = mkOption {
|
2020-05-25 00:45:51 +02:00
|
|
|
default = self: super: { };
|
2020-01-26 11:26:33 +01:00
|
|
|
type = hm.types.overlayFunction;
|
2018-12-17 23:01:43 +01:00
|
|
|
defaultText = "self: super: {}";
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2018-12-17 23:01:43 +01:00
|
|
|
self: super: rec {
|
|
|
|
haskell-mode = self.melpaPackages.haskell-mode;
|
|
|
|
# ...
|
|
|
|
};
|
|
|
|
'';
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2018-12-17 23:01:43 +01:00
|
|
|
Allows overriding packages within the Emacs package set.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-09-11 21:23:11 +02:00
|
|
|
finalPackage = mkOption {
|
|
|
|
type = types.package;
|
2019-01-03 02:15:17 +01:00
|
|
|
visible = false;
|
2018-09-11 21:23:11 +02:00
|
|
|
readOnly = true;
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2019-01-03 02:15:17 +01:00
|
|
|
The Emacs package including any overrides and extra packages.
|
|
|
|
'';
|
2018-09-11 21:23:11 +02:00
|
|
|
};
|
2017-01-07 19:16:26 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2018-09-11 21:23:11 +02:00
|
|
|
home.packages = [ cfg.finalPackage ];
|
2022-04-30 11:04:08 +02:00
|
|
|
programs.emacs.finalPackage = emacsWithPackages extraPackages;
|
2017-01-07 19:16:26 +01:00
|
|
|
};
|
|
|
|
}
|