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