1{
2 lib,
3 buildPythonPackage,
4 django,
5 fetchFromGitHub,
6 netaddr,
7 netbox,
8 poetry-core,
9 pythonOlder,
10}:
11
12buildPythonPackage rec {
13 pname = "netbox-plugin-prometheus-sd";
14 version = "1.2.0";
15 pyproject = true;
16
17 disabled = pythonOlder "3.8";
18
19 src = fetchFromGitHub {
20 owner = "FlxPeters";
21 repo = "netbox-plugin-prometheus-sd";
22 tag = "v${version}";
23 hash = "sha256-L5kJnaY9gKpsWAgwkjVRQQauL2qViinqk7rHLXTVzT4=";
24 };
25
26 postPatch = ''
27 substituteInPlace pyproject.toml \
28 --replace-fail 'version = "0.0.0"' 'version = "${version}"'
29 substituteInPlace netbox_prometheus_sd/__init__.py \
30 --replace-fail "from extras.plugins import PluginConfig" "from netbox.plugins import PluginConfig"
31 '';
32
33 build-system = [ poetry-core ];
34
35 dependencies = [
36 django
37 netaddr
38 ];
39
40 nativeCheckInputs = [ netbox ];
41
42 preFixup = ''
43 export PYTHONPATH=${netbox}/opt/netbox/netbox:$PYTHONPATH
44 '';
45
46 pythonImportsCheck = [ "netbox_prometheus_sd" ];
47
48 meta = with lib; {
49 description = "Netbox plugin to provide Netbox entires to Prometheus HTTP service discovery";
50 homepage = "https://github.com/FlxPeters/netbox-plugin-prometheus-sd";
51 changelog = "https://github.com/FlxPeters/netbox-plugin-prometheus-sd/releases/tag/${src.tag}";
52 license = licenses.mit;
53 maintainers = with maintainers; [ xanderio ];
54 };
55}