-
Notifications
You must be signed in to change notification settings - Fork 0
/
2019-12-07-000-nix-setup-for-spacemacs.html
78 lines (74 loc) · 7.94 KB
/
2019-12-07-000-nix-setup-for-spacemacs.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="alternate"
type="application/rss+xml"
href="https://magnus.therning.org/feed.xml"
title="RSS feed for https://magnus.therning.org/">
<title>Nix setup for Spacemacs</title>
<meta name="author" content="Magnus Therning"><meta name="referrer" content="no-referrer"><link href= "static/style.css" rel="stylesheet" type="text/css" /><link href= "static/htmlize.css" rel="stylesheet" type="text/css" /><link href= "static/extra_style.css" rel="stylesheet" type="text/css" /></head>
<body>
<div id="preamble" class="status"><div class="nav-bar"><a class="nav-link" href="./index.html">Top</a><a class="nav-link" href="./archive.html">Archive</a><a class="nav-link align-right" href="./feed.xml"><img src="static/rss-feed-icon.png" style="height: 24px;" /></a></div></div>
<div id="content">
<div class="post-date">07 Dec 2019</div><h1 class="post-title"><a href="https://magnus.therning.org/2019-12-07-000-nix-setup-for-spacemacs.html">Nix setup for Spacemacs</a></h1>
<p>
<i>Edit 2020-06-22: I've since found a <a href="2020-06-22-000-better-nix-setup-for-spacemacs.html">better setup for this</a>.</i>
</p>
<p>
When using <code>ghcide</code> and LSP, as I wrote about in my post on <a href="2019-09-19-000-haskell--ghcide--and-spacemacs.html">Haskell, ghcide, and
Spacemacs</a>, I found myself ending up recompiling a little too often. This pushed
me to finally start looking at <a href="https://nixos.org/nix/">Nix</a>. After a bit of a fight I managed to
<a href="https://discourse.nixos.org/t/import-and-use-ghide-nix">get ghcide from Nix</a>,
which brought me the issue of setting up Spacemacs. Inspired by <a href="https://gist.github.com/sevanspowell/23b0135dae2834e59904a502b8a0eb5d">a gist from
Samuel Evans-Powell</a> and a guide to <a href="https://github.com/thalesmg/reflex-skeleton/blob/master/Readme.org#setting-up-editor-integration-with-emacs">setting up an environment for Reflex by
Thales Macedo Garitezi</a> I ended up with the following setup:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span class="org-rainbow-delimiters-depth-1">(</span><span class="org-keyword">defun</span> <span class="org-function-name">dotspacemacs/layers</span> <span class="org-rainbow-delimiters-depth-2">()</span>
<span class="org-rainbow-delimiters-depth-2">(</span><span class="org-keyword">setq-default</span>
...
dotspacemacs-additional-packages
'<span class="org-rainbow-delimiters-depth-3">(</span>
nix-sandbox
nix-haskell-mode
...
<span class="org-rainbow-delimiters-depth-3">)</span>
...
<span class="org-rainbow-delimiters-depth-2">)</span><span class="org-rainbow-delimiters-depth-1">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span class="org-rainbow-delimiters-depth-1">(</span><span class="org-keyword">defun</span> <span class="org-function-name">dotspacemacs/user-config</span> <span class="org-rainbow-delimiters-depth-2">()</span>
...
<span class="org-rainbow-delimiters-depth-2">(</span>add-hook 'haskell-mode-hook #'lsp<span class="org-rainbow-delimiters-depth-2">)</span>
<span class="org-rainbow-delimiters-depth-2">(</span>add-hook 'haskell-mode-hook 'nix-haskell-mode<span class="org-rainbow-delimiters-depth-2">)</span>
<span class="org-rainbow-delimiters-depth-2">(</span>add-hook 'haskell-mode-hook
<span class="org-rainbow-delimiters-depth-3">(</span><span class="org-keyword">lambda</span> <span class="org-rainbow-delimiters-depth-4">()</span>
<span class="org-rainbow-delimiters-depth-4">(</span><span class="org-keyword">setq-local</span> flycheck-executable-find
<span class="org-rainbow-delimiters-depth-5">(</span><span class="org-keyword">lambda</span> <span class="org-rainbow-delimiters-depth-6">(</span>cmd<span class="org-rainbow-delimiters-depth-6">)</span>
<span class="org-rainbow-delimiters-depth-6">(</span>nix-executable-find <span class="org-rainbow-delimiters-depth-7">(</span>nix-current-sandbox<span class="org-rainbow-delimiters-depth-7">)</span> cmd<span class="org-rainbow-delimiters-depth-6">)</span><span class="org-rainbow-delimiters-depth-5">)</span><span class="org-rainbow-delimiters-depth-4">)</span>
<span class="org-rainbow-delimiters-depth-4">(</span><span class="org-keyword">setq-local</span> flycheck-command-wrapper-function
<span class="org-rainbow-delimiters-depth-5">(</span><span class="org-keyword">lambda</span> <span class="org-rainbow-delimiters-depth-6">(</span>argv<span class="org-rainbow-delimiters-depth-6">)</span>
<span class="org-rainbow-delimiters-depth-6">(</span>apply 'nix-shell-command <span class="org-rainbow-delimiters-depth-7">(</span>nix-current-sandbox<span class="org-rainbow-delimiters-depth-7">)</span> argv<span class="org-rainbow-delimiters-depth-6">)</span><span class="org-rainbow-delimiters-depth-5">)</span><span class="org-rainbow-delimiters-depth-4">)</span>
<span class="org-rainbow-delimiters-depth-4">(</span><span class="org-keyword">setq-local</span> haskell-process-wrapper-function
<span class="org-rainbow-delimiters-depth-5">(</span><span class="org-keyword">lambda</span> <span class="org-rainbow-delimiters-depth-6">(</span>argv<span class="org-rainbow-delimiters-depth-6">)</span>
<span class="org-rainbow-delimiters-depth-6">(</span>apply 'nix-shell-command <span class="org-rainbow-delimiters-depth-7">(</span>nix-current-sandbox<span class="org-rainbow-delimiters-depth-7">)</span> argv<span class="org-rainbow-delimiters-depth-6">)</span><span class="org-rainbow-delimiters-depth-5">)</span><span class="org-rainbow-delimiters-depth-4">)</span>
<span class="org-rainbow-delimiters-depth-4">(</span><span class="org-keyword">setq-local</span> lsp-haskell-process-wrapper-function
<span class="org-rainbow-delimiters-depth-5">(</span><span class="org-keyword">lambda</span> <span class="org-rainbow-delimiters-depth-6">(</span>argv<span class="org-rainbow-delimiters-depth-6">)</span>
`<span class="org-rainbow-delimiters-depth-6">(</span><span class="org-string">"nix-shell"</span> <span class="org-string">"-I"</span> <span class="org-string">"."</span> <span class="org-string">"--command"</span> <span class="org-string">"ghcide --lsp"</span> ,<span class="org-rainbow-delimiters-depth-7">(</span>nix-current-sandbox<span class="org-rainbow-delimiters-depth-7">)</span><span class="org-rainbow-delimiters-depth-6">)</span><span class="org-rainbow-delimiters-depth-5">)</span><span class="org-rainbow-delimiters-depth-4">)</span><span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span>
<span class="org-rainbow-delimiters-depth-2">(</span>add-hook 'haskell-mode-hook
<span class="org-rainbow-delimiters-depth-3">(</span><span class="org-keyword">lambda</span> <span class="org-rainbow-delimiters-depth-4">()</span>
<span class="org-rainbow-delimiters-depth-4">(</span>flycheck-add-next-checker 'lsp-ui '<span class="org-rainbow-delimiters-depth-5">(</span>warning . haskell-stack-ghc<span class="org-rainbow-delimiters-depth-5">)</span><span class="org-rainbow-delimiters-depth-4">)</span><span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span>
...
<span class="org-rainbow-delimiters-depth-1">)</span>
</pre>
</div>
<p>
It seems to work, but please let me know if you have suggestions for
improvements.
</p>
<div class="taglist"><a href="https://magnus.therning.org/tags.html">Tags</a>: <a href="https://magnus.therning.org/tag-emacs.html">emacs</a> <a href="https://magnus.therning.org/tag-nix.html">nix</a> <a href="https://magnus.therning.org/tag-spacemacs.html">spacemacs</a> </div></div>
<div id="postamble" class="status"><!-- org-static-blog-page-postamble --></div>
</body>
</html>