mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 22:37:18 +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.
|
# with the intention to keep modules independent.
|
||||||
fetchPipMetadataScript = import ../../../pkgs/fetchPipMetadata/script.nix {
|
fetchPipMetadataScript = import ../../../pkgs/fetchPipMetadata/script.nix {
|
||||||
inherit lib;
|
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.deps) writePureShellScript nix;
|
||||||
inherit (config.paths) findRoot;
|
inherit (config.paths) findRoot;
|
||||||
inherit (nixpkgs) gitMinimal nix-prefetch-scripts python3 writeText;
|
inherit (nixpkgs) gitMinimal nix-prefetch-scripts python3 writeText;
|
||||||
@ -141,18 +141,22 @@ in {
|
|||||||
# if any of the invalidationData changes, the lock file will be invalidated
|
# if any of the invalidationData changes, the lock file will be invalidated
|
||||||
# and the user will be promted to re-generate it.
|
# and the user will be promted to re-generate it.
|
||||||
lock.invalidationData = {
|
lock.invalidationData = {
|
||||||
pip = {
|
pip =
|
||||||
inherit
|
{
|
||||||
(config.pip)
|
inherit
|
||||||
pypiSnapshotDate
|
(config.pip)
|
||||||
pipFlags
|
pypiSnapshotDate
|
||||||
pipVersion
|
pipFlags
|
||||||
requirementsList
|
pipVersion
|
||||||
requirementsFiles
|
requirementsList
|
||||||
;
|
requirementsFiles
|
||||||
# don't invalidate on bugfix version changes
|
;
|
||||||
pythonVersion = lib.init (lib.splitVersion config.deps.python.version);
|
# 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 = {
|
pip = {
|
||||||
|
@ -22,6 +22,18 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
# user interface
|
# 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 {
|
pypiSnapshotDate = l.mkOption {
|
||||||
type = t.nullOr t.str;
|
type = t.nullOr t.str;
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
requirementsFiles ? [],
|
requirementsFiles ? [],
|
||||||
pipFlags ? [],
|
pipFlags ? [],
|
||||||
pipVersion ? "23.1",
|
pipVersion ? "23.1",
|
||||||
|
env ? {},
|
||||||
wheelVersion ? "0.40.0",
|
wheelVersion ? "0.40.0",
|
||||||
nativeBuildInputs ? [],
|
nativeBuildInputs ? [],
|
||||||
# maximum release date for packages
|
# maximum release date for packages
|
||||||
@ -86,6 +87,12 @@
|
|||||||
writePureShellScript
|
writePureShellScript
|
||||||
path
|
path
|
||||||
''
|
''
|
||||||
|
${
|
||||||
|
lib.foldlAttrs
|
||||||
|
(acc: name: value: acc + "\nexport " + lib.toShellVar name value)
|
||||||
|
""
|
||||||
|
env
|
||||||
|
}
|
||||||
${package}/bin/fetch_pip_metadata \
|
${package}/bin/fetch_pip_metadata \
|
||||||
--json-args-file ${args} \
|
--json-args-file ${args} \
|
||||||
--project-root $(${findRoot})
|
--project-root $(${findRoot})
|
||||||
|
Loading…
Reference in New Issue
Block a user