From ad763e44fb5b85d0092351cc0ed08751ec7d1767 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Wed, 15 Apr 2026 21:21:57 -0500 Subject: [PATCH 1/2] nixpkgs-plugin-update: handle special chars in tags Previously errored on special chars. Url encode refs. --- .../src/nixpkgs_plugin_update/__init__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py b/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py index 1a54775d1dd2..c7988515bf7b 100644 --- a/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py +++ b/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py @@ -16,7 +16,6 @@ import sys import time import traceback import urllib.error -import urllib.parse import urllib.request import xml.etree.ElementTree as ET from dataclasses import asdict, dataclass @@ -26,7 +25,7 @@ from multiprocessing.dummy import Pool from pathlib import Path from tempfile import NamedTemporaryFile from typing import Any, Callable -from urllib.parse import urljoin, urlparse +from urllib.parse import urljoin, urlparse, urlsplit import git from packaging.version import InvalidVersion, parse as parse_version @@ -407,7 +406,7 @@ class RepoGitHub(Repo): response_url = req.geturl() if url != response_url: new_owner, new_name = ( - urllib.parse.urlsplit(response_url).path.strip("/").split("/")[:2] + urlsplit(response_url).path.strip("/").split("/")[:2] ) new_repo = RepoGitHub(owner=new_owner, repo=new_name, branch=self.branch) @@ -421,7 +420,15 @@ class RepoGitHub(Repo): return sha256 def prefetch_github(self, ref: str) -> str: - cmd = ["nix-prefetch-url", "--unpack", self.url(f"archive/{ref}.tar.gz")] + quoted_ref = quote(ref, safe="") + safe_name = re.sub(r"[^A-Za-z0-9._+-]", "-", f"{self.repo}-{ref}.tar.gz") + cmd = [ + "nix-prefetch-url", + "--unpack", + "--name", + safe_name, + self.url(f"archive/{quoted_ref}.tar.gz"), + ] log.debug("Running %s", cmd) data = subprocess.check_output(cmd) return data.strip().decode("utf-8") From 231170aa16b03d8f26ffe05322cf84f4df400e25 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 16 Apr 2026 08:13:05 -0500 Subject: [PATCH 2/2] nixpkgs-plugin-update: use nix-prefetch-github --- .../editors/vim/plugins/utils/updater.nix | 2 ++ .../src/nixpkgs_plugin_update/__init__.py | 13 +++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/editors/vim/plugins/utils/updater.nix b/pkgs/applications/editors/vim/plugins/utils/updater.nix index 82cbb7a923ba..2ed61a25c83a 100644 --- a/pkgs/applications/editors/vim/plugins/utils/updater.nix +++ b/pkgs/applications/editors/vim/plugins/utils/updater.nix @@ -3,6 +3,7 @@ buildPythonApplication, makeWrapper, nix, + nix-prefetch-github, nix-prefetch-git, nurl, python3Packages, @@ -37,6 +38,7 @@ buildPythonApplication { makeWrapperArgs+=( --prefix PATH : "${ lib.makeBinPath [ nix + nix-prefetch-github nix-prefetch-git neovim-unwrapped nurl diff --git a/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py b/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py index c7988515bf7b..154c0190455f 100644 --- a/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py +++ b/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py @@ -420,18 +420,11 @@ class RepoGitHub(Repo): return sha256 def prefetch_github(self, ref: str) -> str: - quoted_ref = quote(ref, safe="") - safe_name = re.sub(r"[^A-Za-z0-9._+-]", "-", f"{self.repo}-{ref}.tar.gz") - cmd = [ - "nix-prefetch-url", - "--unpack", - "--name", - safe_name, - self.url(f"archive/{quoted_ref}.tar.gz"), - ] + cmd = ["nix-prefetch-github", self.owner, self.repo, "--rev", ref, "--json"] log.debug("Running %s", cmd) data = subprocess.check_output(cmd) - return data.strip().decode("utf-8") + loaded = json.loads(data) + return loaded["hash"] def as_nix(self, plugin: "Plugin") -> str: if plugin.has_submodules: