about summary refs log tree commit diff
path: root/users/sterni/emacs/default.nix
blob: 606fcb14e09e29954ba1cc84572dfb6514f7a9a8 (plain) (blame)
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
{ depot, pkgs, ... }:

let
  inherit (pkgs.emacsGcc.pkgs) withPackages;

  emacs = withPackages (epkgs: [
    # basic setup
    epkgs.elpaPackages.undo-tree
    epkgs.melpaPackages.evil
    epkgs.melpaPackages.evil-collection
    epkgs.melpaPackages.use-package
    # languages
    epkgs.bqn-mode
    epkgs.elpaPackages.ada-mode
    epkgs.melpaPackages.adoc-mode
    epkgs.melpaPackages.dockerfile-mode
    epkgs.melpaPackages.haskell-mode
    epkgs.melpaPackages.jq-mode
    epkgs.melpaPackages.languagetool
    epkgs.melpaPackages.markdown-mode
    epkgs.melpaPackages.nix-mode
    epkgs.melpaPackages.sly
    epkgs.melpaPackages.yaml-mode
    epkgs.rust-mode
    epkgs.urweb-mode
    # misc
    epkgs.melpaPackages.hl-todo
    epkgs.elpaPackages.rainbow-mode
    epkgs.melpaPackages.rainbow-delimiters
    # beyond text editing
    epkgs.melpaPackages.elfeed
    epkgs.melpaPackages.magit
    epkgs.tvlPackages.tvl
  ]);

  configDirectory = pkgs.symlinkJoin {
    name = "emacs.d";
    paths = [
      ./.
      (pkgs.writeTextFile {
        name = "injected-emacs.d";
        destination = "/nix-inject.el";
        text = ''
          ;; bqn-mode
          (setq bqn-interpreter-path "${pkgs.cbqn}/bin/BQN")

          ;; languagetool
          (setq languagetool-java-bin "${pkgs.jre}/bin/java")
          (setq languagetool-language-tool-jar "${pkgs.languagetool}/share/languagetool-commandline.jar")

          (provide 'nix-inject)
        '';
      })
    ];
    postBuild = ''
      rm "$out/default.nix"
    '';
  };
in

# sadly we can't give an init-file via the command line
pkgs.writeShellScriptBin "emacs" ''
  exec ${emacs}/bin/emacs          \
    --no-init-file                 \
    --directory ${configDirectory} \
    --eval "(require 'init)"       \
    "$@"
''