-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
default.nix
131 lines (120 loc) · 4.32 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# ==============================================
# Based on doomemacs's author's config:
# https://github.com/hlissner/dotfiles/blob/master/modules/editors/emacs.nix
#
# Emacs Tutorials:
# 1. Official: <https://www.gnu.org/software/emacs/tour/index.html>
# 2. Doom Emacs: <https://github.com/doomemacs/doomemacs/blob/master/docs/index.org>
#
{
config,
lib,
pkgs,
doomemacs,
...
}:
with lib; let
cfg = config.modules.editors.emacs;
envExtra = lib.mkAfter ''
export PATH="${config.xdg.configHome}/emacs/bin:$PATH"
'';
shellAliases = {
e = "emacsclient --create-frame"; # gui
et = "emacsclient --create-frame --tty"; # terminal
};
librime-dir = "${config.xdg.dataHome}/emacs/librime";
parinfer-rust-lib-dir = "${config.xdg.dataHome}/emacs/parinfer-rust";
myEmacsPackagesFor = emacs: ((pkgs.emacsPackagesFor emacs).emacsWithPackages (epkgs: [
epkgs.vterm
]));
# to make this symlink work, we need to git clone this repo to your home directory.
configPath = "${config.home.homeDirectory}/nix-config/home/base/tui/editors/emacs/doom";
in {
options.modules.editors.emacs = {
enable = mkEnableOption "Emacs Editor";
};
config = mkIf cfg.enable (mkMerge [
{
home.packages = with pkgs; [
## Doom dependencies
git
(ripgrep.override {withPCRE2 = true;})
gnutls # for TLS connectivity
## Optional dependencies
fd # faster projectile indexing
imagemagick # for image-dired
fd # faster projectile indexing
zstd # for undo-fu-session/undo-tree compression
# go-mode
# gocode # project archived, use gopls instead
## Module dependencies
# :checkers spell
# (aspellWithDicts (ds: with ds; [en en-computers en-science]))
# :tools editorconfig
editorconfig-core-c # per-project style config
# :tools lookup & :lang org +roam
sqlite
# :lang latex & :lang org (latex previews)
# texlive.combined.scheme-medium
];
programs.bash.bashrcExtra = envExtra;
programs.zsh.envExtra = envExtra;
home.shellAliases = shellAliases;
programs.nushell.shellAliases = shellAliases;
xdg.configFile."doom".source = config.lib.file.mkOutOfStoreSymlink configPath;
home.activation.installDoomEmacs = lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${doomemacs}/ ${config.xdg.configHome}/emacs/
# librime for emacs-rime
mkdir -p ${librime-dir}
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${pkgs.librime}/ ${librime-dir}/
# libparinfer_rust for emacs' parinfer-rust-mode
mkdir -p ${parinfer-rust-lib-dir}
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${pkgs.vimPlugins.parinfer-rust}/lib/libparinfer_rust.* ${parinfer-rust-lib-dir}/parinfer-rust.so
'';
}
(mkIf pkgs.stdenv.isLinux (
let
# Do not use emacs-nox here, which makes the mouse wheel work abnormally in terminal mode.
# pgtk (pure gtk) build add native support for wayland.
# https://www.gnu.org/savannah-checkouts/gnu/emacs/emacs.html#Releases
emacsPkg = myEmacsPackagesFor pkgs.emacs29-pgtk;
in {
home.packages = [emacsPkg];
services.emacs = {
enable = true;
package = emacsPkg;
client = {
enable = true;
arguments = [" --create-frame"];
};
startWithUserSession = true;
};
}
))
(mkIf pkgs.stdenv.isDarwin (
let
# macport adds some native features based on GNU Emacs 29
# https://bitbucket.org/mituharu/emacs-mac/src/master/README-mac
emacsPkg = myEmacsPackagesFor pkgs.emacs29;
in {
home.packages = [emacsPkg];
launchd.enable = true;
launchd.agents.emacs = {
enable = true;
config = {
ProgramArguments = [
"${pkgs.bash}/bin/bash"
"-l"
"-c"
"${emacsPkg}/bin/emacs --fg-daemon"
];
StandardErrorPath = "${config.home.homeDirectory}/Library/Logs/emacs-daemon.stderr.log";
StandardOutPath = "${config.home.homeDirectory}/Library/Logs/emacs-daemon.stdout.log";
RunAtLoad = true;
KeepAlive = true;
};
};
}
))
]);
}