It seems that when I override a python3 package in nixpkgs.config.packageOverrides
or nixpkgs.overlays
, a python application in environment.systemPackages
is not using those overrides. How can I get that overridden python3 package to be used in a python3 application?
Example darwin-configuration.nix that uses nixpkgs.overlays
:
{ config, pkgs, lib, ... }:
{
environment.systemPackages =
[
pkgs.myawscli2
];
nixpkgs.overlays = let overlayRemovePyopenssl = self: super:
let removePyopenssl = pythonpkgs:
lib.filter
(pythonpkg: !(pythonpkg != null && pythonpkg ? pname && pythonpkg.pname == "pyopenssl"))
pythonpkgs;
in {
python3 = super.python3.override {
packageOverrides = python-self: python-super: rec {
# Delete pyopenssl; workaround for broken package on darwin-aarch64
# “Package ‘python3.10-pyopenssl-22.0.0’ in /nix/store/<hash>-nixpkgs/nixpkgs/pkgs/development/python-modules/pyopenssl/default.nix:73 is marked as broken, refusing to evaluate”
# https://github.com/NixOS/nixpkgs/issues/174457
urllib3 = python-super.urllib3.overridePythonAttrs (origattrs: rec {
propagatedBuildInputs = removePyopenssl origattrs.propagatedBuildInputs;
});
twisted = python-super.twisted.overridePythonAttrs (origattrs: {
checkInputs = removePyopenssl origattrs.checkInputs;
});
};
};
myawscli2 = (self.awscli2.override {
# override the python3 arg of awscli2
# https://github.com/NixOS/nixpkgs/blob/f72be3af76fb7dc45e2088d8cb9aba1e6767a930/pkgs/tools/admin/awscli2/default.nix#L2
python3 = self.python3;
});
}; in
[
overlayRemovePyopenssl
];
system.stateVersion = 4;
}
The overlay is applied properly in the individual python package urllib3:
nix-repl> lib = import <nixpkgs>.lib
nix-repl> :l <darwin>
nix-repl> lib.forEach pkgs.python3.pkgs.urllib3.propagatedBuildInputs (x: x.pname)
[ "brotli" "certifi" "cryptography" "idna" "python3" ]
However, the overlay was not applied to the python application that uses urllib3. Note that pyopenssl is in the dependencies of urllib3 when used by awscli2:
nix-repl> lib.forEach (lib.findFirst (x: x.pname == "urllib3") null pkgs.awscli2.propagatedBuildInputs).propagatedBuildInputs (x: x.pname)
[ "brotli" "certifi" "cryptography" "idna" "pyopenssl" "python3" ]
I also tried the same thing with nixpkgs.config.packageOverrides
with the same effect:
{ config, pkgs, lib, ... }:
{
environment.systemPackages =
[
pkgs.myawscli2
];
nixpkgs.config.packageOverrides = super:
let removePyopenssl = pythonpkgs:
lib.filter
(pythonpkg: !(pythonpkg != null && lib.hasAttr "pname" pythonpkg && pythonpkg.pname == "pyopenssl"))
pythonpkgs;
in {
python3 = super.python3.override {
packageOverrides = python-self: python-super: rec {
# workaround for
# “Package ‘python3.10-pyopenssl-22.0.0’ in /nix/store/<hash>-nixpkgs/nixpkgs/pkgs/development/python-modules/pyopenssl/default.nix:73 is marked as broken, refusing to evaluate”
# https://github.com/NixOS/nixpkgs/issues/174457
urllib3 = python-super.urllib3.overridePythonAttrs (origattrs: rec {
propagatedBuildInputs = removePyopenssl origattrs.propagatedBuildInputs;
});
twisted = python-super.twisted.overridePythonAttrs (origattrs: {
checkInputs = removePyopenssl origattrs.checkInputs;
});
};
};
myawscli2 = (pkgs.awscli2.override {
python3 = pkgs.python3;
});
};
system.stateVersion = 4;
}
This seems to contradict the nixpkgs manual, which says: “pythonPackages.twisted
is now globally overridden. All packages and also all NixOS services that reference twisted
(such as services.buildbot-worker
) now use the new definition”