1{ stdenv, fetchurl, swig ? null, python2 ? null, python3 ? null }:
2
3assert python2 != null || python3 != null -> swig != null;
4
5stdenv.mkDerivation rec {
6 name = "libcap-ng-${version}";
7 # When updating make sure to test that the version with
8 # all of the python bindings still works
9 version = "0.7.8";
10
11 src = fetchurl {
12 url = "${meta.homepage}/${name}.tar.gz";
13 sha256 = "0pyhjxgsph3p28ayk4ynxab6wvzaqmazk1nkamx11m2w8jbzj6n2";
14 };
15
16 nativeBuildInputs = [ swig ];
17 buildInputs = [ python2 python3 ];
18
19 postPatch = ''
20 function get_header() {
21 echo -e "#include <$1>" | gcc -M -xc - | tr ' ' '\n' | grep "$1" | head -n 1
22 }
23
24 # Fix some hardcoding of header paths
25 sed -i "s,/usr/include/linux/capability.h,$(get_header linux/capability.h),g" bindings/python{,3}/Makefile.in
26 '';
27
28 configureFlags = [
29 (if python2 != null then "--with-python" else "--without-python")
30 (if python3 != null then "--with-python3" else "--without-python3")
31 ];
32
33 meta = let inherit (stdenv.lib) platforms licenses maintainers; in {
34 description = "Library for working with POSIX capabilities";
35 homepage = http://people.redhat.com/sgrubb/libcap-ng/;
36 platforms = platforms.linux;
37 license = licenses.lgpl21;
38 maintainers = with maintainers; [ wkennington ];
39 };
40}