2016-12-12 19:40:23 +01:00
|
|
|
# If you would like to test and build changes quickly using `cabal`, run:
|
2016-08-01 19:02:23 +02:00
|
|
|
#
|
2016-12-12 19:40:23 +01:00
|
|
|
# $ # Consider adding the following command to your `~/.profile`
|
|
|
|
# $ NIX_PATH="${NIX_PATH}:ssh-config-file=${HOME}/.ssh/config:ssh-auth-sock=${SSH_AUTH_SOCK}"
|
|
|
|
# $ nix-shell -A grpc-haskell.env release.nix
|
|
|
|
# [nix-shell]$ cabal configure --with-gcc=clang --enable tests
|
2016-08-01 19:02:23 +02:00
|
|
|
#
|
2016-12-12 19:40:23 +01:00
|
|
|
# This will open up a Nix shell where all of your Haskell tools will work like
|
|
|
|
# normal, except that all dependencies (including C libraries) are managed by
|
|
|
|
# Nix. The only thing that won't work is running tests inside this shell
|
|
|
|
# (although you can still build them). Fixing the test suite requires
|
|
|
|
# extensive patching of the test scripts (see `postPatch` below)
|
2016-08-01 19:02:23 +02:00
|
|
|
#
|
2016-12-12 19:40:23 +01:00
|
|
|
# Note that this will compile the library once without tests using Nix. This
|
|
|
|
# is due to the fact that `grpc-haskell`'s test suite cannot test code
|
|
|
|
# generation without the library being built at least once.
|
|
|
|
#
|
|
|
|
# If you want to build and test this repository using `nix`, you can run the
|
|
|
|
# following command:
|
|
|
|
#
|
|
|
|
# $ nix-build -A grpc-haskell release.nix
|
|
|
|
#
|
|
|
|
# ... but this is not recommended for normal development because this will
|
|
|
|
# rebuild the repository from scratch every time, which is extremely slow. Only
|
|
|
|
# do this if you want to exactly reproduce our continuous integration build.
|
|
|
|
#
|
|
|
|
# If you update the `grpc-haskell.cabal` file (such as changing dependencies or
|
|
|
|
# adding new library/executable/test/benchmark sections), then update the
|
|
|
|
# `default.nix` expression by running:
|
2016-08-01 19:02:23 +02:00
|
|
|
#
|
|
|
|
# $ cabal2nix . > default.nix
|
|
|
|
#
|
2016-12-12 19:40:23 +01:00
|
|
|
# By default, Nix will pick a version for each one of your Haskell dependencies.
|
|
|
|
# If you would like to select a different version then, run:
|
2016-08-01 19:02:23 +02:00
|
|
|
#
|
2016-12-12 19:40:23 +01:00
|
|
|
# $ cabal2nix cabal://${package-name}-${version} > nix/${package-name}.nix
|
2016-08-01 19:02:23 +02:00
|
|
|
#
|
2016-12-12 19:40:23 +01:00
|
|
|
# ... and then add this line below in the Haskell package overrides section:
|
2016-08-01 19:02:23 +02:00
|
|
|
#
|
2016-12-12 19:40:23 +01:00
|
|
|
# ${package-name} =
|
|
|
|
# haskellPackagesNew.callPackage ./nix/${package-name}.nix { };
|
2016-08-01 19:02:23 +02:00
|
|
|
#
|
2016-12-12 19:40:23 +01:00
|
|
|
# ... replacing `${package-name}` with the name of the package that you would
|
|
|
|
# like to upgrade and `${version}` with the version you want to upgrade to.
|
|
|
|
#
|
|
|
|
# You can also add private Git dependencies in the same way, except supplying
|
|
|
|
# the `git` URL to clone:
|
|
|
|
#
|
|
|
|
# $ cabal2nix git@github.mv.awakenetworks.net:awakenetworks/${package-name}.git > ./nix/${package-name}.nix
|
|
|
|
#
|
|
|
|
# `cabal2nix` also takes an optional `--revision` flag if you want to pick a
|
|
|
|
# revision other than the latest one to depend on.
|
|
|
|
#
|
|
|
|
# If you want to test a local source checkout of a dependency, then run:
|
|
|
|
#
|
|
|
|
# $ cabal2nix path/to/dependency/repo > nix/${package-name}.nix
|
2016-08-01 19:02:23 +02:00
|
|
|
let
|
|
|
|
config = {
|
|
|
|
packageOverrides = pkgs: rec {
|
2016-12-12 19:40:23 +01:00
|
|
|
cython = pkgs.buildPythonPackage rec {
|
|
|
|
name = "Cython-${version}";
|
|
|
|
version = "0.24.1";
|
|
|
|
|
|
|
|
src = pkgs.fetchurl {
|
|
|
|
url = "mirror://pypi/C/Cython/${name}.tar.gz";
|
|
|
|
sha256 = "84808fda00508757928e1feadcf41c9f78e9a9b7167b6649ab0933b76f75e7b9";
|
|
|
|
};
|
|
|
|
|
|
|
|
# This workaround was taken from https://github.com/NixOS/nixpkgs/issues/18729
|
|
|
|
# This was fixed in `nixpkgs-unstable` so we can get rid of this workaround
|
|
|
|
# when that fix is stabilized
|
|
|
|
NIX_CFLAGS_COMPILE =
|
|
|
|
pkgs.stdenv.lib.optionalString (pkgs.stdenv.cc.isClang or false)
|
|
|
|
"-I${pkgs.libcxx}/include/c++/v1";
|
|
|
|
|
|
|
|
buildInputs =
|
|
|
|
pkgs.stdenv.lib.optional (pkgs.stdenv.cc.isClang or false) pkgs.libcxx
|
|
|
|
++ [ pkgs.pkgconfig pkgs.gdb ];
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
doHaddock = false;
|
|
|
|
|
|
|
|
doHoogle = false;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "An optimising static compiler for both the Python programming language and the extended Cython programming language";
|
|
|
|
platforms = pkgs.stdenv.lib.platforms.all;
|
|
|
|
homepage = http://cython.org;
|
|
|
|
license = pkgs.stdenv.lib.licenses.asl20;
|
|
|
|
maintainers = with pkgs.stdenv.lib.maintainers; [ fridh ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
grpc = pkgs.callPackage ./nix/grpc.nix { };
|
|
|
|
|
|
|
|
grpcio = pkgs.pythonPackages.buildPythonPackage rec {
|
|
|
|
name = "grpc-${version}";
|
|
|
|
|
|
|
|
version = "1.0";
|
|
|
|
|
2016-08-01 19:02:23 +02:00
|
|
|
src = pkgs.fetchgit {
|
|
|
|
url = "https://github.com/grpc/grpc.git";
|
2016-12-12 19:40:23 +01:00
|
|
|
rev = "c204647295437b01337ad8e6c17c4296609c7a13";
|
|
|
|
sha256 = "0ifg5acwcb0qyf5g5mrja8ab4x3f1fxdw80rkmhn3kyjkhjzm9ik";
|
2016-08-01 19:02:23 +02:00
|
|
|
};
|
2016-12-12 19:40:23 +01:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
export GRPC_PYTHON_BUILD_WITH_CYTHON=1
|
|
|
|
'';
|
|
|
|
|
|
|
|
# This workaround was taken from https://github.com/NixOS/nixpkgs/issues/18729
|
|
|
|
# This was fixed in `nixpkgs-unstable` so we can get rid of this workaround
|
|
|
|
# when that fix is stabilized
|
|
|
|
NIX_CFLAGS_COMPILE =
|
|
|
|
pkgs.stdenv.lib.optionalString (pkgs.stdenv.cc.isClang or false)
|
|
|
|
"-I${pkgs.libcxx}/include/c++/v1";
|
|
|
|
|
|
|
|
buildInputs =
|
|
|
|
pkgs.stdenv.lib.optional (pkgs.stdenv.cc.isClang or false) pkgs.libcxx;
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
cython
|
|
|
|
pkgs.pythonPackages.futures
|
|
|
|
pkgs.pythonPackages.protobuf3_0
|
|
|
|
pkgs.pythonPackages.enum34
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
grpcio-tools = pkgs.pythonPackages.buildPythonPackage rec {
|
|
|
|
name = "grpc-${version}";
|
|
|
|
|
|
|
|
version = "1.0";
|
|
|
|
|
|
|
|
src = pkgs.fetchgit {
|
|
|
|
url = "https://github.com/grpc/grpc.git";
|
|
|
|
rev = "c204647295437b01337ad8e6c17c4296609c7a13";
|
|
|
|
sha256 = "0ifg5acwcb0qyf5g5mrja8ab4x3f1fxdw80rkmhn3kyjkhjzm9ik";
|
|
|
|
};
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
export GRPC_PYTHON_BUILD_WITH_CYTHON=1
|
|
|
|
cd tools/distrib/python/grpcio_tools
|
|
|
|
python ../make_grpcio_tools.py
|
|
|
|
'';
|
|
|
|
|
|
|
|
# This workaround was taken from https://github.com/NixOS/nixpkgs/issues/18729
|
|
|
|
# This was fixed in `nixpkgs-unstable` so we can get rid of this workaround
|
|
|
|
# when that fix is stabilized
|
|
|
|
NIX_CFLAGS_COMPILE =
|
|
|
|
pkgs.stdenv.lib.optionalString (pkgs.stdenv.cc.isClang or false)
|
|
|
|
"-I${pkgs.libcxx}/include/c++/v1";
|
|
|
|
|
2016-08-01 19:02:23 +02:00
|
|
|
buildInputs =
|
2016-12-12 19:40:23 +01:00
|
|
|
pkgs.stdenv.lib.optional (pkgs.stdenv.cc.isClang or false) pkgs.libcxx;
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
cython
|
|
|
|
pkgs.pythonPackages.futures
|
|
|
|
pkgs.pythonPackages.protobuf3_0
|
|
|
|
pkgs.pythonPackages.enum34
|
|
|
|
grpcio
|
2016-08-01 19:02:23 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
haskellPackages = pkgs.haskell.packages.ghc7103.override {
|
2016-08-05 18:29:20 +02:00
|
|
|
overrides = haskellPackagesNew: haskellPackagesOld: rec {
|
2016-08-01 19:02:23 +02:00
|
|
|
proto3-wire =
|
2016-12-12 19:40:23 +01:00
|
|
|
haskellPackagesNew.callPackage ./nix/proto3-wire.nix { };
|
2016-08-01 19:02:23 +02:00
|
|
|
|
|
|
|
protobuf-wire =
|
2016-12-12 19:40:23 +01:00
|
|
|
pkgs.haskell.lib.dontCheck
|
|
|
|
(haskellPackagesNew.callPackage ./nix/protobuf-wire.nix {
|
|
|
|
fetchgit = pkgs.fetchgitPrivate;
|
|
|
|
});
|
2016-08-01 19:02:23 +02:00
|
|
|
|
2016-08-05 18:29:20 +02:00
|
|
|
grpc-haskell-no-tests =
|
2016-12-12 19:40:23 +01:00
|
|
|
pkgs.haskell.lib.overrideCabal
|
|
|
|
(haskellPackagesNew.callPackage ./default.nix { })
|
|
|
|
(oldDerivation: {
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
preBuild =
|
|
|
|
pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
|
|
|
|
export DYLD_LIBRARY_PATH=${grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
|
|
|
|
'';
|
|
|
|
});
|
2016-08-03 20:47:52 +02:00
|
|
|
|
2016-08-05 18:29:20 +02:00
|
|
|
grpc-haskell =
|
2016-12-12 19:40:23 +01:00
|
|
|
pkgs.haskell.lib.overrideCabal
|
|
|
|
(haskellPackagesNew.callPackage ./default.nix { })
|
|
|
|
(oldDerivation:
|
|
|
|
let
|
|
|
|
ghc =
|
|
|
|
haskellPackagesNew.ghcWithPackages (pkgs: [
|
|
|
|
pkgs.grpc-haskell-no-tests
|
|
|
|
]);
|
|
|
|
|
|
|
|
python = pkgs.python.withPackages (pkgs: [
|
|
|
|
# pkgs.protobuf3_0
|
|
|
|
grpcio-tools
|
|
|
|
]);
|
|
|
|
|
|
|
|
in rec {
|
|
|
|
buildDepends = [ pkgs.makeWrapper ];
|
|
|
|
|
|
|
|
patches = [ tests/tests.patch ];
|
|
|
|
|
|
|
|
preBuild =
|
|
|
|
pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
|
|
|
|
export DYLD_LIBRARY_PATH=${grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
|
|
|
|
'';
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs tests
|
|
|
|
substituteInPlace tests/simple-client.sh \
|
|
|
|
--replace @makeWrapper@ ${pkgs.makeWrapper} \
|
|
|
|
--replace @grpc@ ${grpc}
|
|
|
|
substituteInPlace tests/simple-server.sh \
|
|
|
|
--replace @makeWrapper@ ${pkgs.makeWrapper} \
|
|
|
|
--replace @grpc@ ${grpc}
|
|
|
|
wrapProgram tests/protoc.sh \
|
|
|
|
--prefix PATH : ${python}/bin
|
|
|
|
wrapProgram tests/test-client.sh \
|
|
|
|
--prefix PATH : ${python}/bin
|
|
|
|
wrapProgram tests/test-server.sh \
|
|
|
|
--prefix PATH : ${python}/bin
|
|
|
|
wrapProgram tests/simple-client.sh \
|
|
|
|
--prefix PATH : ${ghc}/bin
|
|
|
|
wrapProgram tests/simple-server.sh \
|
|
|
|
--prefix PATH : ${ghc}/bin
|
|
|
|
'';
|
|
|
|
|
2016-12-12 22:45:58 +01:00
|
|
|
postInstall = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
|
|
|
|
wrapProgram $out/bin/hellos-client --prefix DYLD_LIBRARY_PATH : ${grpc}/lib
|
|
|
|
wrapProgram $out/bin/hellos-server --prefix DYLD_LIBRARY_PATH : ${grpc}/lib
|
|
|
|
wrapProgram $out/bin/echo-client --prefix DYLD_LIBRARY_PATH : ${grpc}/lib
|
|
|
|
wrapProgram $out/bin/echo-server --prefix DYLD_LIBRARY_PATH : ${grpc}/lib
|
|
|
|
'';
|
|
|
|
|
2016-12-12 19:40:23 +01:00
|
|
|
shellHook =
|
|
|
|
pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
|
|
|
|
export DYLD_LIBRARY_PATH=${grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
|
|
|
|
'';
|
|
|
|
});
|
2016-08-01 19:02:23 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
allowUnfree = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
2016-12-12 19:40:23 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
linuxPkgs = import <nixpkgs> { inherit config; system = "x86_64-linux" ; };
|
|
|
|
darwinPkgs = import <nixpkgs> { inherit config; system = "x86_64-darwin"; };
|
|
|
|
pkgs = import <nixpkgs> { inherit config; };
|
|
|
|
|
|
|
|
in
|
|
|
|
{ grpc-haskell-linux = linuxPkgs.haskellPackages.grpc-haskell;
|
|
|
|
grpc-haskell-darwin = darwinPkgs.haskellPackages.grpc-haskell;
|
|
|
|
grpc-haskell = pkgs.haskellPackages.grpc-haskell;
|
|
|
|
grpc-linux = linuxPkgs.grpc;
|
|
|
|
grpc-darwin = darwinPkgs.grpc;
|
|
|
|
grpc = pkgs.grpc;
|
|
|
|
}
|