Unverified Commit ebfb1d12 authored by André Silva's avatar André Silva
Browse files

tree-sitter-grammars: pin rev for unstable grammars

parent 6279fa2b
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@ in

lib.mapAttrs' (
  language: attrs:
  let
    source = lib.optionalAttrs (attrs ? url) (parseUrl attrs.url);
  in
  lib.nameValuePair "tree-sitter-${language}" (
    {
      # Default to the source attr name as the language
@@ -55,7 +58,7 @@ lib.mapAttrs' (
          if (isUnstable attrs.version) then
            [
              "--version"
              "branch"
              "branch${lib.optionalString (source ? ref) "=${source.ref}"}"
            ]
          else
            [
@@ -70,7 +73,6 @@ lib.mapAttrs' (
    // lib.optionalAttrs (attrs ? url && attrs ? hash) {
      src =
        let
          source = parseUrl attrs.url;
          fetch = lib.getAttr source.type {
            github = fetchFromGitHub;
            gitlab = fetchFromGitLab;
@@ -78,19 +80,26 @@ lib.mapAttrs' (
            codeberg = fetchFromCodeberg;
            # NOTE: include other types here as required
          };
          rev =
            if isUnstable attrs.version then
              attrs.rev
                or (throw "tree-sitter grammar '${language}': unstable version requires a pinned 'rev' attribute")
            else
              source.ref or "v${attrs.version}";
        in
        fetch {
          inherit (source)
            owner
            repo
            ;
          rev = source.ref or "v${attrs.version}";
          inherit rev;
          inherit (attrs) hash;
        };
    }
    // removeAttrs attrs [
      "url"
      "hash"
      "rev"
    ]
  )
) grammar-sources
+361 −180

File changed.

Preview size limit exceeded, changes collapsed.