1 { lib, stdenv, fetchFromGitHub
2 , runtimeShell, nixosTests
3 , autoreconfHook, bison, flex
4 , docbook_xml_dtd_45, docbook_xsl
5 , itstool, libbsd, libxml2, libxslt
6 , libxcrypt, pkg-config
9 , withTcb ? lib.meta.availableOn stdenv.hostPlatform tcb, tcb
13 if stdenv.hostPlatform != stdenv.buildPlatform then glibcCross
14 else assert stdenv.hostPlatform.libc == "glibc"; stdenv.cc.libc;
18 stdenv.mkDerivation rec {
22 src = fetchFromGitHub {
23 owner = "shadow-maint";
26 hash = "sha256-GAwwpyIN5qWSIapjGFfOxPbOx5G6//fEbTpPmkXh6uA=";
29 outputs = [ "out" "su" "dev" "man" ];
31 RUNTIME_SHELL = runtimeShell;
34 autoreconfHook bison flex
35 docbook_xml_dtd_45 docbook_xsl
36 itstool libxml2 libxslt
40 buildInputs = [ libbsd libxcrypt ]
41 ++ lib.optional (pam != null && stdenv.isLinux) pam
42 ++ lib.optional withTcb tcb;
46 # Obtain XML resources from XML catalog (patch adapted from gtk-doc)
47 ./respect-xml-catalog-files-var.patch
49 ./fix-install-with-tcb.patch
52 # The nix daemon often forbids even creating set[ug]id files.
54 sed 's/^\(s[ug]idperms\) = [0-9]755/\1 = 0755/' -i src/Makefile.am
57 # Assume System V `setpgrp (void)', which is the default on GNU variants
58 # (`AC_FUNC_SETPGRP' is not cross-compilation capable.)
60 export ac_cv_func_setpgrp_void=yes
61 export shadow_cv_logdir=/var/log
66 "--with-group-name-max-length=32"
69 ] ++ lib.optional (stdenv.hostPlatform.libc != "glibc") "--disable-nscd"
70 ++ lib.optional withTcb "--with-tcb";
72 preBuild = lib.optionalString (stdenv.hostPlatform.libc == "glibc") ''
73 substituteInPlace lib/nscd.c --replace /usr/sbin/nscd ${glibc.bin}/bin/nscd
77 # Don't install ‘groups’, since coreutils already provides it.
79 rm $man/share/man/man1/groups.*
81 # Move the su binary into the su package
83 mv $out/bin/su $su/bin
86 enableParallelBuilding = true;
88 disallowedReferences = lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) stdenv.shellPackage;
91 homepage = "https://github.com/shadow-maint";
92 description = "Suite containing authentication-related tools such as passwd and su";
93 license = licenses.bsd3;
94 platforms = platforms.linux;
98 shellPath = "/bin/nologin";
99 tests = { inherit (nixosTests) shadow; };