build(nix): use the correct versions of the bundled treesitter parsers

This commit is contained in:
figsoda 2023-06-09 16:50:23 -04:00
parent 9eef2b111d
commit 8df3381202
1 changed files with 39 additions and 2 deletions

View File

@ -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 ++ [