diff --git a/pkgs/os-specific/linux/nftables/default.nix b/pkgs/os-specific/linux/nftables/default.nix index 3680cd43efb7..95e4183a2fb6 100644 --- a/pkgs/os-specific/linux/nftables/default.nix +++ b/pkgs/os-specific/linux/nftables/default.nix @@ -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 = { diff --git a/pkgs/os-specific/linux/nftables/python.nix b/pkgs/os-specific/linux/nftables/python.nix new file mode 100644 index 000000000000..ea50e270d086 --- /dev/null +++ b/pkgs/os-specific/linux/nftables/python.nix @@ -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; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index be2d5d24819a..9fde774e3bba 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -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 { };