diff --git a/pkgs/os-specific/linux/libcap/default.nix b/pkgs/os-specific/linux/libcap/default.nix index 411044c1b925..13d2fb7f5c5a 100644 --- a/pkgs/os-specific/linux/libcap/default.nix +++ b/pkgs/os-specific/linux/libcap/default.nix @@ -1,4 +1,5 @@ -{ stdenv, fetchurl, attr, perl }: +{ stdenv, fetchurl, attr, perl, pam ? null }: +assert pam != null -> stdenv.isLinux; stdenv.mkDerivation rec { name = "libcap-${version}"; @@ -9,19 +10,46 @@ stdenv.mkDerivation rec { sha256 = "0qjiqc5pknaal57453nxcbz3mn1r4hkyywam41wfcglq3v2qlg39"; }; - outputs = [ "dev" "out" ]; + outputs = [ "dev" "lib" "doc" "out" ] + ++ stdenv.lib.optional (pam != null) "pam"; nativeBuildInputs = [ perl ]; + + buildInputs = [ pam ]; + propagatedBuildInputs = [ attr ]; - preConfigure = "cd libcap"; + makeFlags = [ + "lib=lib" + (stdenv.lib.optional (pam != null) "PAM_CAP=yes") + ]; - makeFlags = "lib=lib prefix=$(out)"; + prePatch = '' + # use relative bash path + substituteInPlace progs/capsh.c --replace "/bin/bash" "bash" + + # ensure capsh can find bash in $PATH + substituteInPlace progs/capsh.c --replace execve execvpe + ''; + + preInstall = '' + 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" + ''; + + installFlags = "RAISE_SETFCAP=no"; postInstall = '' - rm "$out"/lib/*.a - mkdir -p "$dev/share/doc/${name}" - cp ../License "$dev/share/doc/${name}/License" + rm "$lib"/lib/*.a + mkdir -p "$doc/share/doc/${name}" + cp License "$doc/share/doc/${name}/" + '' + stdenv.lib.optionalString (pam != null) '' + mkdir -p "$pam/lib/security" + mv "$lib"/lib/security "$pam/lib" ''; meta = { diff --git a/pkgs/os-specific/linux/libcap/man.nix b/pkgs/os-specific/linux/libcap/man.nix deleted file mode 100644 index eeb780f095bd..000000000000 --- a/pkgs/os-specific/linux/libcap/man.nix +++ /dev/null @@ -1,13 +0,0 @@ -{stdenv, libcap}: - -assert stdenv.isLinux; - -stdenv.mkDerivation rec { - name = "libcap-docs-${libcap.version}"; - - inherit (libcap) src; - - makeFlags = "MANDIR=$(out)/share/man"; - - preConfigure = "cd doc"; -} diff --git a/pkgs/os-specific/linux/libcap/pam.nix b/pkgs/os-specific/linux/libcap/pam.nix deleted file mode 100644 index 3dd7cd947af2..000000000000 --- a/pkgs/os-specific/linux/libcap/pam.nix +++ /dev/null @@ -1,15 +0,0 @@ -{stdenv, pam, libcap}: - -assert stdenv.isLinux; - -stdenv.mkDerivation rec { - name = "libcap-pam-${libcap.version}"; - - inherit (libcap) src; - - buildInputs = [ libcap pam ]; - - preConfigure = "cd pam_cap"; - - makeFlags = "${libcap.makeFlags} PAM_CAP=yes"; -} diff --git a/pkgs/os-specific/linux/libcap/progs.nix b/pkgs/os-specific/linux/libcap/progs.nix deleted file mode 100644 index e3871f15f885..000000000000 --- a/pkgs/os-specific/linux/libcap/progs.nix +++ /dev/null @@ -1,28 +0,0 @@ -{stdenv, libcap}: - -assert stdenv.isLinux; - -stdenv.mkDerivation rec { - name = "libcap-progs-${libcap.version}"; - - inherit (libcap) src makeFlags; - - buildInputs = [ libcap ]; - - prePatch = '' - # use relative bash path - substituteInPlace progs/capsh.c --replace "/bin/bash" "bash" - - # ensure capsh can find bash in $PATH - substituteInPlace progs/capsh.c --replace execve execvpe - ''; - - preConfigure = "cd progs"; - - installFlags = "RAISE_SETFCAP=no"; - - postInstall = '' - mkdir -p "$out/share/doc/${name}" - cp ../License "$out/share/doc/${name}/" - ''; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 446501c094b6..911326d023eb 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10913,11 +10913,11 @@ in libcap = callPackage ../os-specific/linux/libcap { }; - libcap_progs = callPackage ../os-specific/linux/libcap/progs.nix { }; + libcap_progs = libcap.out; - libcap_pam = callPackage ../os-specific/linux/libcap/pam.nix { }; + libcap_pam = if stdenv.isLinux then libcap.pam else null; - libcap_manpages = callPackage ../os-specific/linux/libcap/man.nix { }; + libcap_manpages = libcap.doc; libcap_ng = callPackage ../os-specific/linux/libcap-ng { swig = null; # Currently not using the python2/3 bindings