2024-04-29 14:58:41 +10:00
|
|
|
# Copyright 2024 Google LLC
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
2024-05-11 20:35:42 +10:00
|
|
|
{ doomFromPackages }:
|
2024-04-29 14:58:41 +10:00
|
|
|
{ config, options, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
cfg = config.programs.doom-emacs;
|
2024-06-02 00:34:36 +02:00
|
|
|
inherit (lib) literalExpression mkEnableOption mkIf mkMerge mkOption types hm;
|
2024-04-29 14:58:41 +10:00
|
|
|
in {
|
|
|
|
|
options = {
|
|
|
|
|
programs.doom-emacs = {
|
|
|
|
|
enable = mkEnableOption "Doom Emacs";
|
|
|
|
|
|
|
|
|
|
emacs = mkOption {
|
|
|
|
|
type = types.package;
|
|
|
|
|
default = pkgs.emacs;
|
|
|
|
|
defaultText = literalExpression "pkgs.emacs";
|
|
|
|
|
example = literalExpression "pkgs.emacs29-pgtk";
|
|
|
|
|
description = "The Emacs package to wrap.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
doomDir = mkOption {
|
|
|
|
|
type = types.path;
|
|
|
|
|
example = literalExpression "./doom";
|
|
|
|
|
description = "The DOOMDIR to build from and bundle.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
doomLocalDir = mkOption {
|
|
|
|
|
type = types.path;
|
|
|
|
|
default = "${config.xdg.dataHome}/nix-doom";
|
|
|
|
|
defaultText = literalExpression ''"''${config.xdg.dataHome}/nix-doom"'';
|
|
|
|
|
example = literalExpression "~/.local/state/doom";
|
|
|
|
|
description = ''
|
|
|
|
|
DOOMLOCALDIR.
|
|
|
|
|
|
|
|
|
|
`~` is expanded, but shell variables are not! Use `config.xdg.*`, not
|
|
|
|
|
`XDG_DATA_*`.'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
profileName = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "nix";
|
|
|
|
|
example = literalExpression "";
|
|
|
|
|
description = "Doom profile. Set to the empty string to disable.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
noProfileHack = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
example = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Use a hack to make Doom use normal paths (relative to DOOMLOCALDIR).
|
|
|
|
|
|
|
|
|
|
Has no effect if doomProfile is unset (set to the empty string).
|
|
|
|
|
|
|
|
|
|
Currently not recommended: unset doomProfile instead;
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
provideEmacs = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
|
|
|
|
description = ''
|
|
|
|
|
If enabled (the default), provide "emacs" (and "emacsclient", etc).
|
|
|
|
|
If disabled, provide a "doom-emacs" binary.
|
|
|
|
|
|
|
|
|
|
Disable this to install doom-emacs in parallel with vanilla Emacs.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-01 23:14:08 +10:00
|
|
|
experimentalFetchTree = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
example = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Fetch packages using fetchTree instead of fetchGit.
|
|
|
|
|
|
|
|
|
|
This makes use of Nix's "github" fetcher, which is more efficient:
|
|
|
|
|
it fetches tarballs generated by GitHub instead of using git.
|
|
|
|
|
|
|
|
|
|
It is not enabled by default because that fetcher is still "subject
|
|
|
|
|
to change" according to Nix's documentation.
|
|
|
|
|
|
|
|
|
|
This should be safe to enable, as long as you remember to disable it
|
|
|
|
|
if you encounter fetch issues, especially if they start after an
|
|
|
|
|
upgrade of Nix.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2024-04-29 14:58:41 +10:00
|
|
|
finalEmacsPackage = mkOption {
|
|
|
|
|
type = types.package;
|
|
|
|
|
visible = false;
|
|
|
|
|
readOnly = true;
|
|
|
|
|
description = "The final Emacs-compatible package";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
finalDoomPackage = mkOption {
|
|
|
|
|
type = types.package;
|
|
|
|
|
visible = false;
|
|
|
|
|
readOnly = true;
|
|
|
|
|
description = "The final doom-emacs package";
|
|
|
|
|
};
|
2024-06-02 00:34:36 +02:00
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
|
|
|
|
default = self: [ ];
|
|
|
|
|
type = hm.types.selectorFunction;
|
|
|
|
|
defaultText = "epkgs: [ ]";
|
|
|
|
|
example = literalExpression
|
2024-06-03 00:19:46 +02:00
|
|
|
"epkgs: [ epkgs.treesit-grammars.with-all-grammars ]";
|
2024-06-02 00:34:36 +02:00
|
|
|
description = ''
|
2024-06-03 00:19:46 +02:00
|
|
|
Extra Emacs packages from nixpkgs available to Doom Emacs,
|
|
|
|
|
unless that packages is handled by Doom Emacs.
|
|
|
|
|
|
|
|
|
|
If Doom Emacs specifies a package,
|
|
|
|
|
then that specific package and version will be exactly as Doom specifies even if it's
|
|
|
|
|
included in 'extraPackages'.
|
|
|
|
|
|
|
|
|
|
To use 'extraPackages' to override a specific package otherwise specified by Doom Emacs,
|
|
|
|
|
it is required that the Doom Emacs config use the following arguments for the package:
|
|
|
|
|
'(package! ... :built-in t)'
|
|
|
|
|
This allows nix to be used to apply patches to an Emacs package.
|
|
|
|
|
|
|
|
|
|
Some Emacs packages from nixpkgs have additional side-effects specific to nix,
|
|
|
|
|
consider the Emacs Package 'treesit-grammars.with-all-grammars'.
|
|
|
|
|
It downloads all treesitter grammars defined in nixpkgs at build time and makes them
|
|
|
|
|
available on path for Emacs at runtime.
|
|
|
|
|
Doom cannot specify that package using the '(package! ...)' syntax.
|
2024-06-02 00:34:36 +02:00
|
|
|
'';
|
|
|
|
|
};
|
2024-06-16 22:41:03 +10:00
|
|
|
extraBinPackages = mkOption {
|
|
|
|
|
default = [
|
|
|
|
|
config.programs.ripgrep.package
|
|
|
|
|
config.programs.git.package
|
|
|
|
|
config.programs.fd.package
|
|
|
|
|
];
|
|
|
|
|
type = types.listOf types.package;
|
|
|
|
|
defaultText = literalExpression
|
|
|
|
|
"[ programs.ripgrep.package programs.git.package programs.fd.package ]";
|
|
|
|
|
description = "Extra packages to add to Doom's $PATH.";
|
|
|
|
|
};
|
2024-04-29 14:58:41 +10:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
|
(let
|
2024-05-11 20:35:42 +10:00
|
|
|
doomPackages = doomFromPackages pkgs {
|
2024-07-01 23:14:08 +10:00
|
|
|
inherit (cfg) emacs doomDir doomLocalDir profileName noProfileHack extraPackages
|
|
|
|
|
experimentalFetchTree;
|
2024-04-29 14:58:41 +10:00
|
|
|
};
|
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
programs.doom-emacs.finalDoomPackage = doomPackages.doomEmacs;
|
|
|
|
|
programs.doom-emacs.finalEmacsPackage = doomPackages.emacsWithDoom;
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
home.packages = [(
|
|
|
|
|
if cfg.provideEmacs then cfg.finalEmacsPackage else cfg.finalDoomPackage
|
|
|
|
|
)];
|
|
|
|
|
}
|
|
|
|
|
(mkIf (options.services ? emacs && cfg.provideEmacs) {
|
|
|
|
|
services.emacs.package = cfg.finalEmacsPackage;
|
|
|
|
|
})
|
|
|
|
|
]);
|
|
|
|
|
}
|