unclechu's fork of gRPC-haskell
Find a file
Joel Stanley 8a6a7c3715 MONAPP-3634: Improve stack/nix experience and MacOS development environment sanity (#84)
* Update tests.patch

* release.nix fixes for building and running cabal test suite from inside the nix-shell environment

* Update build instructions

* More README updates

* Fix stack tooling and improve documentation

* Update grpc sha256, cleanup build instructions

* Whups, DYLD_LIBRARY_PATH and substituteInPlace is still needed for hydra / macos builds with no brew-installed grpc!

* PR feedback tweaks
2016-12-19 16:53:44 -06:00
bench fix up benchmarks to run with latest changes (#72) 2016-08-26 10:21:59 -07:00
cbits Connor/security (#68) 2016-08-17 09:55:06 -07:00
examples Connor/security (#68) 2016-08-17 09:55:06 -07:00
include Connor/security (#68) 2016-08-17 09:55:06 -07:00
nix MONAPP-3634: Improve stack/nix experience and MacOS development environment sanity (#84) 2016-12-19 16:53:44 -06:00
src/Network/GRPC MONAPP-1369: Server options for generated code. (#76) 2016-11-30 14:22:47 -08:00
tests MONAPP-3634: Improve stack/nix experience and MacOS development environment sanity (#84) 2016-12-19 16:53:44 -06:00
.gitignore Criterion benchmarks (#50) 2016-07-26 15:48:25 -07:00
default.nix Fix grpc-haskell tests for Nix (#80) 2016-12-12 10:40:23 -08:00
grpc-haskell.cabal Fix author/maintainer/copyright in grpc-haskell.cabal (#82) 2016-12-14 12:55:56 -06:00
LICENSE Fix author/maintainer/copyright in grpc-haskell.cabal (#82) 2016-12-14 12:55:56 -06:00
README.md MONAPP-3634: Improve stack/nix experience and MacOS development environment sanity (#84) 2016-12-19 16:53:44 -06:00
release.nix MONAPP-3634: Improve stack/nix experience and MacOS development environment sanity (#84) 2016-12-19 16:53:44 -06:00
Setup.hs Initial commit. 2015-02-27 18:14:32 +01:00
stack.yaml MONAPP-3634: Improve stack/nix experience and MacOS development environment sanity (#84) 2016-12-19 16:53:44 -06:00

Building and testing

You will need to have GRPC installed already. See the "Installing GRPC" section below for more information.

nix-build release.nix -A grpc-haskell will build and test the whole thing and put the completed package into the nix store.

nix-shell can be used to give you a development environment where you can use the cabal and stack test toolchains for development and testing iteration.

$ nix-shell release-nix -A grpc-haskell.env
[nix-shell]$ cabal configure --with-gcc=clang --enable-tests && cabal build && cabal test
$ nix-shell release-nix -A grpc-haskell.env
[nix-shell]$ stack build --fast && stack test --fast

Note that, for stack, the nix-shell environment only needed to run the tests, because it uses some custom python tooling (for grpc interop testing). You should still be able to stack build without using the nix-shell environment at all. See the section below on installing GRPC for use by stack.

NB: You can also instruct stack to run the tests inside the nix-shell environment directly, via stack --nix test --fast. However, this will frequently rebuild the custom ghc that is used by the nix tooling so is not recommended for development iterations.

Finally, since stack does not use nix for any Haskell dependencies, repository references for dependent packages such as protobuf-wire must be updated both in nix/<pkg>.nix AND in the stack.yaml.

Installing GRPC for stack

If you want to use the stack tooling, you will need a working installation of the GRPC C core libraries.

On MacOS, because of this, dependencies on the nix-built grpc don't work properly, so the library needs to be installed somewhere the linker will pick it up without DYLD_LIBRARY_PATH set.

We suggest that use brew to do this:

brew tap grpc/grpc
brew edit grpc
...
brew install grpc

Make sure you select a release version that is reasonably close to our grpc dependency, e.g.:

url "https://github.com/grpc/grpc/archive/release-0_15_0.tar.gz"
sha256 "d02235dff278869e94cb0dcb31cfea935693c6f87bd73f43d44147185e6becdd"

or

url "https://github.com/grpc/grpc/archive/v1.0.1.tar.gz"
sha256 "efad782944da13d362aab9b81f001b7b8b1458794751de818e9848c47acd4b32"

Using the Library

You must compile with -threaded, because we rely on being able to execute Haskell while blocking on foreign calls to the gRPC library. If not using code generation, the recommended place to start is in the Network.GRPC.HighLevel.Server.Unregistered module, where serverLoop provides a handler loop.