13 python3Packages ? null,
17 assert enablePython -> swig != null && python3 != null;
23 inherit (libsepol) se_url;
30 ] ++ lib.optional enablePython "py";
33 url = "${se_url}/${version}/libselinux-${version}.tar.gz";
34 hash = "sha256-6gP0LROk+VdXmX26jPCyYyH6xdLxZEGLTMhWqS0rF70=";
38 # Make it possible to disable shared builds (for pkgsStatic).
40 # We can't use fetchpatch because it processes includes/excludes
41 # /after/ stripping the prefix, which wouldn't work here because
42 # there would be no way to distinguish between
43 # e.g. libselinux/src/Makefile and libsepol/src/Makefile.
45 # This is a static email, so we shouldn't have to worry about
46 # normalizing the patch.
48 url = "https://lore.kernel.org/selinux/20211113141616.361640-1-hi@alyssa.is/raw";
49 hash = "sha256-dqxiupaJK4o00YERGWGIEIhM7sPelxBFQomAFKXQQpk=";
51 mv "$out" $TMPDIR/patch
52 ${buildPackages.patchutils_0_3_3}/bin/filterdiff \
53 -i 'a/libselinux/*' --strip 1 <$TMPDIR/patch >"$out"
58 url = "https://git.yoctoproject.org/meta-selinux/plain/recipes-security/selinux/libselinux/0003-libselinux-restore-drop-the-obsolete-LSF-transitiona.patch?id=62b9c816a5000dc01b28e78213bde26b58cbca9d";
59 hash = "sha256-RiEUibLVzfiRU6N/J187Cs1iPAih87gCZrlyRVI2abU=";
62 # libselinux: fix swig bindings for 4.3.0
64 url = "https://github.com/SELinuxProject/selinux/commit/8e0e718bae53fff30831b92cd784151d475a20da.patch";
66 hash = "sha256-8Nd6ketQ7/r5W0sRdheqyGWHJRZ1RfGC4ehTqnHau04=";
75 ++ lib.optionals enablePython [
77 python3Packages.setuptools
85 ] ++ lib.optionals enablePython [ python3 ];
87 # drop fortify here since package uses it by default, leading to compile error:
88 # command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
89 hardeningDisable = [ "fortify" ];
91 env.NIX_CFLAGS_COMPILE = "-Wno-error -D_FILE_OFFSET_BITS=64";
96 "INCDIR=$(dev)/include/selinux"
97 "INCLUDEDIR=$(dev)/include"
98 "MAN3DIR=$(man)/share/man/man3"
99 "MAN5DIR=$(man)/share/man/man5"
100 "MAN8DIR=$(man)/share/man/man8"
101 "SBINDIR=$(bin)/sbin"
102 "SHLIBDIR=$(out)/lib"
104 "LIBSEPOLA=${lib.getLib libsepol}/lib/libsepol.a"
105 "ARCH=${stdenv.hostPlatform.linuxArch}"
107 ++ lib.optionals (fts != null) [
110 ++ lib.optionals stdenv.hostPlatform.isStatic [
113 ++ lib.optionals enablePython [
114 "PYTHON=${python3.pythonOnBuildForHost.interpreter}"
115 "PYTHONLIBDIR=$(py)/${python3.sitePackages}"
116 "PYTHON_SETUP_ARGS=--no-build-isolation"
119 preInstall = lib.optionalString enablePython ''
120 mkdir -p $py/${python3.sitePackages}/selinux
123 installTargets = [ "install" ] ++ lib.optional enablePython "install-pywrap";
125 meta = removeAttrs libsepol.meta [ "outputsToInstall" ] // {
126 description = "SELinux core library";
130 lib.optionalAttrs (stdenv.cc.bintools.isLLVM && lib.versionAtLeast stdenv.cc.bintools.version "17")
132 NIX_LDFLAGS = "--undefined-version";