add shell.nix for building servant (+ tutorial + cookbook, optionally)
commitc8dbcea5a2175abe1e8684ff059491a30ab8836c
authorAlp Mestanogullari <alpmestan@gmail.com>
dateSat 2 Dec 2017, 01:12 (9 years ago)
parente2314aa
.gitignore−2
@@ -25,8 +25,6 @@ cabal.config
2525*.hp
2626Setup
2727.stack-work
28−shell.nix
29−default.nix
3028doc/_build
3129doc/venv
3230doc/tutorial/static/api.js
nix/README.mdnew file+23
@@ -0,0 +1,23 @@
1+You can use the `shell.nix` from this directory
2+to build the servant packages or even the tutorial
3+or cookbook if you want to, optionally.
4+
5+Just the servant packages:
6+
7+``` sh
8+$ nix-shell nix/shell.nix
9+```
10+
11+Everything needed for the tutorial and the
12+cookbook too:
13+
14+``` sh
15+$ nix-shell nix/shell.nix --arg tutorial true
16+```
17+
18+The `shell.nix` file also supports specifying
19+a particular ghc version, e.g:
20+
21+``` sh
22+$ nix-shell nix/shell.nix --argstr compiler ghcHEAD
23+```
nix/shell.nixnew file+21
@@ -0,0 +1,21 @@
1+{ pkgs ? import <nixpkgs> {}
2+, compiler ? "ghc821"
3+, tutorial ? false
4+}:
5+
6+with pkgs;
7+
8+let
9+ ghc = haskell.packages.${compiler}.ghcWithPackages (_: []);
10+ docstuffs = python3.withPackages (ps: with ps; [ recommonmark sphinx sphinx_rtd_theme ]);
11+in
12+
13+stdenv.mkDerivation {
14+ name = "servant-dev";
15+ buildInputs = [ ghc zlib ]
16+ ++ (if tutorial then [docstuffs postgresql] else []);
17+ shellHook = ''
18+ eval $(grep export ${ghc}/bin/ghc)
19+ export LD_LIBRARY_PATH="${zlib}/lib";
20+ '';
21+}