nixpkgs/pkgs/development/tools/bazel-watcher/default.nix

82 lines
2.4 KiB
Nix
Raw Normal View History

2018-09-11 07:36:11 +02:00
{ buildBazelPackage
, fetchFromGitHub
, git
, go
2018-12-08 09:34:12 +01:00
, python
2018-09-11 07:36:11 +02:00
, stdenv
}:
let
patches = [
./use-go-in-path.patch
];
in
2018-09-11 07:36:11 +02:00
buildBazelPackage rec {
name = "bazel-watcher-${version}";
2020-05-20 07:00:00 +02:00
version = "0.13.1";
2018-09-11 07:36:11 +02:00
src = fetchFromGitHub {
owner = "bazelbuild";
repo = "bazel-watcher";
rev = "v${version}";
2020-05-20 07:00:00 +02:00
sha256 = "0n28q27510ymg5d455hrbk7z8wawszgjmqjjhb4zximqhvxks7kh";
2018-09-11 07:36:11 +02:00
};
2018-12-08 09:34:12 +01:00
nativeBuildInputs = [ go git python ];
removeRulesCC = false;
2018-09-11 07:36:11 +02:00
bazelTarget = "//ibazel";
fetchAttrs = {
inherit patches;
2018-09-11 07:36:11 +02:00
preBuild = ''
patchShebangs .
'';
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 09:34:12 +01:00
# Retains go build input markers
chmod -R 755 $bazelOut/external/{bazel_gazelle_go_repository_cache,@\bazel_gazelle_go_repository_cache.marker}
rm -rf $bazelOut/external/{bazel_gazelle_go_repository_cache,@\bazel_gazelle_go_repository_cache.marker}
2018-12-08 09:34:12 +01: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 07:36:11 +02:00
'';
2020-05-20 07:00:00 +02:00
sha256 = "16zgjd6zww9skk34ggfx5l3kbsdyv98zxawrvmx1arv5gaj63pp9";
2018-09-11 07:36:11 +02:00
};
buildAttrs = {
inherit patches;
2018-09-11 07:36:11 +02:00
preBuild = ''
patchShebangs .
'';
installPhase = ''
install -Dm755 bazel-bin/ibazel/*_pure_stripped/ibazel $out/bin/ibazel
'';
};
meta = with stdenv.lib; {
homepage = "https://github.com/bazelbuild/bazel-watcher";
2018-09-11 07:36:11 +02:00
description = "Tools for building Bazel targets when source files change.";
license = licenses.asl20;
maintainers = with maintainers; [ kalbasit ];
platforms = platforms.all;
};
}