18 libiconv' = if stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isFreeBSD then libiconvReal else libiconv;
20 stdenv.mkDerivation rec {
25 url = "mirror://savannah/man-db/man-db-${version}.tar.xz";
26 hash = "sha256-gvBzn09hqrXrk30jTeOwFOd3tVOKKMvTFDPEWuCa77k=";
29 outputs = [ "out" "doc" ];
30 outputMan = "out"; # users will want `man man` to work
33 nativeBuildInputs = [ groff makeWrapper pkg-config zstd ];
34 buildInputs = [ libpipeline db groff libiconv' ]; # (Yes, 'groff' is both native and build input)
35 nativeCheckInputs = [ libiconv' ]; # for 'iconv' binary; make very sure it matches buildinput libiconv
38 ./systemwide-man-db-conf.patch
42 # Remove all mandatory manpaths. Nixpkgs makes no requirements on
43 # these directories existing.
44 sed -i 's/^MANDATORY_MANPATH/# &/' src/man_db.conf.in
46 # Add Nix-related manpaths
47 echo "MANPATH_MAP /nix/var/nix/profiles/default/bin /nix/var/nix/profiles/default/share/man" >> src/man_db.conf.in
49 # Add mandb locations for the above
50 echo "MANDB_MAP /nix/var/nix/profiles/default/share/man /var/cache/man/nixpkgs" >> src/man_db.conf.in
55 "--disable-cache-owner"
56 "--localstatedir=/var"
57 "--with-config-file=${placeholder "out"}/etc/man_db.conf"
58 "--with-systemdtmpfilesdir=${placeholder "out"}/lib/tmpfiles.d"
59 "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
61 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
62 "ac_cv_func__set_invalid_parameter_handler=no"
63 "ac_cv_func_posix_fadvise=no"
64 "ac_cv_func_mempcpy=no"
65 ] ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
70 configureFlagsArray+=("--with-sections=1 n l 8 3 0 2 5 4 9 6 7")
74 # apropos/whatis uses program name to decide whether to act like apropos or whatis
75 # (multi-call binary). `apropos` is actually just a symlink to whatis. So we need to
76 # make sure that we don't wrap symlinks (since that changes argv[0] to the -wrapped name)
77 find "$out/bin" -type f | while read file; do
79 --prefix PATH : "${lib.makeBinPath [ groff gzip zstd ]}"
83 disallowedReferences = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
87 enableParallelBuilding = true;
89 doCheck = !stdenv.hostPlatform.isMusl /* iconv binary */;
92 nixos = nixosTests.man;
96 homepage = "http://man-db.nongnu.org";
97 description = "Implementation of the standard Unix documentation system accessed using the man command";
98 license = licenses.gpl2Plus;
99 platforms = lib.platforms.unix;