12 ./use-go-in-path.patch
15 # Patch the protoc alias so that it always builds from source.
16 rulesProto = fetchFromGitHub {
20 hash = "sha256-WVPZx14thneAC4PdiDhBibnPwlCKEF9c93CHR0t1Efo=";
22 sed -i 's|name = "protoc"|name = "_protoc_original"|' $out/proto/private/BUILD.release
23 cat <<EOF >>$out/proto/private/BUILD.release
24 alias(name = "protoc", actual = "@com_github_protocolbuffers_protobuf//:protoc", visibility = ["//visibility:public"])
30 buildBazelPackage rec {
31 pname = "bazel-watcher";
34 src = fetchFromGitHub {
36 repo = "bazel-watcher";
38 hash = "sha256-ebNHAYKyE3226KiCc2/VSz1OSITuPwuYlAIS3JrWzj0=";
41 nativeBuildInputs = [ go git python3 ];
42 removeRulesCC = false;
45 bazelFlags = [ "--override_repository=rules_proto=${rulesProto}" ];
46 bazelBuildFlags = lib.optionals stdenv.cc.isClang [ "--cxxopt=-x" "--cxxopt=c++" "--host_cxxopt=-x" "--host_cxxopt=c++" ];
47 bazelTargets = [ "//cmd/ibazel" ];
49 fetchConfigured = false; # we want to fetch all dependencies, regardless of the current system
56 echo ${bazel_5.version} > .bazelversion
60 # Remove the go_sdk (it's just a copy of the go derivation) and all
61 # references to it from the marker files. Bazel does not need to download
62 # this sdk because we have patched the WORKSPACE file to point to the one
63 # currently present in PATH. Without removing the go_sdk from the marker
64 # file, the hash of it will change anytime the Go derivation changes and
65 # that would lead to impurities in the marker files which would result in
66 # a different hash for the fetch phase.
67 rm -rf $bazelOut/external/{go_sdk,\@go_sdk.marker}
68 sed -e '/^FILE:@go_sdk.*/d' -i $bazelOut/external/\@*.marker
70 # Retains go build input markers
71 chmod -R 755 $bazelOut/external/{bazel_gazelle_go_repository_cache,@\bazel_gazelle_go_repository_cache.marker}
72 rm -rf $bazelOut/external/{bazel_gazelle_go_repository_cache,@\bazel_gazelle_go_repository_cache.marker}
74 # Remove the gazelle tools, they contain go binaries that are built
75 # non-deterministically. As long as the gazelle version matches the tools
76 # should be equivalent.
77 rm -rf $bazelOut/external/{bazel_gazelle_go_repository_tools,\@bazel_gazelle_go_repository_tools.marker}
78 sed -e '/^FILE:@bazel_gazelle_go_repository_tools.*/d' -i $bazelOut/external/\@*.marker
80 # remove com_google_protobuf because it had files with different permissions on linux and darwin
81 rm -rf $bazelOut/external/com_google_protobuf
84 sha256 = "sha256-B2KVD/FmkAa7MNhLaH286gF3uA20qjN3CoA83KRB9E8=";
93 substituteInPlace cmd/ibazel/BUILD.bazel --replace '{STABLE_GIT_VERSION}' ${version}
94 echo ${bazel_5.version} > .bazelversion
98 install -Dm755 bazel-bin/cmd/ibazel/ibazel_/ibazel $out/bin/ibazel
103 homepage = "https://github.com/bazelbuild/bazel-watcher";
104 description = "Tools for building Bazel targets when source files change";
105 license = licenses.asl20;
106 maintainers = with maintainers; [ kalbasit ];
107 mainProgram = "ibazel";
108 platforms = platforms.all;