nftables: split python package from main

Starting nftables 1.0.9, the python bindings are no longer built and
installed by the autotools build system and instead must be installed
manually.

Co-authored-by: ajs124 <ajs124@users.noreply.github.com>
This commit is contained in:
Leorize 2023-12-22 19:53:29 +00:00
parent 85299b755e
commit e95a228693
No known key found for this signature in database
GPG Key ID: EF09488EEE4CE244
3 changed files with 32 additions and 19 deletions

@ -5,7 +5,6 @@
, autoreconfHook
, withDebugSymbols ? false
, withCli ? true, libedit
, withPython ? false, python3
, withXtables ? true, iptables
, nixosTests
}:
@ -29,25 +28,12 @@ stdenv.mkDerivation rec {
libmnl libnftnl libpcap
gmp jansson
] ++ lib.optional withCli libedit
++ lib.optional withXtables iptables
++ lib.optionals withPython [
python3
python3.pkgs.setuptools
];
patches = [ ./fix-py-libnftables.patch ];
postPatch = ''
substituteInPlace "py/src/nftables.py" \
--subst-var-by "out" "$out"
'';
++ lib.optional withXtables iptables;
configureFlags = [
"--with-json"
(lib.withFeatureAs withCli "cli" "editline")
] ++ lib.optional (!withDebugSymbols) "--disable-debug"
++ lib.optional (!withPython) "--disable-python"
++ lib.optional withPython "--enable-python"
++ lib.optional withXtables "--with-xtables";
passthru.tests = {

@ -0,0 +1,28 @@
{ lib
, buildPythonPackage
, setuptools
, nftables
}:
buildPythonPackage {
pname = "nftables";
inherit (nftables) version src;
pyproject = true;
patches = [ ./fix-py-libnftables.patch ];
postPatch = ''
substituteInPlace "py/src/nftables.py" \
--subst-var-by "out" "${nftables}"
'';
setSourceRoot = "sourceRoot=$(echo */py)";
build-system = [ setuptools ];
pythonImportsCheck = [ "nftables" ];
meta = {
inherit (nftables.meta) description homepage license platforms maintainers;
};
}

@ -8639,10 +8639,9 @@ self: super: with self; {
nfcpy = callPackage ../development/python-modules/nfcpy { };
nftables = toPythonModule (pkgs.nftables.override {
python3 = python;
withPython = true;
});
nftables = callPackage ../os-specific/linux/nftables/python.nix {
inherit (pkgs) nftables;
};
nh3 = callPackage ../development/python-modules/nh3 { };