@@ -3,6 +3,9 @@
33, writeShellScript, runCommand, which
44, rustPlatform, jq, nix-prefetch-git, xe, curl, emscripten
55, callPackage
6+, enableShared ? true
7+, enableStatic ? false
8+, Security
69}:
710
811# TODO: move to carnix or https://github.com/kolloch/crate2nix
@@ -11,9 +14,9 @@ let
1114 # 1) change all these hashes
1215 # 2) nix-build -A tree-sitter.updater.update-all-grammars
1316 # 3) run the ./result script that is output by that (it updates ./grammars)
14− version = "0.17.1";
15− sha256 = "sha256-k61actAEyao/Ea8aw9PCm252U+1I0d43MAYC68/lui4=";
16− cargoSha256 = "sha256-Jp/Fl20ZZfaIdWinOOujNVH5JjJNtyUYHfyTrmeeoRg=";
17+ version = "0.17.3";
18+ sha256 = "sha256-uQs80r9cPX8Q46irJYv2FfvuppwonSS5HVClFujaP+U=";
19+ cargoSha256 = "sha256-fonlxLNh9KyEwCj7G5vxa7cM/DlcHNFbQpp0SwVQ3j4=";
1720
1821 src = fetchFromGitHub {
1922 owner = "tree-sitter";
@@ -49,6 +52,8 @@ in rustPlatform.buildRustPackage {
4952 pname = "tree-sitter";
5053 inherit src version cargoSha256;
5154
55+ buildInputs = lib.optionals stdenv.isDarwin [ Security ];
56+
5257 nativeBuildInputs = [ emscripten which ];
5358
5459 postPatch = ''
@@ -68,6 +73,12 @@ in rustPlatform.buildRustPackage {
6873 bash ./script/build-wasm --debug
6974 '';
7075
76+ postInstall = ''
77+ PREFIX=$out make install
78+ ${lib.optionalString (!enableShared) "rm $out/lib/*.so{,.*}"}
79+ ${lib.optionalString (!enableStatic) "rm $out/lib/*.a"}
80+ '';
81+
7182 # test result: FAILED. 120 passed; 13 failed; 0 ignored; 0 measured; 0 filtered out
7283 doCheck = false;
7384
@@ -95,9 +106,8 @@ in rustPlatform.buildRustPackage {
95106 '';
96107 license = lib.licenses.mit;
97108 maintainers = with lib.maintainers; [ Profpatsch ];
98− # Darwin needs some more work with default libraries
99109 # Aarch has test failures with how tree-sitter compiles the generated C files
100− broken = stdenv.isDarwin || stdenv.isAarch64;
110+ broken = stdenv.isAarch64;
101111 };
102112
103113}