1{ stdenv, fetchurl, pam ? null, glibcCross ? null }:
2
3let
4
5 glibc =
6 if stdenv ? cross
7 then glibcCross
8 else assert stdenv ? glibc; stdenv.glibc;
9
10 dots_in_usernames = fetchurl {
11 url = http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/shadow/files/shadow-4.1.3-dots-in-usernames.patch;
12 sha256 = "1fj3rg6x3jppm5jvi9y7fhd2djbi4nc5pgwisw00xlh4qapgz692";
13 };
14
15in
16
17stdenv.mkDerivation rec {
18 name = "shadow-4.2.1";
19
20 src = fetchurl {
21 url = "http://pkg-shadow.alioth.debian.org/releases/${name}.tar.xz";
22 sha256 = "0h9x1zdbq0pqmygmc1x459jraiqw4gqz8849v268crk78z8r621v";
23 };
24
25 buildInputs = stdenv.lib.optional (pam != null && stdenv.isLinux) pam;
26
27 patches = [ ./keep-path.patch dots_in_usernames ];
28
29 outputs = [ "out" "su" ];
30
31 # Assume System V `setpgrp (void)', which is the default on GNU variants
32 # (`AC_FUNC_SETPGRP' is not cross-compilation capable.)
33 preConfigure = ''
34 export ac_cv_func_setpgrp_void=yes
35 export shadow_cv_logdir=/var/log
36 '';
37
38 preBuild = assert glibc != null;
39 ''
40 substituteInPlace lib/nscd.c --replace /usr/sbin/nscd ${glibc.bin}/bin/nscd
41 '';
42
43 postInstall =
44 ''
45 # Don't install ‘groups’, since coreutils already provides it.
46 rm $out/bin/groups $out/share/man/man1/groups.*
47
48 # Move the su binary into the su package
49 mkdir -p $su/bin
50 mv $out/bin/su $su/bin
51 '';
52
53 meta = {
54 homepage = http://pkg-shadow.alioth.debian.org/;
55 description = "Suite containing authentication-related tools such as passwd and su";
56 platforms = stdenv.lib.platforms.linux;
57 };
58
59 passthru = {
60 shellPath = "/bin/nologin";
61 };
62}