nixpkgs-suyu/pkgs/os-specific/linux/libcap/default.nix

65 lines
1.8 KiB
Nix
Raw Normal View History

2021-04-11 02:30:44 +02:00
{ stdenv, lib, buildPackages, fetchurl, attr, perl, runtimeShell
, usePam ? !isStatic, pam ? null
, isStatic ? stdenv.hostPlatform.isStatic
}:
assert usePam -> pam != null;
stdenv.mkDerivation rec {
pname = "libcap";
2021-04-29 22:31:41 +02:00
version = "2.49";
2013-08-23 09:55:51 +02:00
src = fetchurl {
url = "mirror://kernel/linux/libs/security/linux-privs/libcap2/${pname}-${version}.tar.xz";
2021-04-29 22:31:41 +02:00
sha256 = "sha256-6YvE2TZFCC7Hh3MLD9GnErOIgkZcUFd33hfDOIMe4YE=";
};
2013-08-23 09:55:51 +02:00
outputs = [ "out" "dev" "lib" "man" "doc" ]
++ lib.optional usePam "pam";
2013-08-23 09:55:51 +02:00
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ perl ];
buildInputs = lib.optional usePam pam;
propagatedBuildInputs = [ attr ];
makeFlags = [
"lib=lib"
"PAM_CAP=${if usePam then "yes" else "no"}"
"BUILD_CC=$(CC_FOR_BUILD)"
"CC:=$(CC)"
] ++ lib.optional isStatic "SHARED=no";
prePatch = ''
2021-01-12 09:23:32 +01:00
# use full path to bash
2021-04-11 02:30:44 +02:00
substituteInPlace progs/capsh.c --replace "/bin/bash" "${runtimeShell}"
# set prefixes
substituteInPlace Make.Rules \
--replace 'prefix=/usr' "prefix=$lib" \
--replace 'exec_prefix=' "exec_prefix=$out" \
--replace 'lib_prefix=$(exec_prefix)' "lib_prefix=$lib" \
--replace 'inc_prefix=$(prefix)' "inc_prefix=$dev" \
--replace 'man_prefix=$(prefix)' "man_prefix=$doc"
'';
2019-11-05 02:10:31 +01:00
installFlags = [ "RAISE_SETFCAP=no" ];
2014-08-27 01:14:09 +02:00
postInstall = ''
${lib.optionalString (!isStatic) ''rm "$lib"/lib/*.a''}
mkdir -p "$doc/share/doc/${pname}-${version}"
cp License "$doc/share/doc/${pname}-${version}/"
2021-01-15 15:45:37 +01:00
'' + lib.optionalString usePam ''
mkdir -p "$pam/lib/security"
mv "$lib"/lib/security "$pam/lib"
2014-08-27 01:14:09 +02:00
'';
meta = {
description = "Library for working with POSIX capabilities";
homepage = "https://sites.google.com/site/fullycapable";
2021-01-15 15:45:37 +01:00
platforms = lib.platforms.linux;
license = lib.licenses.bsd3;
};
}