refactor(fetchPipMetadata): split package and script

This commit is contained in:
DavHau 2023-07-09 10:06:10 +02:00
parent a380add69e
commit 19aeff457d
3 changed files with 28 additions and 14 deletions

View File

@ -103,7 +103,10 @@ in {
config = {
deps = {nixpkgs, ...}:
l.mapAttrs (_: l.mkDefault) {
fetchPipMetadata = nixpkgs.callPackage ../../../pkgs/fetchPipMetadata {};
fetchPipMetadataScript = nixpkgs.callPackage ../../../pkgs/fetchPipMetadata {
inherit (cfg) pypiSnapshotDate pipFlags pipVersion requirementsList requirementsFiles nativeBuildInputs;
inherit (config.deps) writePureShellScript python nix git;
};
setuptools = config.deps.python.pkgs.setuptools;
inherit (nixpkgs) git;
inherit (writers) writePureShellScript;
@ -111,10 +114,7 @@ in {
# Keep package metadata fetched by Pip in our lockfile
lock.fields.fetchPipMetadata = {
script = config.deps.fetchPipMetadata {
inherit (cfg) pypiSnapshotDate pipFlags pipVersion requirementsList requirementsFiles nativeBuildInputs;
inherit (config.deps) writePureShellScript python nix git;
};
script = config.deps.fetchPipMetadataScript;
};
pip = {

View File

@ -18,7 +18,6 @@
# The python version select by the user below might be too old for the
# dependencies required by the proxy
python3,
}: {
# Specify the python version for which the packages should be downloaded.
# Pip needs to be executed from that specific python version.
# Pip accepts '--python-version', but this works only for wheel packages.
@ -49,11 +48,8 @@
path = [nix git] ++ nativeBuildInputs;
fetchPipMetadata = python.pkgs.buildPythonPackage {
name = "fetch_pip_metadata";
format = "flit";
src = ./src;
propagatedBuildInputs = with python.pkgs; [packaging certifi python-dateutil pip];
package = import ./package.nix {
inherit lib python;
};
args = writeText "pip-args" (builtins.toJSON {
@ -74,7 +70,10 @@
pipFlags
;
});
script =
writePureShellScript
path
"${package}/bin/fetch_pip_metadata ${args}";
in
writePureShellScript
path
"${fetchPipMetadata}/bin/fetch_pip_metadata ${args}"
script

View File

@ -0,0 +1,15 @@
{
lib,
# Specify the python version for which the packages should be downloaded.
# Pip needs to be executed from that specific python version.
# Pip accepts '--python-version', but this works only for wheel packages.
python,
}: let
package = python.pkgs.buildPythonPackage {
name = "fetch_pip_metadata";
format = "flit";
src = ./src;
propagatedBuildInputs = with python.pkgs; [packaging certifi python-dateutil pip];
};
in
package