about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/audit/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/os-specific/linux/audit/default.nix')
-rw-r--r--pkgs/os-specific/linux/audit/default.nix15
1 files changed, 10 insertions, 5 deletions
diff --git a/pkgs/os-specific/linux/audit/default.nix b/pkgs/os-specific/linux/audit/default.nix
index 9fd24eea6d9b4..e9762f44dcdca 100644
--- a/pkgs/os-specific/linux/audit/default.nix
+++ b/pkgs/os-specific/linux/audit/default.nix
@@ -3,11 +3,13 @@
   runCommand,
   autoreconfHook,
   autoconf, automake, libtool,
-  enablePython ? false, python ? null,
+  # Enabling python support while cross compiling would be possible, but
+  # the configure script tries executing python to gather info instead of
+  # relying on python3-config exclusively
+  enablePython ? stdenv.hostPlatform == stdenv.buildPlatform, python3, swig,
+  linuxHeaders ? stdenv.cc.libc.linuxHeaders
 }:
 
-assert enablePython -> python != null;
-
 stdenv.mkDerivation rec {
   pname = "audit";
   version = "2.8.5"; # at the next release, remove the patches below!
@@ -21,7 +23,7 @@ stdenv.mkDerivation rec {
 
   depsBuildBuild = [ buildPackages.stdenv.cc ];
   nativeBuildInputs = [ autoreconfHook ];
-  buildInputs = lib.optional enablePython python;
+  buildInputs = lib.optionals enablePython [ python3 swig ];
 
   configureFlags = [
     # z/OS plugin is not useful on Linux,
@@ -69,8 +71,11 @@ stdenv.mkDerivation rec {
     })
   ];
 
-  prePatch = ''
+  postPatch = ''
     sed -i 's,#include <sys/poll.h>,#include <poll.h>\n#include <limits.h>,' audisp/audispd.c
+    substituteInPlace bindings/swig/src/auditswig.i \
+      --replace "/usr/include/linux/audit.h" \
+                "${linuxHeaders}/include/linux/audit.h"
   ''
   # According to https://stackoverflow.com/questions/13089166
   # --whole-archive linker flag is required to be sure that linker