1{ lib
2, stdenv
3, fetchurl
4, fetchpatch
5, autoreconfHook
6, bash
7, buildPackages
8, linuxHeaders
9, python3
10, swig
11, pkgsCross
12
13# Enabling python support while cross compiling would be possible, but the
14# configure script tries executing python to gather info instead of relying on
15# python3-config exclusively
16, enablePython ? stdenv.hostPlatform == stdenv.buildPlatform,
17}:
18
19stdenv.mkDerivation (finalAttrs: {
20 pname = "audit";
21 version = "4.0";
22
23 src = fetchurl {
24 url = "https://people.redhat.com/sgrubb/audit/audit-${finalAttrs.version}.tar.gz";
25 hash = "sha256-v0ItQSard6kqTDrDneVHPyeNw941ck0lGKSMe+FdVNg=";
26 };
27
28 patches = [
29 (fetchpatch {
30 name = "musl.patch";
31 url = "https://github.com/linux-audit/audit-userspace/commit/64cb48e1e5137b8a389c7528e611617a98389bc7.patch";
32 hash = "sha256-DN2F5w+2Llm80FZntH9dvdyT00pVBSgRu8DDFILyrlU=";
33 })
34 (fetchpatch {
35 name = "musl.patch";
36 url = "https://github.com/linux-audit/audit-userspace/commit/4192eb960388458c85d76e5e385cfeef48f02c79.patch";
37 hash = "sha256-G6CJ9nBJSsTyJ0qq14PVo+YdInAvLLQtXcR25Q8V5/4=";
38 })
39 ];
40
41 postPatch = ''
42 substituteInPlace bindings/swig/src/auditswig.i \
43 --replace "/usr/include/linux/audit.h" \
44 "${linuxHeaders}/include/linux/audit.h"
45 '';
46
47 outputs = [ "bin" "dev" "out" "man" ];
48
49 strictDeps = true;
50
51 depsBuildBuild = [
52 buildPackages.stdenv.cc
53 ];
54
55 nativeBuildInputs = [
56 autoreconfHook
57 ]
58 ++ lib.optionals enablePython [
59 python3
60 swig
61 ];
62
63 buildInputs = [
64 bash
65 ];
66
67 configureFlags = [
68 # z/OS plugin is not useful on Linux, and pulls in an extra openldap
69 # dependency otherwise
70 "--disable-zos-remote"
71 "--with-arm"
72 "--with-aarch64"
73 (if enablePython then "--with-python" else "--without-python")
74 ];
75
76 enableParallelBuilding = true;
77
78 passthru.tests = {
79 musl = pkgsCross.musl64.audit;
80 };
81
82 meta = {
83 homepage = "https://people.redhat.com/sgrubb/audit/";
84 description = "Audit Library";
85 changelog = "https://github.com/linux-audit/audit-userspace/releases/tag/v${finalAttrs.version}";
86 license = lib.licenses.gpl2Plus;
87 maintainers = with lib.maintainers; [ AndersonTorres ];
88 platforms = lib.platforms.linux;
89 };
90})