about summary refs log tree commit diff
path: root/emacs.nix
blob: 84408b636686294fa658e284749ca9ea25dc60a1 (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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# Derivation for Emacs pre-configured with packages that I need.
#
# * TODO 2018-06-15: sly removed due to build error in unstable
{ pkgs }:

with pkgs.unstable; with emacsPackagesNg;
let emacsWithPackages = (emacsPackagesNgGen emacs).emacsWithPackages;

# The nix-mode in the official repositories is old and annoying to
# work with, pin it to something newer instead:
nix-mode = emacsPackagesNg.melpaBuild {
  pname   = "nix-mode";
  version = "20180306";

  src = fetchFromGitHub {
    owner  = "NixOS";
    repo   = "nix-mode";
    rev    = "0ac0271f6c8acdbfddfdbb1211a1972ae562ec17";
    sha256 = "157vy4xkvaqd76km47sh41wykbjmfrzvg40jxgppnalq9pjxfinp";
  };

  recipeFile = writeText "nix-mode-recipe" ''
    (nix-mode :repo "NixOS/nix-mode" :fetcher github
              :files (:defaults (:exclude "nix-mode-mmm.el")))
  '';
};

# The default Rust language server mode is not really usable, install
# `eglot` instead and hope for the best.
eglot = emacsPackagesNg.melpaBuild rec {
  pname = "eglot";
  version = "0.8";

  src = fetchFromGitHub {
    owner  = "joaotavora";
    repo   = "eglot";
    rev    = version;
    sha256 = "1avsry84sp3s2vr2iz9dphm579xgw8pqlwffl75gn5akykgazwdx";
  };
};

# ivy has not been updated in unstable for a while:
ivySource = fetchFromGitHub {
  owner  = "abo-abo";
  repo   = "swiper";
  rev    = "6f2939485d33e9b28022d3b6912a50669dcdd596";
  sha256 = "1f2i6hkcbiqdw7fr9vabsm32a0gy647llzki6b97yv8vwa0klh2q";
};

withIvySources = pname: recipe: emacsPackagesNg.melpaBuild {
  inherit pname;
  version = "20180616";
  recipeFile = builtins.toFile "${pname}-recipe" recipe;
  src = ivySource;
};

newIvy.ivy = withIvySources "ivy" ''
(ivy :files (:defaults
             (:exclude "swiper.el" "counsel.el" "ivy-hydra.el")
             "doc/ivy-help.org"))
'';

newIvy.counsel = withIvySources "counsel" ''
(counsel :files ("counsel.el"))
'';

newIvy.swiper = withIvySources "swiper" ''
(swiper :files ("swiper.el"))
'';

newIvy.ivy-pass = melpaBuild {
  pname = "ivy-pass";
  version = "20170812";
  src = fetchFromGitHub {
    owner  = "ecraven";
    repo   = "ivy-pass";
    rev    = "5b523de1151f2109fdd6a8114d0af12eef83d3c5";
    sha256 = "18crb4zh2pjf0cmv3b913m9vfng27girjwfqc3mk7vqd1r5a49yk";
  };
};

counsel-notmuch = melpaBuild {
  pname   = "counsel-notmuch";
  version = "20171223";

  packageRequires = [
    newIvy.ivy
    pkgs.notmuch
  ];

  src = fetchFromGitHub {
    owner  = "fuxialexander";
    repo   = "counsel-notmuch";
    rev    = "ac1aaead81c6860d7b8324cc1c00bcd52de5e9ca";
    sha256 = "19frcrz6bx7d7v1hkg0xv7zmbk2sydlsdzn1s96cqzjk1illchkz";
  };
};

# prescient & ivy-prescient provide better filtering in ivy/counsel,
# but they are not in nixpkgs yet:
prescientSource = fetchFromGitHub {
  owner  = "raxod502";
  repo   = "prescient.el";
  rev    = "27c94636489d5b062970a0f7e9041ca186b6b659";
  sha256 = "05jk8cms48dhpbaimmx3akmnq32fgbc0q4dja7lvpvssmq398cn7";
};

prescient = emacsPackagesNg.melpaBuild {
  pname   = "prescient";
  version = "1.0";
  src     = prescientSource;

  recipeFile = writeText "prescient-recipe" ''
    (prescient :files ("prescient.el"))
  '';
};

ivy-prescient = emacsPackagesNg.melpaBuild {
  pname   = "ivy-prescient";
  version = "1.0";
  src     = prescientSource;
  packageRequires = [ prescient newIvy.ivy ];

  recipeFile = writeText "ivy-prescient-recipe" ''
    (ivy-prescient :files ("ivy-prescient.el"))
  '';
};

sly = emacsPackagesNg.melpaBuild {
  pname           = "sly";
  version         = "20180613";
  packageRequires = [ elpaPackages.company ];

  src = fetchFromGitHub {
    owner  = "joaotavora";
    repo   = "sly";
    rev    = "a05b45f1564a86a9d49707c9c570da6c3a56b6e5";
    sha256 = "1c9xzppxlnak1px0dv0ljpp4izfj4377lncvrcb1jaiyh8z8ry48";
  };

  recipeFile = writeText "sly-recipe" ''
    (sly :files ("*.el"
                 ("lib" "lib/*")
                 ("contrib" "contrib/*")))
  '';
};

in emacsWithPackages(epkgs:
  # Actual ELPA packages (the enlightened!)
  (with epkgs.elpaPackages; [
    ace-window
    adjust-parens
    avy
    company
    pinentry
    rainbow-mode
    undo-tree
    which-key
  ]) ++

  # MELPA packages:
  (with epkgs.melpaPackages; [
    alchemist
    browse-kill-ring
    cargo
    dash
    dash-functional
    dockerfile-mode
    edit-server
    elixir-mode
    erlang
    exwm
    go-mode
    gruber-darker-theme
    haskell-mode
    ht
    hydra
    idle-highlight-mode
    jq-mode
    kotlin-mode
    magit
    markdown-mode
    markdown-toc
    multi-term
    multiple-cursors
    nginx-mode
    paredit
    password-store
    pg
    rainbow-delimiters
    restclient
    rust-mode
    s
    smartparens
    string-edit
    telephone-line
    terraform-mode
    toml-mode
    use-package
    uuidgen
    web-mode
    websocket
    yaml-mode
  ]) ++

  # Use custom updated ivy packages
  (lib.attrValues newIvy) ++

  # Custom packaged Emacs packages:
  [ nix-mode eglot prescient ivy-prescient counsel-notmuch pkgs.notmuch sly ]
)