1 { stdenv, lib, buildPackages, fetchurl, runtimeShell
2 , usePam ? !isStatic, pam ? null
3 , isStatic ? stdenv.hostPlatform.isStatic
18 assert usePam -> pam != null;
20 stdenv.mkDerivation rec {
25 url = "mirror://kernel/linux/libs/security/linux-privs/libcap2/${pname}-${version}.tar.xz";
26 sha256 = "sha256-I6bviq2vHj6HX2M7stEWz++JUtunvHxWmxNFjhlSsw8=";
29 outputs = [ "out" "dev" "lib" "man" "doc" ]
30 ++ lib.optional usePam "pam";
32 depsBuildBuild = [ buildPackages.stdenv.cc ];
34 buildInputs = lib.optional usePam pam;
38 "PAM_CAP=${if usePam then "yes" else "no"}"
39 "BUILD_CC=$(CC_FOR_BUILD)"
41 "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
42 ] ++ lib.optionals isStatic [ "SHARED=no" "LIBCSTATIC=yes" ];
45 patchShebangs ./progs/mkcapshdoc.sh
47 # use full path to bash
48 substituteInPlace progs/capsh.c --replace "/bin/bash" "${runtimeShell}"
51 substituteInPlace Make.Rules \
52 --replace 'prefix=/usr' "prefix=$lib" \
53 --replace 'exec_prefix=' "exec_prefix=$out" \
54 --replace 'lib_prefix=$(exec_prefix)' "lib_prefix=$lib" \
55 --replace 'inc_prefix=$(prefix)' "inc_prefix=$dev" \
56 --replace 'man_prefix=$(prefix)' "man_prefix=$doc"
59 installFlags = [ "RAISE_SETFCAP=no" ];
62 ${lib.optionalString (!isStatic) ''rm "$lib"/lib/*.a''}
63 mkdir -p "$doc/share/doc/${pname}-${version}"
64 cp License "$doc/share/doc/${pname}-${version}/"
65 '' + lib.optionalString usePam ''
66 mkdir -p "$pam/lib/security"
67 mv "$lib"/lib/security "$pam/lib"
85 description = "Library for working with POSIX capabilities";
86 homepage = "https://sites.google.com/site/fullycapable";
87 platforms = lib.platforms.linux;
88 license = lib.licenses.bsd3;