# { lib }: # url: # let # u0 = builtins.head (builtins.split "[?#]" url); # u = lib.strings.removeSuffix "/" u0; # m = builtins.match "https://github.com/([^/]+)/([^/]+)(/(tree|tag|commit)/([^/]+)(/(.*))?)?" u; # in # assert m != null; # let # owner = builtins.elemAt m 0; # repo = builtins.elemAt m 1; # kind = builtins.elemAt m 3; # rev = builtins.elemAt m 4; # subdir = builtins.elemAt m 6; # in # { # inherit # owner # repo # kind # rev # subdir # ; # version = # if rev == null then # null # else # let # vm = builtins.match "^.*([0-9]+(\\.[0-9]+)+).*$" rev; # in # if vm == null then null else builtins.elemAt vm 0; # pname = repo; # homepage = "https://github.com/${owner}/${repo}"; # }