buildPython*: allow stdenv customization through <function>.override
This commit is contained in:
@@ -45,21 +45,42 @@ let
|
||||
override = lib.mirrorFunctionArgs f.override (fdrv: makeOverridablePythonPackage (f.override fdrv));
|
||||
};
|
||||
|
||||
overrideStdenvCompat =
|
||||
f:
|
||||
lib.setFunctionArgs (
|
||||
args:
|
||||
if !(lib.isFunction args) && (args ? stdenv) then
|
||||
# TODO: warn that `args ? stdenv` is deprecated (once in-tree usage is migrated)
|
||||
f.override { stdenv = args.stdenv; } args
|
||||
else
|
||||
f args
|
||||
) (removeAttrs (lib.functionArgs f) [ "stdenv" ])
|
||||
// {
|
||||
# Intentionally drop the effect of overrideStdenvCompat when calling `buildPython*.override`.
|
||||
inherit (f) override;
|
||||
};
|
||||
|
||||
mkPythonDerivation =
|
||||
if python.isPy3k then ./mk-python-derivation.nix else ./python2/mk-python-derivation.nix;
|
||||
|
||||
buildPythonPackage = makeOverridablePythonPackage (
|
||||
callPackage mkPythonDerivation {
|
||||
inherit namePrefix; # We want Python libraries to be named like e.g. "python3.6-${name}"
|
||||
inherit toPythonModule; # Libraries provide modules
|
||||
}
|
||||
overrideStdenvCompat (
|
||||
callPackage mkPythonDerivation {
|
||||
inherit namePrefix; # We want Python libraries to be named like e.g. "python3.6-${name}"
|
||||
inherit toPythonModule; # Libraries provide modules
|
||||
inherit (python) stdenv;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
buildPythonApplication = makeOverridablePythonPackage (
|
||||
callPackage mkPythonDerivation {
|
||||
namePrefix = ""; # Python applications should not have any prefix
|
||||
toPythonModule = x: x; # Application does not provide modules.
|
||||
}
|
||||
overrideStdenvCompat (
|
||||
callPackage mkPythonDerivation {
|
||||
namePrefix = ""; # Python applications should not have any prefix
|
||||
toPythonModule = x: x; # Application does not provide modules.
|
||||
inherit (python) stdenv;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
# Check whether a derivation provides a Python module.
|
||||
|
||||
Reference in New Issue
Block a user