about summary refs log tree commit diff
path: root/pkgs/by-name/eb/ebpf-usb/package.nix
blob: 42a6956a34b1866459fc58df60dac05c51d0e7c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{ lib
, fetchFromGitHub
, python3Packages
, bcc
}:

python3Packages.buildPythonApplication rec {
  pname = "ebpf-usb";
  version = "unstable-2022-04-03";
  pyproject = false;

  src = fetchFromGitHub {
    owner = "francisrstokes";
    repo = "ebpf-usb";
    rev = "3ab6f0d8c6ece51bbb5cc5e05daa4008eccd70e8";
    hash = "sha256-n3ttFej9sroTqAOgyAejwKT+aMt/z7HlVPV6CVGPNUQ=";
  };

  makeWrapperArgs = [
    "--set PYTHONUNBUFFERED 1"
  ];

  pythonPath = [ bcc ] ++ (with python3Packages; [
    hexdump
  ]);

  postPatch = ''
    substituteInPlace ebpf-usb.py \
      --replace '#!/usr/bin/env -S python3 -u' '#!/usr/bin/env python3'
  '';

  installPhase = ''
    runHook preInstall
    install -Dm755 ebpf-usb.py $out/bin/ebpf-usb
    runHook postInstall
  '';

  # no tests
  doCheck = false;

  meta = with lib; {
    description = "Python script for USB monitoring using eBPF";
    homepage = "https://github.com/francisrstokes/ebpf-usb";
    license = lib.licenses.unfree;
    maintainers = with maintainers; [ mevatron ];
    mainProgram = "ebpf-usb";
  };
}