summaryrefslogtreecommitdiff
path: root/modules/nixfiles/emacs/default.nix
blob: a972060070a8ef9d80e0f1b424b856457a5c6f4f (plain)
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
{
  config,
  inputs,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.emacs;
in {
  options.nixfiles.modules.emacs.enable =
    mkEnableOption "GNU Emacs";

  config = mkIf cfg.enable {
    # TODO Make magit-forge to work with this.
    secrets.authinfo = {
      file = "${inputs.self}/secrets/authinfo";
      path = "${config.my.home}/.authinfo";
      owner = my.username;
      inherit (config.my) group;
    };

    nixfiles.modules = {
      fonts.enable = true;
      git.enable = true;
      gnupg.enable = true;
      x11.enable = true;
    };

    hm = {
      imports = [inputs.nix-doom-emacs.hmModule];

      programs.doom-emacs = {
        enable = true;
        doomPrivateDir = ./doom;
        # NOTE NativeComp breaks non-latin fonts and takes a long time to
        # perform updates while giving miniscule speed improvements. Emacs is
        # still a laggy and slow piece of shit regardless of enabling this flag
        # or not.
        # emacsPackage = pkgs.emacs28.override {nativeComp = true;};
        emacsPackage = pkgs.emacs28;
        extraPackages = with pkgs; [
          mu # :email mu4e
        ];
        extraConfig = let
          extraBins = with pkgs; [
            (aspellWithDicts (p: with p; [en ru])) # :checkers spell (+aspell)
            asmfmt # :editor format
            bash-language-server # :lang (sh +lsp)
            clang-tools # :lang (cc +lsp) :editor format
            cmake-format # :lang cc :editor format
            cmigemo # :lang japanese
            dockerfile-language-server # :tools (docker +lsp)
            editorconfig # :tools editorconfig
            fd # core
            gnuplot # :lang (org +gnuplot)
            gnutls # core
            gomodifytags # :lang go
            gopls # :lang (go +lsp)
            gore # :lang go
            gotests # :lang go
            graphviz # :lang (org +roam2) :lang plantuml
            grip # :lang (markdown +grip)
            haskell-language-server # :lang (haskell +lsp)
            haskellPackages.brittany # :lang haskell :editor format
            haskellPackages.cabal-fmt # :lang haskell :editor format
            haskellPackages.cabal-install # :lang haskell
            haskellPackages.hoogle # :lang haskell
            html-tidy # :lang web
            jre # :lang plantuml
            lua-language-server # :lang (lua +lsp)
            nix-language-server # :lang (nix +lsp)
            nixfmt # :lang nix :editor format
            nodePackages.js-beautify # :lang web
            nodePackages.lua-fmt # :lang lua :editor format
            nodePackages.prettier # :editor format
            nodePackages.stylelint # :lang web
            pandoc # :lang org markdown latex
            pre-commit # :tools magit
            python3Packages.black # :lang python :editor format
            python3Packages.isort # :lang python
            python3Packages.pyflakes # :lang python
            ripgrep # core
            shellcheck # :lang sh
            shfmt # :lang sh :editor format
            sqlite # :lang (org +roam2) :tools lookup
            texlive.combined.scheme-full # :lang org tex
            wordnet # :tools (lookup +dictionary +offline)
            yaml-language-server # :lang (yaml +lsp)
            zls # :lang (zig +lsp)
          ];
        in ''
          ;; This will integrate packages, which are required by various modules
          ;; without polluting the user's profile.
          (setq exec-path (append exec-path '(${
            concatMapStringsSep " " (x: ''"${x}/bin"'') extraBins
          })))
          (setenv "PATH" (concat (getenv "PATH") ":${
            concatMapStringsSep ":" (x: "${x}/bin") extraBins
          }"))

          ;; :lang plantuml
          (setq org-plantuml-jar-path "${pkgs.plantuml}/lib/plantuml.jar")

          ;; :input japanese
          (setq migemo-dictionary "${pkgs.cmigemo}/share/migemo/utf-8/migemo-dict")

          ;; :input japanese
          (setq skk-large-jisyo "${pkgs.skk-dicts}/share/skk/SKK-JISYO.L")

          (setq user-full-name "${my.fullname}"
                user-mail-address "${my.email}")

          (setq circe-default-nick "${my.username}"
                circe-default-realname "${my.fullname}"
                circe-default-user circe-default-nick)

          (setq doom-font (font-spec
                          :family "${config.fontScheme.monospaceFont.family}"
                          :size ${toString config.fontScheme.monospaceFont.size})
                doom-unicode-font doom-font)
        '';
      };

      services.emacs = {
        enable = true;
        client.enable = true;
      };
    };
  };
}