fix emacs build

Signed-off-by: Xe <me@christine.website>
This commit is contained in:
Cadey Ratio 2023-01-13 16:48:31 -05:00
parent 0cff49b8a4
commit 8e2ef1948a
3 changed files with 167 additions and 2 deletions

View File

@ -107,7 +107,7 @@ in {
counsel = { counsel = {
enable = true; enable = true;
bindStar = { bind = {
"M-x" = "counsel-M-x"; "M-x" = "counsel-M-x";
"C-x C-f" = "counsel-find-file"; "C-x C-f" = "counsel-find-file";
"C-x C-r" = "counsel-recentf"; "C-x C-r" = "counsel-recentf";
@ -308,7 +308,7 @@ in {
swiper = { swiper = {
enable = true; enable = true;
bindStar = { "C-s" = "swiper"; }; bind = { "C-s" = "swiper"; };
general = '' general = ''
(general-nmap (general-nmap

View File

@ -0,0 +1,146 @@
# A collection of "uncontroversial" configurations for selected packages.
{ pkgs, lib, config, ... }:
{
programs.emacs.init.usePackage = {
all-the-icons = { extraPackages = [ pkgs.emacs-all-the-icons-fonts ]; };
cmake-mode.mode = [
''"\\.cmake\\'"'' # \
''"CMakeLists.txt\\'"''
];
csharp-mode.mode = [ ''"\\.cs\\'"'' ];
cue-mode = {
package = epkgs:
epkgs.trivialBuild {
pname = "cue-mode.el";
src = pkgs.fetchurl {
url =
"https://raw.githubusercontent.com/russell/cue-mode/9c803ee8fa4a6e99c7dc9ae373c6178569583b7a/cue-mode.el";
sha256 = "0swhpknkg1vwbchblzrwynixf5grg95jy1bkc8w92yfpb1jch7m7";
};
preferLocalBuild = true;
allowSubstitutes = true;
};
command = [ "cue-mode" ];
mode = [ ''"\\.cue\\'"'' ];
hook = [ "(cue-mode . subword-mode)" ];
};
dap-lldb = {
config = ''
(setq dap-lldb-debug-program "${pkgs.lldb}/bin/lldb-vscode")
'';
};
deadgrep = {
config = ''
(setq deadgrep-executable "${pkgs.ripgrep}/bin/rg")
'';
};
dhall-mode.mode = [ ''"\\.dhall\\'"'' ];
dockerfile-mode.mode = [ ''"Dockerfile\\'"'' ];
elm-mode.mode = [ ''"\\.elm\\'"'' ];
emacsql-sqlite3 = {
enable =
lib.mkDefault config.programs.emacs.init.usePackage.org-roam.enable;
defer = lib.mkDefault true;
config = ''
(setq emacsql-sqlite3-executable "${pkgs.sqlite}/bin/sqlite3")
'';
};
ggtags = {
config = ''
(setq ggtags-executable-directory "${pkgs.global}/bin")
'';
};
idris-mode = {
mode = [ ''"\\.idr\\'"'' ];
config = ''
(setq idris-interpreter-path "${pkgs.idris}/bin/idris")
'';
};
kotlin-mode = {
mode = [ ''"\\.kts?\\'"'' ];
hook = [ "(kotlin-mode . subword-mode)" ];
};
latex.mode = [ ''("\\.tex\\'" . latex-mode)'' ];
lsp-eslint = {
config = ''
(setq lsp-eslint-server-command '("node" "${pkgs.vscode-extensions.dbaeumer.vscode-eslint}/share/vscode/extensions/dbaeumer.vscode-eslint/server/out/eslintServer.js" "--stdio"))
'';
};
markdown-mode = {
mode = [ ''"\\.mdwn\\'"'' ''"\\.markdown\\'"'' ''"\\.md\\'"'' ];
};
nix-mode.mode = [ ''"\\.nix\\'"'' ];
notmuch = {
package = epkgs: lib.getOutput "emacs" pkgs.notmuch;
config = ''
(setq notmuch-command "${pkgs.notmuch}/bin/notmuch")
'';
};
octave.mode = [ ''("\\.m\\'" . octave-mode)'' ];
ob-plantuml = {
config = ''
(setq org-plantuml-jar-path "${pkgs.plantuml}/lib/plantuml.jar")
'';
};
org-roam = {
defines = [ "org-roam-graph-executable" ];
config = ''
(setq org-roam-graph-executable "${pkgs.graphviz}/bin/dot")
'';
};
pandoc-mode = {
config = ''
(setq pandoc-binary "${pkgs.pandoc}/bin/pandoc")
'';
};
php-mode.mode = [ ''"\\.php\\'"'' ];
plantuml-mode = {
mode = [ ''"\\.puml\\'"'' ];
config = ''
(setq plantuml-default-exec-mode 'executable
plantuml-executable-path "${pkgs.plantuml}/bin/plantuml")
'';
};
protobuf-mode.mode = [ ''"\\.proto\\'"'' ];
purescript-mode.mode = [ ''"\\.purs\\'"'' ];
ripgrep = {
config = ''
(setq ripgrep-executable "${pkgs.ripgrep}/bin/rg")
'';
};
rust-mode.mode = [ ''"\\.rs\\'"'' ];
terraform-mode.mode = [ ''"\\.tf\\'"'' ];
yaml-mode.mode = [ ''"\\.\\(e?ya?\\|ra\\)ml\\'"'' ];
};
}

View File

@ -152,6 +152,14 @@ let
''; '';
}; };
general = mkOption {
type = types.lines;
default = "";
description = ''
Code to place in the <option>:general</option> section.
'';
};
hook = mkOption { hook = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ ];
@ -214,6 +222,7 @@ let
let mkMap = n: v: mkBindHelper "bind" ":map ${n}" v; let mkMap = n: v: mkBindHelper "bind" ":map ${n}" v;
in flatten (mapAttrsToList mkMap bs); in flatten (mapAttrsToList mkMap bs);
mkBindKeyMap = mkBindHelper "bind-keymap" ""; mkBindKeyMap = mkBindHelper "bind-keymap" "";
extraAfter = optional (config.general != "") "general";
mkChords = mkBindHelper "chords" ""; mkChords = mkBindHelper "chords" "";
mkHook = map (v: ":hook ${v}"); mkHook = map (v: ":hook ${v}");
mkDefer = v: mkDefer = v:
@ -232,6 +241,7 @@ let
++ mkMode config.mode ++ mkMode config.mode
++ optionals (config.init != "") [ ":init" config.init ] ++ optionals (config.init != "") [ ":init" config.init ]
++ optionals (config.config != "") [ ":config" config.config ] ++ optionals (config.config != "") [ ":config" config.config ]
++ optionals (config.general != "") [ ":general" config.general ]
++ optional (config.extraConfig != "") config.extraConfig) + ")"; ++ optional (config.extraConfig != "") config.extraConfig) + ")";
}; };
}); });
@ -299,6 +309,9 @@ let
# Whether the configuration makes use of `:chords`. # Whether the configuration makes use of `:chords`.
hasChords = any (p: p.chords != { }) (attrValues cfg.usePackage); hasChords = any (p: p.chords != { }) (attrValues cfg.usePackage);
# Whether the configuration makes use of `:general`.
hasGeneral = any (p: p.general != "") (attrValues cfg.usePackage);
usePackageSetup = '' usePackageSetup = ''
(eval-when-compile (eval-when-compile
(require 'use-package) (require 'use-package)
@ -320,6 +333,11 @@ let
;; For :chords in (use-package). ;; For :chords in (use-package).
(use-package use-package-chords (use-package use-package-chords
:config (key-chord-mode 1)) :config (key-chord-mode 1))
'' + optionalString hasGeneral ''
;; For :general in (use-package).
(use-package general
:config
(general-evil-setup))
''; '';
earlyInitFile = '' earlyInitFile = ''
@ -495,6 +513,7 @@ in {
src = pkgs.writeText "hm-init.el" initFile; src = pkgs.writeText "hm-init.el" initFile;
packageRequires = [ epkgs.use-package ] ++ packages packageRequires = [ epkgs.use-package ] ++ packages
++ optional hasBind epkgs.bind-key ++ optional hasBind epkgs.bind-key
++ optional hasGeneral epkgs.general
++ optional hasDiminish epkgs.diminish ++ optional hasDiminish epkgs.diminish
++ optional hasChords epkgs.use-package-chords; ++ optional hasChords epkgs.use-package-chords;
preferLocalBuild = true; preferLocalBuild = true;