bazel-watcher: 0.25.2 -> 0.25.3

This commit is contained in:
Malte Poll 2024-09-29 12:49:56 +02:00 committed by Paul Meyer
parent 2c7cfbb88c
commit 4955487fc1
2 changed files with 18 additions and 99 deletions

View File

@ -1,102 +1,34 @@
{ buildBazelPackage
, bazel_5
, fetchFromGitHub
, git
, go_1_21
, python3
, lib, stdenv
{
lib,
fetchFromGitHub,
buildGoModule,
testers,
bazel-watcher,
}:
let
patches = [
./use-go-in-path.patch
];
# Patch the protoc alias so that it always builds from source.
rulesProto = fetchFromGitHub {
owner = "bazelbuild";
repo = "rules_proto";
rev = "4.0.0";
hash = "sha256-WVPZx14thneAC4PdiDhBibnPwlCKEF9c93CHR0t1Efo=";
postFetch = ''
sed -i 's|name = "protoc"|name = "_protoc_original"|' $out/proto/private/BUILD.release
cat <<EOF >>$out/proto/private/BUILD.release
alias(name = "protoc", actual = "@com_github_protocolbuffers_protobuf//:protoc", visibility = ["//visibility:public"])
EOF
'';
};
in
buildBazelPackage rec {
buildGoModule rec {
pname = "bazel-watcher";
version = "0.25.2";
version = "0.25.3";
src = fetchFromGitHub {
owner = "bazelbuild";
repo = "bazel-watcher";
rev = "v${version}";
hash = "sha256-lreGKA0DZiOd1bJq8NNQ+80cyDwiughoXCkKu1RaZmc=";
hash = "sha256-5cRj04e5VVG4NSe4LOLkZIrerT4laLEDeXCqTiJj6MM=";
};
nativeBuildInputs = [ go_1_21 git python3 ];
removeRulesCC = false;
vendorHash = "sha256-0I/bvuyosN55oNSMuom4C8rVjxneUaqV19l9OMiwWhU=";
bazel = bazel_5;
bazelFlags = [ "--override_repository=rules_proto=${rulesProto}" ];
bazelBuildFlags = lib.optionals stdenv.cc.isClang [ "--cxxopt=-x" "--cxxopt=c++" "--host_cxxopt=-x" "--host_cxxopt=c++" ];
bazelTargets = [ "//cmd/ibazel" ];
CGO_ENABLED = "0";
ldflags = [
"-s"
"-X main.Version=${version}"
];
fetchConfigured = false; # we want to fetch all dependencies, regardless of the current system
fetchAttrs = {
inherit patches;
subPackages = [ "cmd/ibazel" ];
preBuild = ''
patchShebangs .
echo ${bazel_5.version} > .bazelversion
'';
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 hash for the fetch phase.
rm -rf $bazelOut/external/{go_sdk,\@go_sdk.marker}
sed -e '/^FILE:@go_sdk.*/d' -i $bazelOut/external/\@*.marker
# 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}
# 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
# remove com_google_protobuf because it had files with different permissions on linux and darwin
rm -rf $bazelOut/external/com_google_protobuf
'';
sha256 = "sha256-B2KVD/FmkAa7MNhLaH286gF3uA20qjN3CoA83KRB9E8=";
};
buildAttrs = {
inherit patches;
preBuild = ''
patchShebangs .
substituteInPlace cmd/ibazel/BUILD.bazel --replace '{STABLE_GIT_VERSION}' ${version}
echo ${bazel_5.version} > .bazelversion
'';
installPhase = ''
install -Dm755 bazel-bin/cmd/ibazel/ibazel_/ibazel $out/bin/ibazel
'';
passthru = {
tests.version = testers.testVersion { package = bazel-watcher; };
};
meta = with lib; {

View File

@ -1,13 +0,0 @@
diff --git a/WORKSPACE b/WORKSPACE
index 51273b6..fcf9ffb 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -61,7 +61,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe
go_rules_dependencies()
-go_register_toolchains(version = "1.19.4")
+go_register_toolchains(go_version = "host")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")