-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pluginupdate.py: fix bugs and add improvements; vimPlugins: sort properly #353786
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,49 +2,63 @@ | |
#!nix-shell update-shell.nix -i python3 | ||
|
||
# format: | ||
# $ nix run nixpkgs.python3Packages.black -c black update.py | ||
# $ nix run nixpkgs#python3Packages.ruff -- update.py | ||
# type-check: | ||
# $ nix run nixpkgs.python3Packages.mypy -c mypy update.py | ||
# $ nix run nixpkgs#python3Packages.mypy -- update.py | ||
# linted: | ||
# $ nix run nixpkgs.python3Packages.flake8 -c flake8 --ignore E501,E265,E402 update.py | ||
# $ nix run nixpkgs#python3Packages.flake8 -- --ignore E501,E265,E402 update.py | ||
|
||
import inspect | ||
import os | ||
import sys | ||
from typing import List, Tuple | ||
from pathlib import Path | ||
from typing import List, Tuple | ||
|
||
# Import plugin update library from maintainers/scripts/pluginupdate.py | ||
ROOT = Path(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))) # type: ignore | ||
ROOT = Path(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))) # type: ignore | ||
sys.path.insert( | ||
0, os.path.join(ROOT.parent.parent.parent.parent.parent, "maintainers", "scripts") | ||
) | ||
import pluginupdate | ||
|
||
GET_PLUGINS = f"""(with import <localpkgs> {{}}; | ||
GET_PLUGINS = f"""( | ||
with import <localpkgs> {{ }}; | ||
let | ||
inherit (kakouneUtils.override {{}}) buildKakounePluginFrom2Nix; | ||
inherit (kakouneUtils.override {{ }}) buildKakounePluginFrom2Nix; | ||
generated = callPackage {ROOT}/generated.nix {{ | ||
inherit buildKakounePluginFrom2Nix; | ||
}}; | ||
hasChecksum = value: lib.isAttrs value && lib.hasAttrByPath ["src" "outputHash"] value; | ||
getChecksum = name: value: | ||
if hasChecksum value then {{ | ||
submodules = value.src.fetchSubmodules or false; | ||
sha256 = value.src.outputHash; | ||
rev = value.src.rev; | ||
}} else null; | ||
hasChecksum = | ||
value: | ||
lib.isAttrs value | ||
&& lib.hasAttrByPath [ | ||
"src" | ||
"outputHash" | ||
] value; | ||
getChecksum = | ||
name: value: | ||
if hasChecksum value then | ||
{{ | ||
submodules = value.src.fetchSubmodules or false; | ||
sha256 = value.src.outputHash; | ||
rev = value.src.rev; | ||
}} | ||
else | ||
null; | ||
checksums = lib.mapAttrs getChecksum generated; | ||
in lib.filterAttrs (n: v: v != null) checksums)""" | ||
|
||
HEADER = "# This file has been generated by ./pkgs/applications/editors/kakoune/plugins/update.py. Do not edit!" | ||
|
||
class KakouneEditor(pluginupdate.Editor): | ||
in | ||
lib.filterAttrs (n: v: v != null) checksums | ||
)""" | ||
|
||
HEADER = "# This file has been @generated by ./pkgs/applications/editors/kakoune/plugins/update.py. Do not edit!" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just saw that the same does poetry There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, fine by me. |
||
|
||
def generate_nix(self, plugins: List[Tuple[pluginupdate.PluginDesc, pluginupdate.Plugin]], outfile: str): | ||
sorted_plugins = sorted(plugins, key=lambda v: v[1].name.lower()) | ||
|
||
class KakouneEditor(pluginupdate.Editor): | ||
def generate_nix( | ||
self, | ||
plugins: List[Tuple[pluginupdate.PluginDesc, pluginupdate.Plugin]], | ||
outfile: str, | ||
): | ||
with open(outfile, "w+") as f: | ||
f.write(HEADER) | ||
f.write( | ||
|
@@ -54,7 +68,7 @@ def generate_nix(self, plugins: List[Tuple[pluginupdate.PluginDesc, pluginupdate | |
packages = ( self: | ||
{""" | ||
) | ||
for pluginDesc, plugin in sorted_plugins: | ||
for pluginDesc, plugin in plugins: | ||
f.write( | ||
f""" | ||
{plugin.normalized_name} = buildKakounePluginFrom2Nix {{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also manually formatted this with
nixfmt-rfc-style