1{ lib, stdenv, fetchurl, fetchpatch, flex }:
2
3stdenv.mkDerivation rec {
4 pname = "libsepol";
5 version = "3.5";
6 se_url = "https://github.com/SELinuxProject/selinux/releases/download";
7
8 outputs = [ "bin" "out" "dev" "man" ];
9
10 src = fetchurl {
11 url = "${se_url}/${version}/libsepol-${version}.tar.gz";
12 sha256 = "sha256-eP2vaZJNt4C6x4VG5D2cRAdLrXmMLEFdC5u5bQZe6KI=";
13 };
14
15 postPatch = lib.optionalString stdenv.hostPlatform.isStatic ''
16 substituteInPlace src/Makefile --replace 'all: $(LIBA) $(LIBSO)' 'all: $(LIBA)'
17 sed -i $'/^\t.*LIBSO/d' src/Makefile
18 '';
19
20 nativeBuildInputs = [ flex ];
21
22 makeFlags = [
23 "PREFIX=$(out)"
24 "BINDIR=$(bin)/bin"
25 "INCDIR=$(dev)/include/sepol"
26 "INCLUDEDIR=$(dev)/include"
27 "MAN3DIR=$(man)/share/man/man3"
28 "MAN8DIR=$(man)/share/man/man8"
29 "SHLIBDIR=$(out)/lib"
30 ];
31
32 env.NIX_CFLAGS_COMPILE = "-Wno-error";
33
34 enableParallelBuilding = true;
35
36 passthru = { inherit se_url; };
37
38 meta = with lib; {
39 description = "SELinux binary policy manipulation library";
40 homepage = "http://userspace.selinuxproject.org";
41 platforms = platforms.linux;
42 maintainers = [ ];
43 license = lib.licenses.gpl2Plus;
44 pkgConfigModules = [ "libselinux" ];
45 };
46}