Python poetry cannot install pynput and python-iptc

Hello,
recently i started to use NixOS. I have python project which use poetry.
When i want to install all dependencies I have problem with pynput and python-iptc.

pynput

I have installed python3 and poetry. In project i create python venv and install packages poetry install --no-root. Poetry starts to install evdev which failed to install due to missing /linux/input.h
i tried to install linuxHeaders but that does not works. I tried to search on forum etc. but i cannot find the solution.
console:

 running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-cpython-311
  creating build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/genecodes.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/ecodes.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/device.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/util.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/eventio_async.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/__init__.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/uinput.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/events.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/eventio.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/evtest.py -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/ff.py -> build/lib.linux-x86_64-cpython-311/evdev
  running egg_info
  writing evdev.egg-info/PKG-INFO
  writing dependency_links to evdev.egg-info/dependency_links.txt
  writing top-level names to evdev.egg-info/top_level.txt
  reading manifest file 'evdev.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no previously-included files found matching 'evdev/ecodes.c'
  adding license file 'LICENSE'
  writing manifest file 'evdev.egg-info/SOURCES.txt'
  copying evdev/input.c -> build/lib.linux-x86_64-cpython-311/evdev
  copying evdev/uinput.c -> build/lib.linux-x86_64-cpython-311/evdev
  running build_ext
  running build_ecodes
  The 'linux/input.h' and 'linux/input-event-codes.h' include files
  are missing. You will have to install the kernel header files in
  order to continue:
  
      dnf install kernel-headers-$(uname -r)
      apt-get install linux-headers-$(uname -r)
      emerge sys-kernel/linux-headers
      pacman -S kernel-headers
  
  In case they are installed in a non-standard location, you may use
  the '--evdev-headers' option to specify one or more colon-separated
  paths. For example:
  
      python setup.py \
        build \
        build_ecodes --evdev-headers path/input.h:path/input-event-codes.h \
        build_ext --include-dirs path/ \
        install

iptc

python package iptc needs iptables to work but i have error about dependency.

iptc.errors.XTablesError: can't find directory with extensions; please set XTABLES_LIBDIR

Thank you all for help.

Did you ever solve this? I also cannot install pynput into a venv because it can’t find the Linux header files (even with linuxHeaders installed).

Does anyone know how to pass the kernel headers path to pip? I’ve tried various combinations of --config-options to pass -I... and build_ecodes.

One solution is to pass in C_INCLUDE_PATH with linux headers to the environment. evdev looks there as seen here python-evdev/setup.py at c4dee7d93e068492d59c5f856cf2129cc11892bc · gvalkov/python-evdev · GitHub

So it can look something like this for a simple shell.nix:

{ pkgs ? import <nixpkgs> {} }:
  pkgs.mkShell {
    packages = with pkgs; [
    python311Full
    linuxHeaders
  ];

  C_INCLUDE_PATH = "${pkgs.linuxHeaders}/include";
}