From e95a228693d2d60afa4715bb12945af092553705 Mon Sep 17 00:00:00 2001 From: Leorize Date: Fri, 22 Dec 2023 19:53:29 +0000 Subject: [PATCH] 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 --- pkgs/os-specific/linux/nftables/default.nix | 16 +----------- pkgs/os-specific/linux/nftables/python.nix | 28 +++++++++++++++++++++ pkgs/top-level/python-packages.nix | 7 +++--- 3 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 pkgs/os-specific/linux/nftables/python.nix 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 { };