From 8df3381202046ee5feeb9e9256d21f20a20531fb Mon Sep 17 00:00:00 2001 From: figsoda Date: Fri, 9 Jun 2023 16:50:23 -0400 Subject: [PATCH] build(nix): use the correct versions of the bundled treesitter parsers --- contrib/flake.nix | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/contrib/flake.nix b/contrib/flake.nix index 59d977b748..e4d0fae99f 100644 --- a/contrib/flake.nix +++ b/contrib/flake.nix @@ -7,13 +7,50 @@ }; outputs = { self, nixpkgs, flake-utils }: + let + inherit (builtins) + elemAt + foldl' + mapAttrs + match + readFile + ; + inherit (nixpkgs.lib) + const + flip + pipe + remove + splitString + toLower + ; + in { overlay = final: prev: { - neovim = final.neovim-unwrapped.overrideAttrs (oa: rec { + neovim = (final.neovim-unwrapped.override { + treesitter-parsers = pipe ../cmake.deps/deps.txt [ + readFile + (splitString "\n") + (map (match "TREESITTER_([A-Z_]+)_(URL|SHA256)[[:space:]]+([^[:space:]]+)[[:space:]]*")) + (remove null) + (flip foldl' { } + (acc: matches: + let + lang = toLower (elemAt matches 0); + type = toLower (elemAt matches 1); + value = elemAt matches 2; + in + acc // { + ${lang} = acc.${lang} or { } // { + ${type} = value; + }; + })) + (mapAttrs (const final.fetchurl)) + ]; + }).overrideAttrs (oa: rec { version = self.shortRev or "dirty"; src = ../.; - preConfigure = '' + preConfigure = oa.preConfigure or "" + '' sed -i cmake.config/versiondef.h.in -e 's/@NVIM_VERSION_PRERELEASE@/-dev-${version}/' ''; nativeBuildInputs = oa.nativeBuildInputs ++ [