Merge pull request #133296 from teto/luarocks-pyupdater-followup

Luarocks pyupdater followup

authored by

Matthieu Coudron and committed by
GitHub
4de33380 891b3d3d

+269 -219
+53 -58
maintainers/scripts/pluginupdate.py
··· 42 42 } 43 43 44 44 log = logging.getLogger() 45 - log.addHandler(logging.StreamHandler()) 46 - 47 45 48 46 def retry(ExceptionToCheck: Any, tries: int = 4, delay: float = 3, backoff: float = 2): 49 47 """Retry calling the decorated function using an exponential backoff. ··· 203 201 name: str, 204 202 root: Path, 205 203 get_plugins: str, 206 - generate_nix: Callable[[List[Tuple[str, str, Plugin]], str], None], 207 204 default_in: Optional[Path] = None, 208 205 default_out: Optional[Path] = None, 209 206 deprecated: Optional[Path] = None, ··· 213 210 self.name = name 214 211 self.root = root 215 212 self.get_plugins = get_plugins 216 - self._generate_nix = generate_nix 217 213 self.default_in = default_in or root.joinpath(f"{name}-plugin-names") 218 214 self.default_out = default_out or root.joinpath("generated.nix") 219 215 self.deprecated = deprecated or root.joinpath("deprecated.json") ··· 226 222 def load_plugin_spec(self, plugin_file) -> List[PluginDesc]: 227 223 return load_plugin_spec(plugin_file) 228 224 229 - def generate_nix(self, plugins, outfile): 225 + def generate_nix(self, plugins, outfile: str): 230 226 '''Returns nothing for now, writes directly to outfile''' 231 - self._generate_nix(plugins, outfile) 227 + raise NotImplementedError() 232 228 233 229 def get_update(self, input_file: str, outfile: str, proc: int): 234 230 return get_update(input_file, outfile, proc, editor=self) ··· 237 233 def attr_path(self): 238 234 return self.name + "Plugins" 239 235 236 + def get_drv_name(self, name: str): 237 + return self.attr_path + "." + name 238 + 240 239 def rewrite_input(self, *args, **kwargs): 241 240 return rewrite_input(*args, **kwargs) 242 241 242 + def create_parser(self): 243 + parser = argparse.ArgumentParser( 244 + description=( 245 + f"Updates nix derivations for {self.name} plugins" 246 + f"By default from {self.default_in} to {self.default_out}" 247 + ) 248 + ) 249 + parser.add_argument( 250 + "--add", 251 + dest="add_plugins", 252 + default=[], 253 + action="append", 254 + help=f"Plugin to add to {self.attr_path} from Github in the form owner/repo", 255 + ) 256 + parser.add_argument( 257 + "--input-names", 258 + "-i", 259 + dest="input_file", 260 + default=self.default_in, 261 + help="A list of plugins in the form owner/repo", 262 + ) 263 + parser.add_argument( 264 + "--out", 265 + "-o", 266 + dest="outfile", 267 + default=self.default_out, 268 + help="Filename to save generated nix code", 269 + ) 270 + parser.add_argument( 271 + "--proc", 272 + "-p", 273 + dest="proc", 274 + type=int, 275 + default=30, 276 + help="Number of concurrent processes to spawn.", 277 + ) 278 + parser.add_argument( 279 + "--no-commit", "-n", action="store_true", default=False, 280 + help="Whether to autocommit changes" 281 + ) 282 + parser.add_argument( 283 + "--debug", "-d", choices=LOG_LEVELS.keys(), 284 + default=logging.getLevelName(logging.WARN), 285 + help="Adjust log level" 286 + ) 287 + return parser 243 288 244 289 245 290 ··· 466 511 with open(input_file, "w") as f: 467 512 f.writelines(lines) 468 513 469 - # TODO move to Editor ? 470 - def parse_args(editor: Editor): 471 - parser = argparse.ArgumentParser( 472 - description=( 473 - f"Updates nix derivations for {editor.name} plugins" 474 - f"By default from {editor.default_in} to {editor.default_out}" 475 - ) 476 - ) 477 - parser.add_argument( 478 - "--add", 479 - dest="add_plugins", 480 - default=[], 481 - action="append", 482 - help=f"Plugin to add to {editor.attr_path} from Github in the form owner/repo", 483 - ) 484 - parser.add_argument( 485 - "--input-names", 486 - "-i", 487 - dest="input_file", 488 - default=editor.default_in, 489 - help="A list of plugins in the form owner/repo", 490 - ) 491 - parser.add_argument( 492 - "--out", 493 - "-o", 494 - dest="outfile", 495 - default=editor.default_out, 496 - help="Filename to save generated nix code", 497 - ) 498 - parser.add_argument( 499 - "--proc", 500 - "-p", 501 - dest="proc", 502 - type=int, 503 - default=30, 504 - help="Number of concurrent processes to spawn.", 505 - ) 506 - parser.add_argument( 507 - "--no-commit", "-n", action="store_true", default=False, 508 - help="Whether to autocommit changes" 509 - ) 510 - parser.add_argument( 511 - "--debug", "-d", choices=LOG_LEVELS.keys(), 512 - default=logging.getLevelName(logging.WARN), 513 - help="Adjust log level" 514 - ) 515 - return parser.parse_args() 516 - 517 514 518 515 def commit(repo: git.Repo, message: str, files: List[Path]) -> None: 519 516 repo.index.add([str(f.resolve()) for f in files]) ··· 547 544 return update 548 545 549 546 550 - def update_plugins(editor: Editor): 547 + def update_plugins(editor: Editor, args): 551 548 """The main entry function of this module. All input arguments are grouped in the `Editor`.""" 552 549 553 - args = parse_args(editor) 554 550 log.setLevel(LOG_LEVELS[args.debug]) 555 - 556 551 log.info("Start updating plugins") 557 552 nixpkgs_repo = git.Repo(editor.root, search_parent_directories=True) 558 553 update = editor.get_update(args.input_file, args.outfile, args.proc) ··· 581 576 if autocommit: 582 577 commit( 583 578 nixpkgs_repo, 584 - "{editor.attr_path}.{name}: init at {version}".format( 579 + "{editor.get_drv_name name}: init at {version}".format( 585 580 editor=editor.name, name=plugin.normalized_name, version=plugin.version 586 581 ), 587 582 [args.outfile, args.input_file],
+82 -67
maintainers/scripts/update-luarocks-packages
··· 16 16 import subprocess 17 17 import csv 18 18 import logging 19 + import textwrap 20 + from multiprocessing.dummy import Pool 19 21 20 - from typing import List 22 + from typing import List, Tuple 21 23 from pathlib import Path 22 24 23 - LOG_LEVELS = { 24 - logging.getLevelName(level): level for level in [ 25 - logging.DEBUG, logging.INFO, logging.WARN, logging.ERROR ] 26 - } 27 - 28 25 log = logging.getLogger() 29 26 log.addHandler(logging.StreamHandler()) 30 27 31 28 ROOT = Path(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))).parent.parent 32 - from pluginupdate import Editor, parse_args, update_plugins, PluginDesc, CleanEnvironment 29 + from pluginupdate import Editor, update_plugins, PluginDesc, CleanEnvironment, LOG_LEVELS, Cache 33 30 34 31 PKG_LIST="maintainers/scripts/luarocks-packages.csv" 35 32 TMP_FILE="$(mktemp)" ··· 67 64 def get_current_plugins(self): 68 65 return [] 69 66 70 - def load_plugin_spec(self, input_file) -> List[PluginDesc]: 67 + def load_plugin_spec(self, input_file) -> List[LuaPlugin]: 71 68 luaPackages = [] 72 69 csvfilename=input_file 73 70 log.info("Loading package descriptions from %s", csvfilename) 74 - 75 71 76 72 with open(csvfilename, newline='') as csvfile: 77 73 reader = csv.DictReader(csvfile,) ··· 81 77 luaPackages.append(plugin) 82 78 return luaPackages 83 79 80 + def generate_nix( 81 + self, 82 + results: List[Tuple[LuaPlugin, str]], 83 + outfilename: str 84 + ): 85 + 86 + with tempfile.NamedTemporaryFile("w+") as f: 87 + f.write(HEADER) 88 + header2 = textwrap.dedent( 89 + # header2 = inspect.cleandoc( 90 + """ 91 + { self, stdenv, lib, fetchurl, fetchgit, ... } @ args: 92 + self: super: 93 + with self; 94 + { 95 + """) 96 + f.write(header2) 97 + for (plugin, nix_expr) in results: 98 + f.write(f"{plugin.normalized_name} = {nix_expr}") 99 + f.write(FOOTER) 100 + f.flush() 101 + 102 + # if everything went fine, move the generated file to its destination 103 + # using copy since move doesn't work across disks 104 + shutil.copy(f.name, outfilename) 105 + 106 + print(f"updated {outfilename}") 107 + 84 108 @property 85 109 def attr_path(self): 86 110 return "luaPackages" 87 111 88 - def get_update(self, input_file: str, outfile: str, _: int): 112 + def get_update(self, input_file: str, outfile: str, proc: int): 113 + cache: Cache = Cache(self.cache_file) 114 + _prefetch = generate_pkg_nix 89 115 90 116 def update() -> dict: 91 117 plugin_specs = self.load_plugin_spec(input_file) 118 + sorted_plugin_specs = sorted(plugin_specs, key=lambda v: v.name.lower()) 92 119 93 - self.generate_nix(plugin_specs, outfile) 120 + try: 121 + pool = Pool(processes=proc) 122 + results = pool.map(_prefetch, sorted_plugin_specs) 123 + finally: 124 + pass 125 + 126 + self.generate_nix(results, outfile) 94 127 95 128 redirects = [] 96 129 return redirects 97 130 98 131 return update 99 132 100 - def rewrite_input(self, *args, **kwargs): 133 + def rewrite_input(self, input_file: str, *args, **kwargs): 134 + # vim plugin reads the file before update but that shouldn't be our case 101 135 # not implemented yet 136 + # fieldnames = ['name', 'server', 'version', 'luaversion', 'maintainers'] 137 + # input_file = "toto.csv" 138 + # with open(input_file, newline='') as csvfile: 139 + # writer = csv.DictWriter(csvfile, fieldnames=fieldnames) 140 + # writer.writeheader() 141 + # for row in reader: 142 + # # name,server,version,luaversion,maintainers 143 + # plugin = LuaPlugin(**row) 144 + # luaPackages.append(plugin) 102 145 pass 103 146 104 - def generate_nix( 105 - plugins: List[LuaPlugin], 106 - outfilename: str 107 - ): 108 - sorted_plugins = sorted(plugins, key=lambda v: v.name.lower()) 147 + def generate_pkg_nix(plug: LuaPlugin): 148 + ''' 149 + Generate nix expression for a luarocks package 150 + Our cache key associates "p.name-p.version" to its rockspec 151 + ''' 152 + log.debug("Generating nix expression for %s", plug.name) 153 + cmd = [ "luarocks", "nix", plug.name] 109 154 110 - # plug = {} 111 - # selon le manifest luarocks.org/manifest 112 - def _generate_pkg_nix(plug): 113 - cmd = [ "luarocks", "nix", plug.name] 114 - if plug.server: 115 - cmd.append(f"--only-server={plug.server}") 116 - 117 - if plug.maintainers: 118 - cmd.append(f"--maintainers={plug.maintainers}") 119 - 120 - if plug.version: 121 - cmd.append(plug.version) 122 - 123 - if plug.luaversion: 124 - with CleanEnvironment(): 125 - local_pkgs = str(ROOT.resolve()) 126 - cmd2 = ["nix-build", "--no-out-link", local_pkgs, "-A", f"{plug.luaversion}"] 127 - 128 - log.debug("running %s", cmd2) 129 - lua_drv_path=subprocess.check_output(cmd2, text=True).strip() 130 - cmd.append(f"--lua-dir={lua_drv_path}/bin") 131 - 132 - log.debug("running %s", cmd) 133 - output = subprocess.check_output(cmd, text=True) 134 - return output 135 - 136 - with tempfile.NamedTemporaryFile("w+") as f: 137 - f.write(HEADER) 138 - f.write(""" 139 - { self, stdenv, lib, fetchurl, fetchgit, ... } @ args: 140 - self: super: 141 - with self; 142 - { 143 - """) 155 + if plug.server: 156 + cmd.append(f"--only-server={plug.server}") 144 157 145 - for plugin in sorted_plugins: 158 + if plug.maintainers: 159 + cmd.append(f"--maintainers={plug.maintainers}") 146 160 147 - nix_expr = _generate_pkg_nix(plugin) 148 - f.write(f"{plugin.normalized_name} = {nix_expr}" 149 - ) 150 - f.write(FOOTER) 151 - f.flush() 161 + if plug.version: 162 + cmd.append(plug.version) 152 163 153 - # if everything went fine, move the generated file to its destination 154 - # using copy since move doesn't work across disks 155 - shutil.copy(f.name, outfilename) 164 + if plug.luaversion: 165 + with CleanEnvironment(): 166 + local_pkgs = str(ROOT.resolve()) 167 + cmd2 = ["nix-build", "--no-out-link", local_pkgs, "-A", f"{plug.luaversion}"] 156 168 157 - print(f"updated {outfilename}") 169 + log.debug("running %s", ' '.join(cmd2)) 170 + lua_drv_path=subprocess.check_output(cmd2, text=True).strip() 171 + cmd.append(f"--lua-dir={lua_drv_path}/bin") 158 172 159 - def load_plugin_spec(): 160 - pass 161 - 173 + log.debug("running %s", cmd) 174 + output = subprocess.check_output(cmd, text=True) 175 + return (plug, output) 162 176 163 177 def main(): 164 178 165 - editor = LuaEditor("lua", ROOT, '', generate_nix, 179 + editor = LuaEditor("lua", ROOT, '', 166 180 default_in = ROOT.joinpath(PKG_LIST), 167 181 default_out = ROOT.joinpath(GENERATED_NIXFILE) 168 182 ) 169 183 170 - args = parse_args(editor) 184 + parser = editor.create_parser() 185 + args = parser.parse_args() 171 186 log.setLevel(LOG_LEVELS[args.debug]) 172 187 173 - update_plugins(editor) 188 + update_plugins(editor, args) 174 189 175 190 176 191 if __name__ == "__main__":
+42 -37
pkgs/applications/editors/kakoune/plugins/update.py
··· 39 39 40 40 HEADER = "# This file has been generated by ./pkgs/applications/editors/kakoune/plugins/update.py. Do not edit!" 41 41 42 + class KakouneEditor(pluginupdate.Editor): 42 43 43 - def generate_nix(plugins: List[Tuple[str, str, pluginupdate.Plugin]], outfile: str): 44 - sorted_plugins = sorted(plugins, key=lambda v: v[2].name.lower()) 45 44 46 - with open(outfile, "w+") as f: 47 - f.write(HEADER) 48 - f.write( 49 - """ 50 - { lib, buildKakounePluginFrom2Nix, fetchFromGitHub, overrides ? (self: super: {}) }: 51 - let 52 - packages = ( self: 53 - {""" 54 - ) 55 - for owner, repo, plugin in sorted_plugins: 56 - if plugin.has_submodules: 57 - submodule_attr = "\n fetchSubmodules = true;" 58 - else: 59 - submodule_attr = "" 45 + def generate_nix(plugins: List[Tuple[str, str, pluginupdate.Plugin]], outfile: str): 46 + sorted_plugins = sorted(plugins, key=lambda v: v[2].name.lower()) 60 47 48 + with open(outfile, "w+") as f: 49 + f.write(HEADER) 61 50 f.write( 62 - f""" 63 - {plugin.normalized_name} = buildKakounePluginFrom2Nix {{ 64 - pname = "{plugin.normalized_name}"; 65 - version = "{plugin.version}"; 66 - src = fetchFromGitHub {{ 67 - owner = "{owner}"; 68 - repo = "{repo}"; 69 - rev = "{plugin.commit}"; 70 - sha256 = "{plugin.sha256}";{submodule_attr} 51 + """ 52 + { lib, buildKakounePluginFrom2Nix, fetchFromGitHub, overrides ? (self: super: {}) }: 53 + let 54 + packages = ( self: 55 + {""" 56 + ) 57 + for owner, repo, plugin in sorted_plugins: 58 + if plugin.has_submodules: 59 + submodule_attr = "\n fetchSubmodules = true;" 60 + else: 61 + submodule_attr = "" 62 + 63 + f.write( 64 + f""" 65 + {plugin.normalized_name} = buildKakounePluginFrom2Nix {{ 66 + pname = "{plugin.normalized_name}"; 67 + version = "{plugin.version}"; 68 + src = fetchFromGitHub {{ 69 + owner = "{owner}"; 70 + repo = "{repo}"; 71 + rev = "{plugin.commit}"; 72 + sha256 = "{plugin.sha256}";{submodule_attr} 73 + }}; 74 + meta.homepage = "https://github.com/{owner}/{repo}/"; 71 75 }}; 72 - meta.homepage = "https://github.com/{owner}/{repo}/"; 73 - }}; 74 - """ 76 + """ 77 + ) 78 + f.write( 79 + """ 80 + }); 81 + in lib.fix' (lib.extends overrides packages) 82 + """ 75 83 ) 76 - f.write( 77 - """ 78 - }); 79 - in lib.fix' (lib.extends overrides packages) 80 - """ 81 - ) 82 - print(f"updated {outfile}") 84 + print(f"updated {outfile}") 83 85 84 86 85 87 def main(): 86 - editor = pluginupdate.Editor("kakoune", ROOT, GET_PLUGINS, generate_nix) 87 - pluginupdate.update_plugins(editor) 88 + editor = KakouneEditor("kakoune", ROOT, GET_PLUGINS) 89 + parser = editor.create_parser() 90 + args = parser.parse_args() 91 + 92 + pluginupdate.update_plugins(editor, args) 88 93 89 94 90 95 if __name__ == "__main__":
+50 -19
pkgs/development/lua-modules/generated-packages.nix
··· 34 34 version = "1.0.2-3"; 35 35 36 36 src = fetchurl { 37 - url = "https://luarocks.org/ansicolors-1.0.2-3.src.rock"; 37 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/ansicolors-1.0.2-3.src.rock"; 38 38 sha256 = "1mhmr090y5394x1j8p44ws17sdwixn5a0r4i052bkfgk3982cqfz"; 39 39 }; 40 40 disabled = (luaOlder "5.1"); ··· 94 94 version = "0.4-1"; 95 95 96 96 src = fetchurl { 97 - url = "https://luarocks.org/binaryheap-0.4-1.src.rock"; 97 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/binaryheap-0.4-1.src.rock"; 98 98 sha256 = "11rd8r3bpinfla2965jgjdv1hilqdc1q6g1qla5978d7vzg19kpc"; 99 99 }; 100 100 disabled = (luaOlder "5.1"); ··· 175 175 version = "0.7-1"; 176 176 177 177 src = fetchurl { 178 - url = "https://luarocks.org/compat53-0.7-1.src.rock"; 178 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/compat53-0.7-1.src.rock"; 179 179 sha256 = "0kpaxbpgrwjn4jjlb17fn29a09w6lw732d21bi0302kqcaixqpyb"; 180 180 }; 181 181 disabled = (luaOlder "5.1") || (luaAtLeast "5.4"); ··· 194 194 version = "16.06.04-1"; 195 195 196 196 src = fetchurl { 197 - url = "https://luarocks.org/cosmo-16.06.04-1.src.rock"; 197 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/cosmo-16.06.04-1.src.rock"; 198 198 sha256 = "1adrk74j0x1yzhy0xz9k80hphxdjvm09kpwpbx00sk3kic6db0ww"; 199 199 }; 200 200 propagatedBuildInputs = [ lpeg ]; ··· 278 278 version = "0.2-1"; 279 279 280 280 src = fetchurl { 281 - url = "mirror://luarocks/digestif-0.2-1.src.rock"; 281 + url = "https://luarocks.org/digestif-0.2-1.src.rock"; 282 282 sha256 = "03blpj5lxlhmxa4hnj21sz7sc84g96igbc7r97yb2smmlbyq8hxd"; 283 283 }; 284 284 disabled = (luaOlder "5.3"); ··· 326 326 }; 327 327 }; 328 328 329 + gitsigns-nvim = buildLuarocksPackage { 330 + pname = "gitsigns.nvim"; 331 + version = "scm-1"; 332 + 333 + knownRockspec = (fetchurl { 334 + url = "https://luarocks.org/gitsigns.nvim-scm-1.rockspec"; 335 + sha256 = "12cl4dpx18jrdjfzfk8mckqgb52fh9ayikqny5rfn2s4mbn9i5lj"; 336 + }).outPath; 337 + 338 + src = fetchgit ( removeAttrs (builtins.fromJSON ''{ 339 + "url": "git://github.com/lewis6991/gitsigns.nvim", 340 + "rev": "083dc2f485571546144e287c38a96368ea2e79a1", 341 + "date": "2021-08-09T21:58:59+01:00", 342 + "path": "/nix/store/1kwvlcshbbk31i4pa3s9gx8znsh9nwk2-gitsigns.nvim", 343 + "sha256": "0vrb900p2rc323axb93hc7jwcxg8455zwqsvxm9vkd2mcsdpn33w", 344 + "fetchSubmodules": true, 345 + "deepClone": false, 346 + "leaveDotGit": false 347 + } 348 + '') ["date" "path"]) ; 349 + 350 + disabled = (lua.luaversion != "5.1"); 351 + propagatedBuildInputs = [ lua plenary-nvim ]; 352 + 353 + meta = with lib; { 354 + homepage = "http://github.com/lewis6991/gitsigns.nvim"; 355 + description = "Git signs written in pure lua"; 356 + license.fullName = "MIT/X11"; 357 + }; 358 + }; 359 + 329 360 http = buildLuarocksPackage { 330 361 pname = "http"; 331 362 version = "0.3-0"; ··· 350 381 version = "3.1.1-0"; 351 382 352 383 src = fetchurl { 353 - url = "https://luarocks.org/inspect-3.1.1-0.src.rock"; 384 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/inspect-3.1.1-0.src.rock"; 354 385 sha256 = "0k4g9ahql83l4r2bykfs6sacf9l1wdpisav2i0z55fyfcdv387za"; 355 386 }; 356 387 disabled = (luaOlder "5.1"); ··· 422 453 version = "0.9.2-1"; 423 454 424 455 src = fetchurl { 425 - url = "https://luarocks.org/lgi-0.9.2-1.src.rock"; 456 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/lgi-0.9.2-1.src.rock"; 426 457 sha256 = "07ajc5pdavp785mdyy82n0w6d592n96g95cvq025d6i0bcm2cypa"; 427 458 }; 428 459 disabled = (luaOlder "5.1"); ··· 440 471 version = "0.9-1"; 441 472 442 473 knownRockspec = (fetchurl { 443 - url = "https://luarocks.org/linenoise-0.9-1.rockspec"; 474 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/linenoise-0.9-1.rockspec"; 444 475 sha256 = "0wic8g0d066pj9k51farsvcdbnhry2hphvng68w9k4lh0zh45yg4"; 445 476 }).outPath; 446 477 ··· 483 514 version = "1.0.2-1"; 484 515 485 516 src = fetchurl { 486 - url = "https://luarocks.org/lpeg-1.0.2-1.src.rock"; 517 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/lpeg-1.0.2-1.src.rock"; 487 518 sha256 = "1g5zmfh0x7drc6mg2n0vvlga2hdc08cyp3hnb22mh1kzi63xdl70"; 488 519 }; 489 520 disabled = (luaOlder "5.1"); ··· 537 568 version = "1.2.2-1"; 538 569 539 570 src = fetchurl { 540 - url = "https://luarocks.org/lpty-1.2.2-1.src.rock"; 571 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/lpty-1.2.2-1.src.rock"; 541 572 sha256 = "1vxvsjgjfirl6ranz6k4q4y2dnxqh72bndbk400if22x8lqbkxzm"; 542 573 }; 543 574 disabled = (luaOlder "5.1"); ··· 744 775 version = "0.16.1-0"; 745 776 746 777 src = fetchurl { 747 - url = "https://luarocks.org/lua-resty-http-0.16.1-0.src.rock"; 778 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/lua-resty-http-0.16.1-0.src.rock"; 748 779 sha256 = "0n5hiablpc0dsccs6h76zg81wc3jb4mdvyfn9lfxnhls3yqwrgkj"; 749 780 }; 750 781 disabled = (luaOlder "5.1"); ··· 923 954 version = "3.0-2"; 924 955 925 956 src = fetchurl { 926 - url = "https://luarocks.org/lua_cliargs-3.0-2.src.rock"; 957 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/lua_cliargs-3.0-2.src.rock"; 927 958 sha256 = "0qqdnw00r16xbyqn4w1xwwpg9i9ppc3c1dcypazjvdxaj899hy9w"; 928 959 }; 929 960 disabled = (luaOlder "5.1"); ··· 1377 1408 version = "0.1.3-1"; 1378 1409 1379 1410 src = fetchurl { 1380 - url = "https://luarocks.org/luautf8-0.1.3-1.src.rock"; 1411 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luautf8-0.1.3-1.src.rock"; 1381 1412 sha256 = "1yp4j1r33yvsqf8cggmf4mhaxhz5lqzxhl9mnc0q5lh01yy5di48"; 1382 1413 }; 1383 1414 disabled = (luaOlder "5.1"); ··· 1432 1463 version = "1.30.0-0"; 1433 1464 1434 1465 src = fetchurl { 1435 - url = "https://luarocks.org/luv-1.30.0-0.src.rock"; 1466 + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luv-1.30.0-0.src.rock"; 1436 1467 sha256 = "1z5sdq9ld4sm5pws9qxpk9cadv9i7ycwad1zwsa57pj67gly11vi"; 1437 1468 }; 1438 1469 disabled = (luaOlder "5.1"); ··· 1588 1619 1589 1620 knownRockspec = (fetchurl { 1590 1621 url = "https://luarocks.org/plenary.nvim-scm-1.rockspec"; 1591 - sha256 = "1cp2dzf3010q85h300aa7zphyz75qn67lrwf9v6b0p534nzvmash"; 1622 + sha256 = "1xgqq0skg3vxahlnh1libc5dvhafp11k6k8cs65jcr9sw6xjycwh"; 1592 1623 }).outPath; 1593 1624 1594 1625 src = fetchgit ( removeAttrs (builtins.fromJSON ''{ 1595 1626 "url": "git://github.com/nvim-lua/plenary.nvim", 1596 - "rev": "d897b4d9fdbc51febd71a1f96c96001ae4fa6121", 1597 - "date": "2021-08-03T08:49:43-04:00", 1598 - "path": "/nix/store/nwarm7lh0r1rzmx92srq73x3r40whyw1-plenary.nvim", 1599 - "sha256": "0rgqby4aakqamiw3ykvzhn3vd2grjkzgfxrpzjjp1ipkd2qak8mb", 1627 + "rev": "adf9d62023e2d39d9d9a2bc550feb3ed7b545d0f", 1628 + "date": "2021-08-11T11:38:20-04:00", 1629 + "path": "/nix/store/fjmpxdswkx54a1n8vwmh3xfrzjq3j5wg-plenary.nvim", 1630 + "sha256": "1h11a0lil14c13v5mdzdmxxqjpqip5fhvjbm34827czb5pz1hvcz", 1600 1631 "fetchSubmodules": true, 1601 1632 "deepClone": false, 1602 1633 "leaveDotGit": false
+42 -38
pkgs/misc/vim-plugins/update.py
··· 11 11 import inspect 12 12 import os 13 13 import sys 14 + import logging 15 + import textwrap 14 16 from typing import List, Tuple 15 17 from pathlib import Path 18 + 19 + log = logging.getLogger() 20 + log.addHandler(logging.StreamHandler()) 16 21 17 22 # Import plugin update library from maintainers/scripts/pluginupdate.py 18 23 ROOT = Path(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))) ··· 40 45 ) 41 46 42 47 43 - def generate_nix(plugins: List[Tuple[str, str, pluginupdate.Plugin]], outfile: str): 44 - sorted_plugins = sorted(plugins, key=lambda v: v[2].name.lower()) 48 + class VimEditor(pluginupdate.Editor): 49 + def generate_nix(self, plugins: List[Tuple[str, str, pluginupdate.Plugin]], outfile: str): 50 + sorted_plugins = sorted(plugins, key=lambda v: v[2].name.lower()) 45 51 46 - with open(outfile, "w+") as f: 47 - f.write(HEADER) 48 - f.write( 49 - """ 50 - { lib, buildVimPluginFrom2Nix, fetchFromGitHub }: 52 + with open(outfile, "w+") as f: 53 + f.write(HEADER) 54 + f.write(textwrap.dedent(""" 55 + { lib, buildVimPluginFrom2Nix, fetchFromGitHub }: 51 56 52 - final: prev: 53 - {""" 54 - ) 55 - for owner, repo, plugin in sorted_plugins: 56 - if plugin.has_submodules: 57 - submodule_attr = "\n fetchSubmodules = true;" 58 - else: 59 - submodule_attr = "" 57 + final: prev: 58 + {""" 59 + )) 60 + for owner, repo, plugin in sorted_plugins: 61 + if plugin.has_submodules: 62 + submodule_attr = "\n fetchSubmodules = true;" 63 + else: 64 + submodule_attr = "" 60 65 61 - f.write( 62 - f""" 63 - {plugin.normalized_name} = buildVimPluginFrom2Nix {{ 64 - pname = "{plugin.normalized_name}"; 65 - version = "{plugin.version}"; 66 - src = fetchFromGitHub {{ 67 - owner = "{owner}"; 68 - repo = "{repo}"; 69 - rev = "{plugin.commit}"; 70 - sha256 = "{plugin.sha256}";{submodule_attr} 71 - }}; 72 - meta.homepage = "https://github.com/{owner}/{repo}/"; 73 - }}; 74 - """ 75 - ) 76 - f.write( 77 - """ 78 - } 79 - """ 80 - ) 81 - print(f"updated {outfile}") 66 + f.write(textwrap.indent(textwrap.dedent( 67 + f""" 68 + {plugin.normalized_name} = buildVimPluginFrom2Nix {{ 69 + pname = "{plugin.normalized_name}"; 70 + version = "{plugin.version}"; 71 + src = fetchFromGitHub {{ 72 + owner = "{owner}"; 73 + repo = "{repo}"; 74 + rev = "{plugin.commit}"; 75 + sha256 = "{plugin.sha256}";{submodule_attr} 76 + }}; 77 + meta.homepage = "https://github.com/{owner}/{repo}/"; 78 + }}; 79 + """ 80 + ), ' ')) 81 + f.write("\n}") 82 + print(f"updated {outfile}") 82 83 83 84 85 + 84 86 def main(): 85 - editor = pluginupdate.Editor("vim", ROOT, GET_PLUGINS, generate_nix) 86 - pluginupdate.update_plugins(editor) 87 + editor = VimEditor("vim", ROOT, GET_PLUGINS) 88 + parser = editor.create_parser() 89 + args = parser.parse_args() 90 + pluginupdate.update_plugins(editor, args) 87 91 88 92 89 93 if __name__ == "__main__":