git.iko.soy/rowtype-yoga/purescript-protobuf
on master help sign in
libprotoc 23.2, purs 0.15.8, node v18.16.0
commit5c26b1034dfb889ce82c0fe86550235052a9c74c authorJames Brock <jamesbrock@gmail.com> dateMon 5 Jun 2023, 00:46 (3 years ago) parent97efb92
4 files changed+133−33
README.md+5−5 flake.lock+71−18 flake.nix+8−10 nix/protobuf.nix+49
README.md+5−5
@@ -31,7 +31,7 @@ We do not support
3131
3232In this version, we pass all 651 of the
3333[Google conformance tests](https://github.com/protocolbuffers/protobuf/tree/main/conformance)
34−of binary-wire-format *proto3* for [Protocol Buffers v21.10](https://github.com/protocolbuffers/protobuf/releases/tag/v21.10).
34+of binary-wire-format *proto3* for [Protocol Buffers v23.2](https://github.com/protocolbuffers/protobuf/releases/).
3535See the `conformance/README.md` in this repository for details.
3636
3737We also have our own unit tests, see `test/README.md` in this repository.
@@ -48,10 +48,10 @@ The `nix develop` environment provides
4848```
4949$ nix develop
5050
51−PureScript Protobuf development environment.
52−libprotoc 3.21.10
53−purs 0.15.6
54−node v17.1.0
51+PureScript Protobuf development environment
52+libprotoc 23.2
53+purs 0.15.8
54+node v18.16.0
5555
5656To build the protoc compiler plugin, run:
5757
flake.lock+71−18
@@ -1,13 +1,15 @@
11{
22 "nodes": {
33 "easy-purescript-nix": {
4− "flake": false,
4+ "inputs": {
5+ "flake-utils": "flake-utils"
6+ },
57 "locked": {
6− "lastModified": 1671011575,
7− "narHash": "sha256-tESal32bcqqdZO+aKnBzc1GoL2mtnaDtj2y7ociCRGA=",
8+ "lastModified": 1685892271,
9+ "narHash": "sha256-VgBowaSVbO9Uhw7lm//FiOvXXM4CT2Dfpth3pDqtaV8=",
810 "owner": "justinwoo",
911 "repo": "easy-purescript-nix",
10− "rev": "11d3bd58ce6e32703bf69cec04dc7c38eabe14ba",
12+ "rev": "27e01251c981215afb3c04989ca9a6b0b8378c8b",
1113 "type": "github"
1214 },
1315 "original": {
@@ -33,12 +35,15 @@
3335 }
3436 },
3537 "flake-utils": {
38+ "inputs": {
39+ "systems": "systems"
40+ },
3641 "locked": {
37− "lastModified": 1667395993,
38− "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
42+ "lastModified": 1685518550,
43+ "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
3944 "owner": "numtide",
4045 "repo": "flake-utils",
41− "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
46+ "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
4247 "type": "github"
4348 },
4449 "original": {
@@ -48,6 +53,24 @@
4853 }
4954 },
5055 "flake-utils_2": {
56+ "inputs": {
57+ "systems": "systems_2"
58+ },
59+ "locked": {
60+ "lastModified": 1685518550,
61+ "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
62+ "owner": "numtide",
63+ "repo": "flake-utils",
64+ "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
65+ "type": "github"
66+ },
67+ "original": {
68+ "owner": "numtide",
69+ "repo": "flake-utils",
70+ "type": "github"
71+ }
72+ },
73+ "flake-utils_3": {
5174 "locked": {
5275 "lastModified": 1667395993,
5376 "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
@@ -64,16 +87,16 @@
6487 },
6588 "nixpkgs": {
6689 "locked": {
67− "lastModified": 1673796341,
68− "narHash": "sha256-1kZi9OkukpNmOaPY7S5/+SlCDOuYnP3HkXHvNDyLQcc=",
90+ "lastModified": 1685801374,
91+ "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
6992 "owner": "NixOS",
7093 "repo": "nixpkgs",
71− "rev": "6dccdc458512abce8d19f74195bb20fdb067df50",
94+ "rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
7295 "type": "github"
7396 },
7497 "original": {
7598 "owner": "NixOS",
76− "ref": "nixos-unstable",
99+ "ref": "nixos-23.05",
77100 "repo": "nixpkgs",
78101 "type": "github"
79102 }
@@ -97,7 +120,7 @@
97120 "root": {
98121 "inputs": {
99122 "easy-purescript-nix": "easy-purescript-nix",
100− "flake-utils": "flake-utils",
123+ "flake-utils": "flake-utils_2",
101124 "nixpkgs": "nixpkgs",
102125 "spago2nix": "spago2nix"
103126 }
@@ -105,22 +128,52 @@
105128 "spago2nix": {
106129 "inputs": {
107130 "easy-purescript-nix": "easy-purescript-nix_2",
108− "flake-utils": "flake-utils_2",
131+ "flake-utils": "flake-utils_3",
109132 "nixpkgs": "nixpkgs_2"
110133 },
111134 "locked": {
112− "lastModified": 1670976475,
113− "narHash": "sha256-wNG71nooTCrwRPkKIITzvRnga2UHq3Kq+bOZpx+QWZ4=",
114− "owner": "jamesdbrock",
135+ "lastModified": 1671225584,
136+ "narHash": "sha256-h9r67pmvDuA3TV9299L4CN60XSm8RRtX1EwUoKu9Pyw=",
137+ "owner": "justinwoo",
115138 "repo": "spago2nix",
116− "rev": "780780be5c369c521559f55b2bffcca101ad70d8",
139+ "rev": "1b8ec352bc7eac077b934d6b9f6efa0129926e59",
117140 "type": "github"
118141 },
119142 "original": {
120− "owner": "jamesdbrock",
143+ "owner": "justinwoo",
121144 "repo": "spago2nix",
122145 "type": "github"
123146 }
147+ },
148+ "systems": {
149+ "locked": {
150+ "lastModified": 1681028828,
151+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
152+ "owner": "nix-systems",
153+ "repo": "default",
154+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
155+ "type": "github"
156+ },
157+ "original": {
158+ "owner": "nix-systems",
159+ "repo": "default",
160+ "type": "github"
161+ }
162+ },
163+ "systems_2": {
164+ "locked": {
165+ "lastModified": 1681028828,
166+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
167+ "owner": "nix-systems",
168+ "repo": "default",
169+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
170+ "type": "github"
171+ },
172+ "original": {
173+ "owner": "nix-systems",
174+ "repo": "default",
175+ "type": "github"
176+ }
124177 }
125178 },
126179 "root": "root",
flake.nix+8−10
@@ -5,20 +5,15 @@
55 nixConfig.sandbox = "relaxed";
66
77 inputs = {
8−
9− nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
8+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
109 flake-utils.url = "github:numtide/flake-utils";
1110 easy-purescript-nix = {
1211 url = "github:justinwoo/easy-purescript-nix";
13− flake = false;
12+ # inputs.nixpkgs.follow = "nixpkgs";
1413 };
1514 spago2nix = {
16− url = "github:jamesdbrock/spago2nix";
15+ url = "github:justinwoo/spago2nix";
1716 };
18− # flake-compat = {
19− # url = "github:edolstra/flake-compat";
20− # flake = false;
21− # };
2217 };
2318
2419 outputs = { self, ... }@inputs:
@@ -27,9 +22,10 @@
2722
2823 nixpkgs = inputs.nixpkgs.legacyPackages.${system};
2924 easy-purescript-nix = import inputs.easy-purescript-nix {pkgs = nixpkgs;};
30− protobuf = (import ./nix/protobuf.nix {pkgs = nixpkgs;}).protobuf_v21_10;
25+ protobufs = (import ./nix/protobuf.nix {pkgs = nixpkgs;});
26+ protobuf = protobufs.protobuf_v23_2;
3127
32− purs = easy-purescript-nix.purs-0_15_7;
28+ purs = easy-purescript-nix.purs-0_15_8;
3329 nodejs = nixpkgs.nodejs-18_x;
3430
3531 protoc-gen-purescript = nixpkgs.stdenv.mkDerivation {
@@ -145,6 +141,8 @@
145141 inherit protoc-gen-purescript;
146142 inherit protobuf;
147143 inherit conformance-purescript;
144+ inherit (protobufs) protobuf_v21_10;
145+ inherit (protobufs) protobuf_v23_2;
148146 };
149147 apps = {
150148 conformance =
nix/protobuf.nix+49
@@ -64,6 +64,16 @@ let
6464 ref = "refs/tags/${ref}";
6565 };
6666 };
67+ protobuf_repo_v23_2 = rec {
68+ ref = "v23.2";
69+ src = pkgs.fetchFromGitHub {
70+ owner = "protocolbuffers";
71+ repo = "protobuf";
72+ rev = "v23.2";
73+ hash = "sha256-kYiT7MIhKH28YwZqaIj0ri/fJ5sOaUA4z9jM64o2iqg=";
74+ fetchSubmodules = true;
75+ };
76+ };
6777
6878 # Builds `protoc`, plus the conformance test runners, and also copies
6979 # in the .proto files for the conformance test protocol,
@@ -113,6 +123,43 @@ let
113123 };
114124 };
115125
126+ cmakeProtobuf = repo: pkgs.stdenv.mkDerivation {
127+ name = "protobuf-${repo.ref}";
128+ nativeBuildInputs = with pkgs; [ cmake rsync ];
129+ src = repo.src;
130+ # https://github.com/protocolbuffers/protobuf/blob/main/src/README.md#c-installation---unix
131+ cmakeFlags = [ "-Dprotobuf_BUILD_CONFORMANCE=ON" ];
132+ postInstall =
133+ let
134+ conformance_rpath = pkgs.lib.makeLibraryPath [
135+ pkgs.stdenv.cc.cc.lib
136+ ];
137+ in
138+ ''
139+ # Recursive copy all the .proto files
140+ rsync -am --include='*.proto' --include='*/' --exclude='*' $src/src $out/
141+ mkdir -p $out/conformance
142+ cp $src/conformance/conformance.proto $out/conformance/
143+
144+ # Conformance test runner
145+ cp ./conformance_test_runner $out/bin/conformance_test_runner
146+ # https://nixos.wiki/wiki/Packaging/Binaries#Creating_the_Derivation_for_upstream_Packaging
147+ patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath "$out/lib:${conformance_rpath}" $out/bin/conformance_test_runner
148+ ln -s $out/bin/conformance_test_runner $out/bin/conformance-test-runner
149+ '';
150+ meta = {
151+ description = "Google’s Protobuf built for purescript-protobuf";
152+ longDescription = ''
153+ This Protobuf build includes the protoc compiler and the “well-known”
154+ .proto definitions, as well as all of the conformance test runners
155+ and conformance .proto definitions.
156+ '';
157+ homepage = "https://github.com/xc-jp/purescript-protobuf";
158+ license = pkgs.lib.licenses.bsd3;
159+ mainProgram = "protoc";
160+ };
161+ };
162+
116163in
117164{
118165 inherit protobuf_repo_v3_9_2;
@@ -121,12 +168,14 @@ in
121168 inherit protobuf_repo_v3_20_1;
122169 inherit protobuf_repo_v3_21_0;
123170 inherit protobuf_repo_v21_10;
171+ inherit protobuf_repo_v23_2;
124172 protobuf_v3_9_2 = mkProtobuf protobuf_repo_v3_9_2;
125173 protobuf_v3_14_0 = mkProtobuf protobuf_repo_v3_14_0;
126174 protobuf_v3_15_8 = mkProtobuf protobuf_repo_v3_15_8;
127175 protobuf_v3_20_1 = mkProtobuf protobuf_repo_v3_20_1;
128176 protobuf_v3_21_0 = mkProtobuf protobuf_repo_v3_21_0;
129177 protobuf_v21_10 = mkProtobuf protobuf_repo_v21_10;
178+ protobuf_v23_2 = cmakeProtobuf protobuf_repo_v23_2;
130179}
131180
132181