Even better, if it’s appropriate, would be to add your package to nixpkgs and use the instructions in Nixpkgs 23.11 manual | Nix & NixOS to build and install locally until the PR is merged.
It seems not to merge. Now every other python35Packages are missing.
environment.systemPackages = with pkgs; [
python35Packages.youtube-dl
];
attribute ‘youtube-dl’ missing, at /root/nixos-config/profiles/desktop.nix:39:5
nixpkgs does some kind of magic with the python packages, so they are available as python35Packages or pypyPackages. It would be great to have that also with the overlay. It probably would get very complex.
The manual says:
Based on the packages defined in pkgs/top-level/python-packages.nix an attribute set is created for each available Python interpreter.
It would be easier to just add it to nixpkgs, but that’s not possible at this point in time. It’s not even on PyPI yet.
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