I’m trying to package a handy python program ebpf-usb to monitor USB device outputs, but it uses the bcc package as a dependency. I have hacky version of a derivation working that looks like so:
{ lib
, fetchFromGitHub
, python3Packages
, bcc
, makeWrapper
}:
python3Packages.buildPythonApplication rec {
pname = "ebpf-usb";
version = "unstable-2022-04-03";
format = "other";
src = fetchFromGitHub {
owner = "francisrstokes";
repo = "ebpf-usb";
rev = "3ab6f0d8c6ece51bbb5cc5e05daa4008eccd70e8";
sha256 = "n3ttFej9sroTqAOgyAejwKT+aMt/z7HlVPV6CVGPNUQ=";
};
nativeBuildInputs = [ bcc makeWrapper ];
propagatedBuildInputs = with python3Packages; [
hexdump
];
# Disable the build phase as there is no setup.py in this project
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
cp ebpf-usb.py $out/bin/ebpf-usb
chmod +x $out/bin/ebpf-usb
BCC_SITE_PACKAGES=${bcc}/lib/python3.11/site-packages/bcc-0.28.0-py3.11.egg
wrapProgram $out/bin/ebpf-usb \
--prefix PYTHONPATH : $PYTHONPATH:$BCC_SITE_PACKAGES
'';
# no tests
doCheck = false;
meta = with lib; {
description = "A Python script for USB monitoring using eBPF";
homepage = "https://github.com/francisrstokes/ebpf-usb";
maintainers = with maintainers; [ mevatron ];
mainProgram = "ebpf-usb";
};
}
This hack seems kinda brittle:
BCC_SITE_PACKAGES=${bcc}/lib/python3.11/site-packages/bcc-0.28.0-py3.11.egg
wrapProgram $out/bin/ebpf-usb \
--prefix PYTHONPATH : $PYTHONPATH:$BCC_SITE_PACKAGES
Is there a better way to wrap this python program to use the bcc package’s python egg file?
Also, if a project doesn’t specify a license, is the proper meta entry to not specify a license?
Thanks for any tips!