mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 22:37:18 +03:00
feat(python-pdm): iterate
This commit is contained in:
parent
6b89285dbc
commit
2f9c0c28d9
@ -4,24 +4,33 @@
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
t = lib.types;
|
||||
pyproject-nix = import (dream2nix.inputs.pyproject-nix + "/lib") {inherit lib;};
|
||||
interpreterVersion = config.pythonInterpreter.pythonVersion;
|
||||
libpdm = ./lib.nix {
|
||||
inherit lib libpyproject;
|
||||
};
|
||||
|
||||
libpyproject = import (dream2nix.inputs.pyproject-nix + "/lib") {inherit lib;};
|
||||
|
||||
lock-data = libpdm.parseLockData {
|
||||
lock-data = lib.importTOML config.pdm.lock-file;
|
||||
environ = libpyproject.pep508.mkEnviron config.deps.python3;
|
||||
selector = libpdm.preferWheelSelector;
|
||||
};
|
||||
|
||||
lock-data = lib.importTOML config.pdm.lock-file;
|
||||
pyproject-data = lib.importTOML config.pdm.pyproject;
|
||||
|
||||
pyproject-parsed = pyproject-nix.project.loadPyproject {
|
||||
pyprojectLoaded = libpyproject.project.loadPyproject {
|
||||
pyproject = pyproject-data;
|
||||
};
|
||||
|
||||
build-systems = pyprojectLoaded.build-systems;
|
||||
dependencies = pyprojectLoaded.dependencies;
|
||||
in {
|
||||
imports = [
|
||||
dream2nix.modules.groups
|
||||
dream2nix.modules.dream2nix.groups
|
||||
./interface.nix
|
||||
];
|
||||
pdm.debugData = pyproject-parsed;
|
||||
commonModule = {
|
||||
options.sourceSelector = import ./sourceSeelctorOption.nix {};
|
||||
options.sourceSelector = import ./sourceSelectorOption.nix {};
|
||||
config.sourceSelector = lib.mkOptionDefault config.pdm.sourceSelector;
|
||||
};
|
||||
}
|
||||
|
@ -18,10 +18,6 @@ in {
|
||||
type = t.package;
|
||||
};
|
||||
|
||||
debugData = l.mkOption {
|
||||
type = t.raw;
|
||||
};
|
||||
|
||||
sourceSelector = import ./sourceSelectorOption.nix {inherit lib;};
|
||||
};
|
||||
}
|
||||
|
@ -4,6 +4,14 @@
|
||||
}: rec {
|
||||
getFilename = url: lib.lists.last (lib.splitString "/" url);
|
||||
|
||||
getPdmPackages = {lock-data}:
|
||||
lib.listToAttrs (
|
||||
lib.forEach lock-data.package (
|
||||
pkg:
|
||||
lib.nameValuePair pkg.name pkg
|
||||
)
|
||||
);
|
||||
|
||||
# Convert sources to mapping with filename as key.
|
||||
sourcesToAttrs = sources:
|
||||
lib.listToAttrs (
|
||||
@ -130,7 +138,18 @@
|
||||
isUsableFilename {inherit environ filename;}
|
||||
)
|
||||
sources;
|
||||
evalDep = dep:
|
||||
libpyproject.pep508.evalMarkers
|
||||
environ
|
||||
(libpyproject.pep508.parseString dep);
|
||||
dependencies =
|
||||
map
|
||||
(dep: {
|
||||
inherit (dep) name;
|
||||
})
|
||||
(lib.filter evalDep item.dependencies);
|
||||
value = {
|
||||
inherit dependencies;
|
||||
inherit (item) version;
|
||||
source = sources.${selector (lib.attrNames compatibleSources)};
|
||||
# In the future we could add additional meta data fields
|
||||
|
@ -160,7 +160,8 @@
|
||||
(parsed ? "certifi")
|
||||
&& (parsed.certifi.version == version)
|
||||
&& (parsed.certifi ? source)
|
||||
&& (parsed.certifi.source.url == "https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl");
|
||||
&& (parsed.certifi.source.url == "https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl")
|
||||
&& (parsed.certifi.dependencies == []);
|
||||
expected = true;
|
||||
};
|
||||
};
|
||||
|
@ -24,8 +24,7 @@ in {
|
||||
# groups.my-group.packages.hello = {...}: fixtures.basic-derivation;
|
||||
};
|
||||
in {
|
||||
expr = true;
|
||||
# expr = config.groups.my-group.public.hello ? drvPath;
|
||||
expr = config.groups.default.public.certifi ? drvPath;
|
||||
expected = true;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user