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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
2.7 KiB
Nix
Raw Normal View History

2018-09-11 05:36:11 +00:00
{ buildBazelPackage
2022-07-05 15:54:40 +00:00
, bazel_5
2018-09-11 05:36:11 +00:00
, fetchFromGitHub
, git
, go
2021-03-25 09:36:54 +00:00
, python3
, lib, stdenv
2018-09-11 05:36:11 +00:00
}:
let
patches = [
./use-go-in-path.patch
];
in
2018-09-11 05:36:11 +00:00
buildBazelPackage rec {
2022-02-01 22:01:51 +00:00
pname = "bazel-watcher";
2022-07-05 15:54:40 +00:00
version = "0.16.2";
2018-09-11 05:36:11 +00:00
src = fetchFromGitHub {
owner = "bazelbuild";
repo = "bazel-watcher";
rev = "v${version}";
2022-07-05 15:54:40 +00:00
sha256 = "sha256-yRXta6pPhgIonTL0q9GSzNQg/jHMIeC7xvfVYrZMmnc=";
2018-09-11 05:36:11 +00:00
};
2021-03-25 09:36:54 +00:00
nativeBuildInputs = [ go git python3 ];
removeRulesCC = false;
2018-09-11 05:36:11 +00:00
2022-07-05 15:54:40 +00:00
bazel = bazel_5;
2018-09-11 05:36:11 +00:00
bazelTarget = "//ibazel";
fetchAttrs = {
inherit patches;
2018-09-11 05:36:11 +00:00
preBuild = ''
patchShebangs .
2022-07-05 15:54:40 +00:00
echo ${bazel_5.version} > .bazelversion
2018-09-11 05:36:11 +00:00
'';
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
# 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
'';
2022-07-05 15:54:40 +00:00
sha256 = "sha256-vij20VMBlKTBOACjH+XP4Z15BOmXYvlmErkVgjOln3M=";
2018-09-11 05:36:11 +00:00
};
buildAttrs = {
inherit patches;
2018-09-11 05:36:11 +00:00
preBuild = ''
patchShebangs .
substituteInPlace ibazel/BUILD --replace '{STABLE_GIT_VERSION}' ${version}
2022-07-05 15:54:40 +00:00
echo ${bazel_5.version} > .bazelversion
2018-09-11 05:36:11 +00:00
'';
installPhase = ''
2022-07-05 15:54:40 +00:00
install -Dm755 bazel-bin/ibazel/ibazel_/ibazel $out/bin/ibazel
2018-09-11 05:36:11 +00:00
'';
};
meta = with lib; {
homepage = "https://github.com/bazelbuild/bazel-watcher";
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
};
}