mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-25 17:46:14 +01:00
49504a10e8
Signed-off-by: Magic_RB <magic_rb@redalder.org>
156 lines
4.1 KiB
Nix
156 lines
4.1 KiB
Nix
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
|
#
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
{
|
|
pkgs,
|
|
config,
|
|
lib,
|
|
secret,
|
|
...
|
|
}:
|
|
with lib; let
|
|
cfg = config.magic_rb.programs.emacs;
|
|
in {
|
|
options.magic_rb.programs.emacs = {
|
|
enable = mkEnableOption "Enable emacs with my config";
|
|
enableMu4e = mkEnableOption "Enable mu4e in emacs. WARNING: requires secrets";
|
|
package = mkOption {
|
|
description = "Which emacs package to use.";
|
|
type = types.package;
|
|
default = let
|
|
# gensymb is not here, dont add
|
|
tex = with pkgs;
|
|
texlive.combine
|
|
{
|
|
inherit
|
|
(texlive)
|
|
scheme-full
|
|
;
|
|
};
|
|
r = with pkgs;
|
|
rWrapper.override
|
|
{packages = with rPackages; [ggplot2];};
|
|
in
|
|
(pkgs.emacs-magicrb.override
|
|
{
|
|
pkgs.emacs = pkgs.emacs.overrideAttrs
|
|
(old:
|
|
{
|
|
# patches = [ ./native-comp-driver-options.patch ];
|
|
});
|
|
march = config.magic_rb.optimisation.march;
|
|
hunspell.enable = true;
|
|
hunspell.dictionaries = with pkgs.hunspellDicts; [en_US];
|
|
environment = {
|
|
MU4E_CONTEXTS = mkIf cfg.enableMu4e secret.emacs.mu4eContexts;
|
|
};
|
|
additionalPackages =
|
|
[
|
|
tex
|
|
r
|
|
]
|
|
++ (with pkgs; [
|
|
krita
|
|
ripgrep
|
|
mu
|
|
isync
|
|
exa
|
|
fd
|
|
nil
|
|
graphviz
|
|
]);
|
|
})
|
|
.bundle;
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = with pkgs; [
|
|
cfg.package
|
|
(makeDesktopItem {
|
|
name = "Org-Protocol";
|
|
exec = "emacsclient %u";
|
|
comment = "Org protocol";
|
|
desktopName = "org-protocol";
|
|
type = "Application";
|
|
mimeTypes = ["x-scheme-handler/org-protocol"];
|
|
})
|
|
|
|
fira-code
|
|
(iosevka-bin.override {variant = "aile";})
|
|
(iosevka-bin.override {variant = "etoile";})
|
|
(iosevka-bin.override {variant = "";})
|
|
emacs-all-the-icons-fonts
|
|
];
|
|
|
|
fonts.fontconfig.enable = true;
|
|
|
|
home.activation.emacsStraightVerions =
|
|
config.lib.dag.entryAfter
|
|
["writeBoundary"] ''
|
|
mkdir -p ~/.emacs.d/straight/versions
|
|
ln -sfn ~/dotfiles/home-manager/modules/emacs/straight-versions.el ~/.emacs.d/straight/versions/default.el
|
|
'';
|
|
|
|
systemd.user.services.emacs = {
|
|
Unit = {
|
|
After = "graphical-session.target";
|
|
PartOf = "graphical-session.target";
|
|
X-RestartIfChanged = false;
|
|
};
|
|
|
|
Service = {
|
|
Type = "notify";
|
|
ExecStart = ''${pkgs.runtimeShell} -l -c "${lib.getExe cfg.package} --fg-daemon"'';
|
|
|
|
# Emacs will exit with status 15 after having received SIGTERM, which
|
|
# is the default "KillSignal" value systemd uses to stop services.
|
|
SuccessExitStatus = 15;
|
|
|
|
Restart = "on-failure";
|
|
};
|
|
|
|
Install = {
|
|
WantedBy = [
|
|
"graphical-session.target"
|
|
];
|
|
};
|
|
};
|
|
|
|
home.file = {
|
|
".emacs".source = ./.emacs;
|
|
".mbsyncrc" = mkIf cfg.enableMu4e {
|
|
source = secret.emacs.mbsyncrc;
|
|
};
|
|
".emacs.d/org" = {
|
|
source = ./.emacs.d/org;
|
|
recursive = true;
|
|
};
|
|
".emacs.d/lisp" = {
|
|
source = ./.emacs.d/lisp;
|
|
recursive = true;
|
|
};
|
|
".emacs.d/mu4e-contexts" = mkIf cfg.enableMu4e {
|
|
source = secret.emacs.mu4eContexts;
|
|
};
|
|
".emacs.d/tree-sitter" = {
|
|
source =
|
|
pkgs.linkFarm "grammars"
|
|
(map
|
|
(drv:
|
|
let
|
|
name = lib.strings.getName drv;
|
|
in
|
|
{
|
|
name = "lib" +
|
|
(lib.strings.removeSuffix "-grammar" name)
|
|
+ ".so";
|
|
path = "${drv}/parser";
|
|
}
|
|
)
|
|
(builtins.attrValues pkgs.tree-sitter.builtGrammars));
|
|
};
|
|
};
|
|
};
|
|
}
|