forked from
lass.pds.lassul.us/superconfig
This repository has no description
2.3 kB
87 lines
1{
2 stdenv,
3 gcc14Stdenv,
4 lib,
5 buildBazelPackage,
6 bazel_7,
7 fetchFromGitHub,
8 cctools,
9}:
10
11let
12 # fails to build with gcc15, see https://github.com/NixOS/nixpkgs/issues/475586
13 buildBazelPackage' =
14 if stdenv.cc.isGNU then
15 buildBazelPackage.override {
16 stdenv = gcc14Stdenv;
17 }
18 else
19 buildBazelPackage;
20
21 # Since 4.0.0 the project resolves its dependencies with bzlmod. Bazel needs
22 # the registry in the sandboxed build phase as well, so a checkout of the
23 # Bazel Central Registry is pinned.
24 registry = fetchFromGitHub {
25 owner = "bazelbuild";
26 repo = "bazel-central-registry";
27 rev = "0f256a72067e42d62bb568cc2619f98deed139e2";
28 hash = "sha256-OcMLg0KiAQOJZLH8r+QkeQ9bxcEc4L0dCgyUv5PkLQk=";
29 };
30in
31buildBazelPackage' rec {
32 pname = "protoc-gen-js";
33 version = "4.0.2";
34
35 src = fetchFromGitHub {
36 owner = "protocolbuffers";
37 repo = "protobuf-javascript";
38 rev = "v${version}";
39 hash = "sha256-vFTR7dwquZht4st90bFQ9CJMYBPbL+DWO0uQ3xsXIBU=";
40 };
41
42 bazel = bazel_7;
43 bazelFlags = [
44 "--registry"
45 "file://${registry}"
46 ];
47 bazelTargets = [ "generator:protoc-gen-js" ];
48 bazelBuildFlags = lib.optionals stdenv.cc.isClang [
49 "--cxxopt=-x"
50 "--cxxopt=c++"
51 "--host_cxxopt=-x"
52 "--host_cxxopt=c++"
53 ];
54 removeRulesCC = false;
55
56 env = lib.optionalAttrs stdenv.hostPlatform.isDarwin {
57 LIBTOOL = "${cctools}/bin/libtool";
58 };
59
60 fetchAttrs = {
61 # Repositories Bazel generates by inspecting the build host (store paths,
62 # host CPU) stay out of the deps tarball; the build phase regenerates them.
63 # With bzlmod their names carry the extension prefix (`~` on Bazel 7).
64 preInstall = ''
65 rm -rf "$bazelOut"/external/*[~+]{host_platform,local_config_*}
66 '';
67
68 hash = "sha256-bc+VwWhHzXIblFGYf8gfRTZvAiBY4L9L9texuJlxRYI=";
69 };
70
71 buildAttrs.installPhase = ''
72 mkdir -p $out/bin
73 install -Dm755 bazel-bin/generator/protoc-gen-js $out/bin/
74 '';
75
76 meta = {
77 description = "Protobuf plugin for generating JavaScript code";
78 mainProgram = "protoc-gen-js";
79 homepage = "https://github.com/protocolbuffers/protobuf-javascript";
80 platforms = lib.platforms.linux ++ lib.platforms.darwin;
81 license = with lib.licenses; [
82 asl20
83 bsd3
84 ];
85 sourceProvenance = [ lib.sourceTypes.fromSource ];
86 };
87}