update-python-libraries: make hermetic (#395046)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{
|
||||
lib,
|
||||
python3,
|
||||
runCommand,
|
||||
git,
|
||||
@@ -9,8 +10,6 @@
|
||||
runCommand "update-python-libraries"
|
||||
{
|
||||
buildInputs = [
|
||||
nix
|
||||
nix-prefetch-git
|
||||
(python3.withPackages (
|
||||
ps: with ps; [
|
||||
packaging
|
||||
@@ -18,11 +17,14 @@ runCommand "update-python-libraries"
|
||||
toolz
|
||||
]
|
||||
))
|
||||
git
|
||||
];
|
||||
}
|
||||
''
|
||||
cp ${./update-python-libraries.py} $out
|
||||
patchShebangs $out
|
||||
substituteInPlace $out --replace 'GIT = "git"' 'GIT = "${git}/bin/git"'
|
||||
substituteInPlace $out \
|
||||
--replace-fail 'NIX = "nix"' 'NIX = "${lib.getExe nix}"' \
|
||||
--replace-fail 'NIX_PREFETCH_URL = "nix-prefetch-url"' 'NIX_PREFETCH_URL = "${lib.getExe' nix "nix-prefetch-url"}"' \
|
||||
--replace-fail 'NIX_PREFETCH_GIT = "nix-prefetch-git"' 'NIX_PREFETCH_GIT = "${lib.getExe nix-prefetch-git}"' \
|
||||
--replace-fail 'GIT = "git"' 'GIT = "${lib.getExe git}"'
|
||||
''
|
||||
|
||||
@@ -36,10 +36,13 @@ PRERELEASES = False
|
||||
|
||||
BULK_UPDATE = False
|
||||
|
||||
NIX = "nix"
|
||||
NIX_PREFETCH_URL = "nix-prefetch-url"
|
||||
NIX_PREFETCH_GIT = "nix-prefetch-git"
|
||||
GIT = "git"
|
||||
|
||||
NIXPKGS_ROOT = (
|
||||
subprocess.check_output(["git", "rev-parse", "--show-toplevel"])
|
||||
subprocess.check_output([GIT, "rev-parse", "--show-toplevel"])
|
||||
.decode("utf-8")
|
||||
.strip()
|
||||
)
|
||||
@@ -79,7 +82,7 @@ def _get_attr_value(attr_path: str) -> Optional[Any]:
|
||||
try:
|
||||
response = subprocess.check_output(
|
||||
[
|
||||
"nix",
|
||||
NIX,
|
||||
"--extra-experimental-features",
|
||||
"nix-command",
|
||||
"eval",
|
||||
@@ -164,7 +167,7 @@ def _hash_to_sri(algorithm, value):
|
||||
return (
|
||||
subprocess.check_output(
|
||||
[
|
||||
"nix",
|
||||
NIX,
|
||||
"--extra-experimental-features",
|
||||
"nix-command",
|
||||
"hash",
|
||||
@@ -260,7 +263,7 @@ def _get_latest_version_github(attr_path, package, extension, current_version, t
|
||||
try:
|
||||
homepage = subprocess.check_output(
|
||||
[
|
||||
"nix",
|
||||
NIX,
|
||||
"--extra-experimental-features",
|
||||
"nix-command",
|
||||
"eval",
|
||||
@@ -301,7 +304,7 @@ def _get_latest_version_github(attr_path, package, extension, current_version, t
|
||||
|
||||
algorithm = "sha256"
|
||||
cmd = [
|
||||
"nix-prefetch-git",
|
||||
NIX_PREFETCH_GIT,
|
||||
f"https://github.com/{owner}/{repo}.git",
|
||||
"--hash",
|
||||
algorithm,
|
||||
@@ -317,7 +320,7 @@ def _get_latest_version_github(attr_path, package, extension, current_version, t
|
||||
hash = (
|
||||
subprocess.check_output(
|
||||
[
|
||||
"nix-prefetch-url",
|
||||
NIX_PREFETCH_URL,
|
||||
"--type",
|
||||
"sha256",
|
||||
"--unpack",
|
||||
@@ -336,7 +339,7 @@ def _get_latest_version_github(attr_path, package, extension, current_version, t
|
||||
try:
|
||||
hash = (
|
||||
subprocess.check_output(
|
||||
["nix-prefetch-url", "--type", "sha256", "--unpack", tag_url],
|
||||
[NIX_PREFETCH_URL, "--type", "sha256", "--unpack", tag_url],
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
.decode("utf-8")
|
||||
|
||||
@@ -49,6 +49,7 @@ let
|
||||
description = "Script used to obtain source hashes for fetch${tool}";
|
||||
maintainers = with maintainers; [ bennofs ];
|
||||
platforms = platforms.unix;
|
||||
mainProgram = "nix-prefetch-${tool}";
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
Reference in New Issue
Block a user