diff --git a/pkgs/development/python-modules/tree-sitter-grammars/default.nix b/pkgs/development/python-modules/tree-sitter-grammars/default.nix index 8abe7bae8221..4bf53a9e134a 100644 --- a/pkgs/development/python-modules/tree-sitter-grammars/default.nix +++ b/pkgs/development/python-modules/tree-sitter-grammars/default.nix @@ -12,8 +12,20 @@ grammarDrv, }: let - inherit (grammarDrv) version; - + # Map nix style `0-unstable-YYYY-MM-DD` version identifiers to a PEP 440 + # compatible form (`0+unstableYYYYMMDD`). + version = lib.pipe grammarDrv [ + lib.getVersion + (lib.splitString "-") + ( + parts: + let + version = lib.head parts; + metadata = lib.join "" (lib.tail parts); + in + if (metadata == "") then version else "${version}+${metadata}" + ) + ]; snakeCaseName = lib.replaceStrings [ "-" ] [ "_" ] name; drvPrefix = "python-${name}"; # If the name of the grammar attribute differs from the grammar's symbol name,