Add new test-derivation target to release.nix (#108)

This comes in handy for `nix-shell` when you want to test
against an already built `grpc-haskell`
This commit is contained in:
Gabriel Gonzalez 2020-09-04 11:02:41 -07:00 committed by GitHub
parent d532cec4d1
commit d7c3c3847a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,18 +60,22 @@
# $ cabal2nix path/to/dependency/repo > nix/${package-name}.nix # $ cabal2nix path/to/dependency/repo > nix/${package-name}.nix
let let
nixpkgs = import ./nixpkgs.nix; nixpkgs = import ./nixpkgs.nix;
config = { config = {
packageOverrides = pkgs: rec { allowUnfree = true;
};
overlay = pkgsNew: pkgsOld: {
protobuf3_2NoCheck = protobuf3_2NoCheck =
pkgs.stdenv.lib.overrideDerivation pkgsNew.stdenv.lib.overrideDerivation
pkgs.pythonPackages.protobuf pkgsNew.pythonPackages.protobuf
(oldAttrs : {doCheck = false; doInstallCheck = false;}); (oldAttrs : {doCheck = false; doInstallCheck = false;});
cython = pkgs.pythonPackages.buildPythonPackage rec { cython = pkgsNew.pythonPackages.buildPythonPackage rec {
name = "Cython-${version}"; name = "Cython-${version}";
version = "0.24.1"; version = "0.24.1";
src = pkgs.fetchurl { src = pkgsNew.fetchurl {
url = "mirror://pypi/C/Cython/${name}.tar.gz"; url = "mirror://pypi/C/Cython/${name}.tar.gz";
sha256 = "84808fda00508757928e1feadcf41c9f78e9a9b7167b6649ab0933b76f75e7b9"; sha256 = "84808fda00508757928e1feadcf41c9f78e9a9b7167b6649ab0933b76f75e7b9";
}; };
@ -80,12 +84,12 @@ let
# This was fixed in `nixpkgs-unstable` so we can get rid of this workaround # This was fixed in `nixpkgs-unstable` so we can get rid of this workaround
# when that fix is stabilized # when that fix is stabilized
NIX_CFLAGS_COMPILE = NIX_CFLAGS_COMPILE =
pkgs.stdenv.lib.optionalString (pkgs.stdenv.cc.isClang or false) pkgsNew.stdenv.lib.optionalString (pkgsNew.stdenv.cc.isClang or false)
"-I${pkgs.libcxx}/include/c++/v1"; "-I${pkgsNew.libcxx}/include/c++/v1";
buildInputs = buildInputs =
pkgs.stdenv.lib.optional (pkgs.stdenv.cc.isClang or false) pkgs.libcxx pkgsNew.stdenv.lib.optional (pkgsNew.stdenv.cc.isClang or false) pkgsNew.libcxx
++ [ pkgs.pkgconfig pkgs.gdb ]; ++ [ pkgsNew.pkgconfig pkgsNew.gdb ];
doCheck = false; doCheck = false;
@ -95,21 +99,21 @@ let
meta = { meta = {
description = "An optimising static compiler for both the Python programming language and the extended Cython programming language"; description = "An optimising static compiler for both the Python programming language and the extended Cython programming language";
platforms = pkgs.stdenv.lib.platforms.all; platforms = pkgsNew.stdenv.lib.platforms.all;
homepage = http://cython.org; homepage = http://cython.org;
license = pkgs.stdenv.lib.licenses.asl20; license = pkgsNew.stdenv.lib.licenses.asl20;
maintainers = with pkgs.stdenv.lib.maintainers; [ fridh ]; maintainers = with pkgsNew.stdenv.lib.maintainers; [ fridh ];
}; };
}; };
grpc = pkgs.callPackage ./nix/grpc.nix { }; grpc = pkgsNew.callPackage ./nix/grpc.nix { };
grpcio = pkgs.pythonPackages.buildPythonPackage rec { grpcio = pkgsNew.pythonPackages.buildPythonPackage rec {
name = "grpc-${version}"; name = "grpc-${version}";
version = "1.0"; version = "1.0";
src = pkgs.fetchgit { src = pkgsNew.fetchgit {
url = "https://github.com/grpc/grpc.git"; url = "https://github.com/grpc/grpc.git";
rev = "e2cfe9df79c4eda4e376222df064c4c65e616352"; rev = "e2cfe9df79c4eda4e376222df064c4c65e616352";
sha256 = "19ldbjlnbc287hkaylsigm8w9fai2bjdbfxk6315kl75cq54iprr"; sha256 = "19ldbjlnbc287hkaylsigm8w9fai2bjdbfxk6315kl75cq54iprr";
@ -123,26 +127,26 @@ let
# This was fixed in `nixpkgs-unstable` so we can get rid of this workaround # This was fixed in `nixpkgs-unstable` so we can get rid of this workaround
# when that fix is stabilized # when that fix is stabilized
NIX_CFLAGS_COMPILE = NIX_CFLAGS_COMPILE =
pkgs.stdenv.lib.optionalString (pkgs.stdenv.cc.isClang or false) pkgsNew.stdenv.lib.optionalString (pkgsNew.stdenv.cc.isClang or false)
"-I${pkgs.libcxx}/include/c++/v1"; "-I${pkgsNew.libcxx}/include/c++/v1";
buildInputs = buildInputs =
pkgs.stdenv.lib.optional (pkgs.stdenv.cc.isClang or false) pkgs.libcxx; pkgsNew.stdenv.lib.optional (pkgsNew.stdenv.cc.isClang or false) pkgsNew.libcxx;
propagatedBuildInputs = [ propagatedBuildInputs = [
cython pkgsNew.cython
pkgs.pythonPackages.futures pkgsNew.pythonPackages.futures
protobuf3_2NoCheck pkgsNew.protobuf3_2NoCheck
pkgs.pythonPackages.enum34 pkgsNew.pythonPackages.enum34
]; ];
}; };
grpcio-tools = pkgs.pythonPackages.buildPythonPackage rec { grpcio-tools = pkgsNew.pythonPackages.buildPythonPackage rec {
name = "grpc-${version}"; name = "grpc-${version}";
version = "1.0"; version = "1.0";
src = pkgs.fetchgit { src = pkgsNew.fetchgit {
url = "https://github.com/grpc/grpc.git"; url = "https://github.com/grpc/grpc.git";
rev = "e2cfe9df79c4eda4e376222df064c4c65e616352"; rev = "e2cfe9df79c4eda4e376222df064c4c65e616352";
sha256 = "19ldbjlnbc287hkaylsigm8w9fai2bjdbfxk6315kl75cq54iprr"; sha256 = "19ldbjlnbc287hkaylsigm8w9fai2bjdbfxk6315kl75cq54iprr";
@ -158,67 +162,67 @@ let
# This was fixed in `nixpkgs-unstable` so we can get rid of this workaround # This was fixed in `nixpkgs-unstable` so we can get rid of this workaround
# when that fix is stabilized # when that fix is stabilized
NIX_CFLAGS_COMPILE = NIX_CFLAGS_COMPILE =
pkgs.stdenv.lib.optionalString (pkgs.stdenv.cc.isClang or false) pkgsNew.stdenv.lib.optionalString (pkgsNew.stdenv.cc.isClang or false)
"-I${pkgs.libcxx}/include/c++/v1"; "-I${pkgsNew.libcxx}/include/c++/v1";
buildInputs = buildInputs =
pkgs.stdenv.lib.optional (pkgs.stdenv.cc.isClang or false) pkgs.libcxx; pkgsNew.stdenv.lib.optional (pkgsNew.stdenv.cc.isClang or false) pkgsNew.libcxx;
propagatedBuildInputs = [ propagatedBuildInputs = [
cython pkgsNew.cython
pkgs.pythonPackages.futures pkgsNew.pythonPackages.futures
protobuf3_2NoCheck pkgsNew.protobuf3_2NoCheck
pkgs.pythonPackages.enum34 pkgsNew.pythonPackages.enum34
grpcio pkgsNew.grpcio
]; ];
}; };
usesGRPC = haskellPackage: usesGRPC = haskellPackage:
pkgs.haskell.lib.overrideCabal haskellPackage (oldAttributes: { pkgsNew.haskell.lib.overrideCabal haskellPackage (oldAttributes: {
preBuild = (oldAttributes.preBuild or "") + preBuild = (oldAttributes.preBuild or "") +
pkgs.lib.optionalString pkgs.stdenv.isDarwin '' pkgsNew.lib.optionalString pkgsNew.stdenv.isDarwin ''
export DYLD_LIBRARY_PATH=${grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH export DYLD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
'' + '' +
pkgs.lib.optionalString pkgs.stdenv.isLinux '' pkgsNew.lib.optionalString pkgsNew.stdenv.isLinux ''
export LD_LIBRARY_PATH=${grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
''; '';
shellHook = (oldAttributes.shellHook or "") + shellHook = (oldAttributes.shellHook or "") +
pkgs.lib.optionalString pkgs.stdenv.isDarwin '' pkgsNew.lib.optionalString pkgsNew.stdenv.isDarwin ''
export DYLD_LIBRARY_PATH=${grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH export DYLD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH
'' + '' +
pkgs.lib.optionalString pkgs.stdenv.isLinux '' pkgsNew.lib.optionalString pkgsNew.stdenv.isLinux ''
export LD_LIBRARY_PATH=${grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${pkgsNew.grpc}/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
''; '';
} }
); );
haskellPackages = pkgs.haskellPackages.override { haskellPackages = pkgsOld.haskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld: rec { overrides = haskellPackagesNew: haskellPackagesOld: rec {
proto3-wire = proto3-wire =
haskellPackagesNew.callPackage ./nix/proto3-wire.nix { }; haskellPackagesNew.callPackage ./nix/proto3-wire.nix { };
proto3-suite = proto3-suite =
pkgs.haskell.lib.dontCheck pkgsNew.haskell.lib.dontCheck
(haskellPackagesNew.callPackage ./nix/proto3-suite.nix {}); (haskellPackagesNew.callPackage ./nix/proto3-suite.nix {});
grpc-haskell-core = grpc-haskell-core =
pkgs.haskell.lib.buildFromSdist (usesGRPC pkgsNew.haskell.lib.buildFromSdist (pkgsNew.usesGRPC
(pkgs.haskell.lib.overrideCabal (pkgsNew.haskell.lib.overrideCabal
(haskellPackagesNew.callPackage ./core { }) (haskellPackagesNew.callPackage ./core { })
(_: { buildDepends = [ haskellPackagesNew.c2hs ]; }))); (_: { buildDepends = [ haskellPackagesNew.c2hs ]; })));
grpc-haskell-no-tests = grpc-haskell-no-tests =
pkgs.haskell.lib.buildFromSdist (usesGRPC pkgsNew.haskell.lib.buildFromSdist (pkgsNew.usesGRPC
(pkgs.haskell.lib.dontCheck (pkgsNew.haskell.lib.dontCheck
(haskellPackagesNew.callPackage ./default.nix { }) (haskellPackagesNew.callPackage ./default.nix { })
)); ));
grpc-haskell = grpc-haskell =
usesGRPC pkgsNew.usesGRPC
(pkgs.haskell.lib.overrideCabal (pkgsNew.haskell.lib.overrideCabal
(pkgs.haskell.lib.buildFromSdist ((haskellPackagesNew.callPackage ./default.nix { }))) (pkgsNew.haskell.lib.buildFromSdist ((haskellPackagesNew.callPackage ./default.nix { })))
(oldDerivation: (oldDerivation:
let let
ghc = ghc =
@ -230,9 +234,9 @@ let
pkgs.turtle pkgs.turtle
]); ]);
python = pkgs.python.withPackages (pkgs: [ python = pkgsNew.python.withPackages (pkgs: [
# pkgs.protobuf3_0 # pkgs.protobuf3_0
grpcio-tools pkgsNew.grpcio-tools
]); ]);
in rec { in rec {
@ -241,7 +245,7 @@ let
]; ];
buildDepends = [ buildDepends = [
pkgs.makeWrapper pkgsNew.makeWrapper
# Give our nix-shell its own cabal so we don't pick up one # Give our nix-shell its own cabal so we don't pick up one
# from the user's environment by accident. # from the user's environment by accident.
haskellPackagesNew.cabal-install haskellPackagesNew.cabal-install
@ -255,11 +259,11 @@ let
postPatch = '' postPatch = ''
patchShebangs tests patchShebangs tests
substituteInPlace tests/simple-client.sh \ substituteInPlace tests/simple-client.sh \
--replace @makeWrapper@ ${pkgs.makeWrapper} \ --replace @makeWrapper@ ${pkgsNew.makeWrapper} \
--replace @grpc@ ${grpc} --replace @grpc@ ${pkgsNew.grpc}
substituteInPlace tests/simple-server.sh \ substituteInPlace tests/simple-server.sh \
--replace @makeWrapper@ ${pkgs.makeWrapper} \ --replace @makeWrapper@ ${pkgsNew.makeWrapper} \
--replace @grpc@ ${grpc} --replace @grpc@ ${pkgsNew.grpc}
wrapProgram tests/protoc.sh \ wrapProgram tests/protoc.sh \
--prefix PATH : ${python}/bin --prefix PATH : ${python}/bin
wrapProgram tests/test-client.sh \ wrapProgram tests/test-client.sh \
@ -281,17 +285,27 @@ let
}; };
}; };
test-grpc-haskell =
pkgsNew.mkShell {
nativeBuildInputs = [
(pkgsNew.haskellPackages.ghcWithPackages (pkgs: [
pkgs.grpc-haskell
]
)
)
];
};
}; };
allowUnfree = true; overlays = [ overlay ];
};
in in
let let
linuxPkgs = import nixpkgs { inherit config; system = "x86_64-linux" ; }; linuxPkgs = import nixpkgs { inherit config overlays; system = "x86_64-linux" ; };
darwinPkgs = import nixpkgs { inherit config; system = "x86_64-darwin"; }; darwinPkgs = import nixpkgs { inherit config overlays; system = "x86_64-darwin"; };
pkgs = import nixpkgs { inherit config; }; pkgs = import nixpkgs { inherit config overlays; };
in in
{ {
@ -308,4 +322,6 @@ in
grpc-darwin = darwinPkgs.grpc; grpc-darwin = darwinPkgs.grpc;
grpc = pkgs.grpc; grpc = pkgs.grpc;
inherit (pkgs) test-grpc-haskell;
} }