1 #!/usr/bin/env nix-shell
2 #!nix-shell update-shell.nix -i python3
5 # $ nix run nixpkgs#python3Packages.ruff -- update.py
7 # $ nix run nixpkgs#python3Packages.mypy -- update.py
9 # $ nix run nixpkgs#python3Packages.flake8 -- --ignore E501,E265,E402 update.py
14 from pathlib
import Path
16 # Import plugin update library from maintainers/scripts/pluginupdate.py
17 ROOT
= Path(os
.path
.dirname(os
.path
.abspath(inspect
.getfile(inspect
.currentframe())))) # type: ignore
19 0, os
.path
.join(ROOT
.parent
.parent
.parent
.parent
.parent
, "maintainers", "scripts")
23 GET_PLUGINS
= f
"""with import <localpkgs> {{ }};
25 inherit (kakouneUtils.override {{ }}) buildKakounePluginFrom2Nix;
26 generated = callPackage {ROOT}/generated.nix {{ inherit buildKakounePluginFrom2Nix; }};
31 && lib.hasAttrByPath [
36 parse = name: value: {{
38 version = value.version;
39 homePage = value.meta.homepage;
41 if hasChecksum value then
43 submodules = value.src.fetchSubmodules or false;
44 sha256 = value.src.outputHash;
51 lib.mapAttrs parse generated"""
53 HEADER
= "# This file has been @generated by ./pkgs/applications/editors/kakoune/plugins/update.py. Do not edit!"
56 class KakouneEditor(pluginupdate
.Editor
):
59 plugins
: list[tuple[pluginupdate
.PluginDesc
, pluginupdate
.Plugin
]],
62 with
open(outfile
, "w+") as f
:
66 { lib, buildKakounePluginFrom2Nix, fetchFromGitHub, overrides ? (self: super: {}) }:
71 for pluginDesc
, plugin
in plugins
:
74 {plugin.normalized_name} = buildKakounePluginFrom2Nix {{
75 pname = "{plugin.normalized_name}";
76 version = "{plugin.version}";
77 src = {pluginDesc.repo.as_nix(plugin)};
78 meta.homepage = "{pluginDesc.repo.url("")}";
85 in lib.fix' (lib.extends overrides packages)
88 print(f
"updated {outfile}")
90 def update(self
, args
):
91 pluginupdate
.update_plugins(self
, args
)
95 editor
= KakouneEditor("kakoune", ROOT
, GET_PLUGINS
)
99 if __name__
== "__main__":