3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/bazel-watcher/default.nix

76 lines
2.4 KiB
Nix
Raw Normal View History

2018-09-11 06:36:11 +01:00
{ buildBazelPackage
, cacert
, fetchFromGitHub
, fetchpatch
, git
, go
2018-12-08 08:34:12 +00:00
, python
2018-09-11 06:36:11 +01:00
, stdenv
}:
buildBazelPackage rec {
name = "bazel-watcher-${version}";
2019-02-21 19:50:48 +00:00
version = "0.9.1";
2018-09-11 06:36:11 +01:00
src = fetchFromGitHub {
owner = "bazelbuild";
repo = "bazel-watcher";
rev = "v${version}";
2019-02-21 19:50:48 +00:00
sha256 = "1gjbv67ydyb0mafpp59qr9n8f8vva2mwhgan6lxxl0i9yfx7qc6p";
2018-09-11 06:36:11 +01:00
};
2018-12-08 08:34:12 +00:00
nativeBuildInputs = [ go git python ];
2018-09-11 06:36:11 +01:00
bazelTarget = "//ibazel";
fetchAttrs = {
preBuild = ''
patchShebangs .
# tell rules_go to use the Go binary found in the PATH
sed -e 's:go_register_toolchains():go_register_toolchains(go_version = "host"):g' -i WORKSPACE
'';
preInstall = ''
# Remove the go_sdk (it's just a copy of the go derivation) and all
# references to it from the marker files. Bazel does not need to download
# this sdk because we have patched the WORKSPACE file to point to the one
# currently present in PATH. Without removing the go_sdk from the marker
# file, the hash of it will change anytime the Go derivation changes and
# that would lead to impurities in the marker files which would result in
# a different sha256 for the fetch phase.
rm -rf $bazelOut/external/{go_sdk,\@go_sdk.marker}
sed -e '/^FILE:@go_sdk.*/d' -i $bazelOut/external/\@*.marker
2018-12-08 08:34:12 +00:00
# Remove the gazelle tools, they contain go binaries that are built
# non-deterministically. As long as the gazelle version matches the tools
# should be equivalent.
rm -rf $bazelOut/external/{bazel_gazelle_go_repository_tools,\@bazel_gazelle_go_repository_tools.marker}
sed -e '/^FILE:@bazel_gazelle_go_repository_tools.*/d' -i $bazelOut/external/\@*.marker
2018-09-11 06:36:11 +01:00
'';
2019-02-21 19:50:48 +00:00
sha256 = "0p6yarz4wlb6h33n4slkczkdkaa93zc9jx55h8wl9vv81ahp0md5";
2018-09-11 06:36:11 +01:00
};
buildAttrs = {
preBuild = ''
patchShebangs .
# tell rules_go to use the Go binary found in the PATH
sed -e 's:go_register_toolchains():go_register_toolchains(go_version = "host"):g' -i WORKSPACE
'';
installPhase = ''
install -Dm755 bazel-bin/ibazel/*_pure_stripped/ibazel $out/bin/ibazel
'';
};
meta = with stdenv.lib; {
homepage = https://github.com/bazelbuild/bazel-watcher;
description = "Tools for building Bazel targets when source files change.";
license = licenses.asl20;
maintainers = with maintainers; [ kalbasit ];
platforms = platforms.all;
};
}