nixpkgs-plugin-update: generate sri hashes (#471237)

This commit is contained in:
Gaétan Lepage
2025-12-16 15:07:51 +00:00
committed by GitHub
2 changed files with 1821 additions and 1804 deletions
File diff suppressed because it is too large Load Diff
@@ -201,7 +201,7 @@ class Repo:
return f"""fetchgit {{
url = "{self.uri}";
rev = "{plugin.commit}";
sha256 = "{plugin.sha256}";
hash = "{plugin.to_sri_hash()}";
}}"""
@@ -428,7 +428,7 @@ class RepoGitHub(Repo):
owner = "{self.owner}";
repo = "{self.repo}";
rev = "{plugin.commit}";
sha256 = "{plugin.sha256}";{submodule_attr}
hash = "{plugin.to_sri_hash()}";{submodule_attr}
}}"""
@@ -483,6 +483,23 @@ class Plugin:
def normalized_name(self) -> str:
return self.name.replace(".", "-")
def to_sri_hash(self) -> str:
if self.sha256.startswith("sha256-"):
return self.sha256
cmd = [
"nix",
"hash",
"convert",
"--hash-algo",
"sha256",
"--to",
"sri",
self.sha256,
]
result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
return result.decode("utf-8").strip()
@property
def version(self) -> str:
assert self.date is not None