mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-23 06:21:30 +03:00
feat: allow specifying env for fetchPipMetadata
This helps for configuring pip with environment variables. See https://github.com/nix-community/dream2nix/discussions/697 for more context. pip: remove callPackage
This commit is contained in:
parent
4c0d029add
commit
cf853080a3
@ -122,7 +122,7 @@ in {
|
||||
# with the intention to keep modules independent.
|
||||
fetchPipMetadataScript = import ../../../pkgs/fetchPipMetadata/script.nix {
|
||||
inherit lib;
|
||||
inherit (cfg) pypiSnapshotDate pipFlags pipVersion requirementsList requirementsFiles nativeBuildInputs;
|
||||
inherit (cfg) env pypiSnapshotDate pipFlags pipVersion requirementsList requirementsFiles nativeBuildInputs;
|
||||
inherit (config.deps) writePureShellScript nix;
|
||||
inherit (config.paths) findRoot;
|
||||
inherit (nixpkgs) gitMinimal nix-prefetch-scripts python3 writeText;
|
||||
@ -141,7 +141,8 @@ in {
|
||||
# if any of the invalidationData changes, the lock file will be invalidated
|
||||
# and the user will be promted to re-generate it.
|
||||
lock.invalidationData = {
|
||||
pip = {
|
||||
pip =
|
||||
{
|
||||
inherit
|
||||
(config.pip)
|
||||
pypiSnapshotDate
|
||||
@ -152,7 +153,10 @@ in {
|
||||
;
|
||||
# don't invalidate on bugfix version changes
|
||||
pythonVersion = lib.init (lib.splitVersion config.deps.python.version);
|
||||
};
|
||||
}
|
||||
# including env conditionally to not invalidate all existing lockfiles
|
||||
# TODO: refactor once compat is broken through something else
|
||||
// (lib.optionalAttrs (config.pip.env != {}) config.pip.env);
|
||||
};
|
||||
|
||||
pip = {
|
||||
|
@ -22,6 +22,18 @@ in {
|
||||
};
|
||||
|
||||
# user interface
|
||||
env = l.mkOption {
|
||||
type = t.attrsOf t.str;
|
||||
default = {};
|
||||
description = ''
|
||||
environment variables exported while locking
|
||||
'';
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
PIP_FIND_LINKS = "${config.deps.setuptools.dist}";
|
||||
}
|
||||
'';
|
||||
};
|
||||
pypiSnapshotDate = l.mkOption {
|
||||
type = t.nullOr t.str;
|
||||
description = ''
|
||||
|
@ -26,6 +26,7 @@
|
||||
requirementsFiles ? [],
|
||||
pipFlags ? [],
|
||||
pipVersion ? "23.1",
|
||||
env ? {},
|
||||
wheelVersion ? "0.40.0",
|
||||
nativeBuildInputs ? [],
|
||||
# maximum release date for packages
|
||||
@ -86,6 +87,12 @@
|
||||
writePureShellScript
|
||||
path
|
||||
''
|
||||
${
|
||||
lib.foldlAttrs
|
||||
(acc: name: value: acc + "\nexport " + lib.toShellVar name value)
|
||||
""
|
||||
env
|
||||
}
|
||||
${package}/bin/fetch_pip_metadata \
|
||||
--json-args-file ${args} \
|
||||
--project-root $(${findRoot})
|
||||
|
Loading…
Reference in New Issue
Block a user