python3Packages.tree-sitter-grammars: ensure PEP 440 compatible versions

This commit is contained in:
kb
2025-12-18 00:50:42 +10:00
parent 6e22720fe7
commit 19713c71fd
@@ -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,