From c8dbcea5a2175abe1e8684ff059491a30ab8836c Mon Sep 17 00:00:00 2001 From: Alp Mestanogullari Date: Sat, 2 Dec 2017 01:12:47 +0100 Subject: [PATCH] add shell.nix for building servant (+ tutorial + cookbook, optionally) --- .gitignore | 2 -- nix/README.md | 23 +++++++++++++++++++++++ nix/shell.nix | 21 +++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 nix/README.md create mode 100644 nix/shell.nix diff --git a/.gitignore b/.gitignore index 16abfc41..98bf1884 100644 --- a/.gitignore +++ b/.gitignore @@ -25,8 +25,6 @@ cabal.config *.hp Setup .stack-work -shell.nix -default.nix doc/_build doc/venv doc/tutorial/static/api.js diff --git a/nix/README.md b/nix/README.md new file mode 100644 index 00000000..56400fbd --- /dev/null +++ b/nix/README.md @@ -0,0 +1,23 @@ +You can use the `shell.nix` from this directory +to build the servant packages or even the tutorial +or cookbook if you want to, optionally. + +Just the servant packages: + +``` sh +$ nix-shell nix/shell.nix +``` + +Everything needed for the tutorial and the +cookbook too: + +``` sh +$ nix-shell nix/shell.nix --arg tutorial true +``` + +The `shell.nix` file also supports specifying +a particular ghc version, e.g: + +``` sh +$ nix-shell nix/shell.nix --argstr compiler ghcHEAD +``` diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 00000000..637aaeb2 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,21 @@ +{ pkgs ? import {} +, compiler ? "ghc821" +, tutorial ? false +}: + +with pkgs; + +let + ghc = haskell.packages.${compiler}.ghcWithPackages (_: []); + docstuffs = python3.withPackages (ps: with ps; [ recommonmark sphinx sphinx_rtd_theme ]); +in + +stdenv.mkDerivation { + name = "servant-dev"; + buildInputs = [ ghc zlib ] + ++ (if tutorial then [docstuffs postgresql] else []); + shellHook = '' + eval $(grep export ${ghc}/bin/ghc) + export LD_LIBRARY_PATH="${zlib}/lib"; + ''; +}