Unfortunately, it’s a bit complicated.
Here’s a full example that shows how to extend pythonPackages with a custom package for various python versions.
nix-build --no-out-link - <<'EOF'
let
overlay = (self: super:
let
myOverride = {
packageOverrides = self: super: {
inotify_simple = super.buildPythonPackage rec {
pname = "inotify_simple";
version = "1.1.7";
doCheck = false;
src = super.fetchPypi {
inherit pname version;
sha256 = "1jvivp84cyp4x4rsw4g6bzbzqka7gaqhk4k4jqifyxnqqmbdgvcq";
};
};
};
};
in {
# Add an override for each required python version.
# There’s currently no way to add a package that’s automatically picked up by
# all python versions, besides editing python-packages.nix
python2 = super.python2.override myOverride;
python3 = super.python3.override myOverride;
python35 = super.python35.override myOverride;
}
);
pkgs = import <nixpkgs> { overlays = [ overlay ]; };
in
with pkgs; [
pythonPackages.inotify_simple
python3Packages.inotify_simple
python35Packages.inotify_simple
]
EOF