2018-09-11 05:36:11 +00:00
|
|
|
{ buildBazelPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, git
|
|
|
|
, go
|
2021-03-25 09:36:54 +00:00
|
|
|
, python3
|
2021-01-23 12:26:19 +00:00
|
|
|
, lib, stdenv
|
2018-09-11 05:36:11 +00:00
|
|
|
}:
|
|
|
|
|
2019-06-27 01:02:38 +00:00
|
|
|
let
|
2019-06-27 01:05:49 +00:00
|
|
|
patches = [
|
|
|
|
./use-go-in-path.patch
|
|
|
|
];
|
2019-06-27 01:02:38 +00:00
|
|
|
in
|
2018-09-11 05:36:11 +00:00
|
|
|
buildBazelPackage rec {
|
2022-02-01 22:01:51 +00:00
|
|
|
pname = "bazel-watcher";
|
2020-12-02 07:48:00 +00:00
|
|
|
version = "0.14.0";
|
2018-09-11 05:36:11 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "bazelbuild";
|
|
|
|
repo = "bazel-watcher";
|
|
|
|
rev = "v${version}";
|
2020-12-02 07:48:00 +00:00
|
|
|
sha256 = "0gigl1lg8sb4bj5crvj54329ws4yirldbncs15f96db6vhp0ig7r";
|
2018-09-11 05:36:11 +00:00
|
|
|
};
|
|
|
|
|
2021-03-25 09:36:54 +00:00
|
|
|
nativeBuildInputs = [ go git python3 ];
|
2020-04-29 00:16:20 +00:00
|
|
|
removeRulesCC = false;
|
2018-09-11 05:36:11 +00:00
|
|
|
|
|
|
|
bazelTarget = "//ibazel";
|
|
|
|
|
|
|
|
fetchAttrs = {
|
2019-06-27 01:02:38 +00:00
|
|
|
inherit patches;
|
|
|
|
|
2018-09-11 05:36:11 +00: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 08:34:12 +00:00
|
|
|
|
2020-04-29 00:16:20 +00: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 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 05:36:11 +00:00
|
|
|
'';
|
|
|
|
|
2021-06-07 01:54:29 +00:00
|
|
|
sha256 = "1j175z3d4fbi4pl35py7yjq7ywrvwin6id131jv32hx0ck4g1m46";
|
2018-09-11 05:36:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildAttrs = {
|
2019-06-27 01:02:38 +00:00
|
|
|
inherit patches;
|
|
|
|
|
2018-09-11 05:36:11 +00:00
|
|
|
preBuild = ''
|
|
|
|
patchShebangs .
|
2020-12-02 08:33:14 +00:00
|
|
|
|
|
|
|
substituteInPlace ibazel/BUILD --replace '{STABLE_GIT_VERSION}' ${version}
|
2018-09-11 05:36:11 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm755 bazel-bin/ibazel/*_pure_stripped/ibazel $out/bin/ibazel
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-01-23 12:26:19 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://github.com/bazelbuild/bazel-watcher";
|
2020-10-11 05:55:05 +00:00
|
|
|
description = "Tools for building Bazel targets when source files change";
|
2018-09-11 05:36:11 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ kalbasit ];
|
|
|
|
platforms = platforms.all;
|
2020-12-07 11:33:22 +00:00
|
|
|
# broken on darwin, see https://github.com/NixOS/nixpkgs/issues/105573
|
|
|
|
broken = stdenv.isDarwin;
|
2018-09-11 05:36:11 +00:00
|
|
|
};
|
|
|
|
}
|