nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 buildPackages,
3 gdbm,
4 fetchurl,
5 groff,
6 gzip,
7 lib,
8 libiconv,
9 libiconvReal,
10 libpipeline,
11 makeWrapper,
12 nixosTests,
13 pkg-config,
14 stdenv,
15 util-linuxMinimal,
16 zstd,
17}:
18
19let
20 libiconv' =
21 if stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isFreeBSD then libiconvReal else libiconv;
22in
23stdenv.mkDerivation rec {
24 pname = "man-db";
25 version = "2.13.1";
26
27 src = fetchurl {
28 url = "mirror://savannah/man-db/man-db-${version}.tar.xz";
29 hash = "sha256-iv67b362u4VCkpRYhB9cfm8kDjDIY1jB+8776gdsh9k=";
30 };
31
32 outputs = [
33 "out"
34 "doc"
35 ];
36 outputMan = "out"; # users will want `man man` to work
37
38 strictDeps = true;
39 nativeBuildInputs = [
40 groff
41 makeWrapper
42 pkg-config
43 zstd
44 ];
45 buildInputs = [
46 libpipeline
47 gdbm
48 groff
49 libiconv'
50 ]; # (Yes, 'groff' is both native and build input)
51 nativeCheckInputs = [ libiconv' ]; # for 'iconv' binary; make very sure it matches buildinput libiconv
52
53 patches = [
54 ./systemwide-man-db-conf.patch
55 ];
56
57 postPatch = ''
58 # Remove all mandatory manpaths. Nixpkgs makes no requirements on
59 # these directories existing.
60 sed -i 's/^MANDATORY_MANPATH/# &/' src/man_db.conf.in
61
62 # Add Nix-related manpaths
63 echo "MANPATH_MAP /nix/var/nix/profiles/default/bin /nix/var/nix/profiles/default/share/man" >> src/man_db.conf.in
64
65 # Add mandb locations for the above
66 echo "MANDB_MAP /nix/var/nix/profiles/default/share/man /var/cache/man/nixpkgs" >> src/man_db.conf.in
67 '';
68
69 configureFlags = [
70 "--disable-setuid"
71 "--disable-cache-owner"
72 "--localstatedir=/var"
73 "--with-config-file=${placeholder "out"}/etc/man_db.conf"
74 "--with-systemdtmpfilesdir=${placeholder "out"}/lib/tmpfiles.d"
75 "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
76 "--with-pager=less"
77 ]
78 ++ lib.optionals util-linuxMinimal.hasCol [
79 "--with-col=${util-linuxMinimal}/bin/col"
80 ]
81 ++ lib.optionals stdenv.hostPlatform.isDarwin [
82 "ac_cv_func__set_invalid_parameter_handler=no"
83 "ac_cv_func_posix_fadvise=no"
84 "ac_cv_func_mempcpy=no"
85 ]
86 ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
87 "--enable-mandirs="
88 ];
89
90 preConfigure = ''
91 configureFlagsArray+=("--with-sections=1 n l 8 3 0 2 5 4 9 6 7")
92 '';
93
94 postInstall = ''
95 # apropos/whatis uses program name to decide whether to act like apropos or whatis
96 # (multi-call binary). `apropos` is actually just a symlink to whatis. So we need to
97 # make sure that we don't wrap symlinks (since that changes argv[0] to the -wrapped name)
98 find "$out/bin" -type f | while read file; do
99 wrapProgram "$file" \
100 --prefix PATH : "${
101 lib.makeBinPath [
102 groff
103 gzip
104 zstd
105 ]
106 }"
107 done
108 '';
109
110 disallowedReferences = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
111 buildPackages.groff
112 ];
113
114 enableParallelBuilding = true;
115
116 doCheck =
117 !stdenv.hostPlatform.isMusl # iconv binary
118 ;
119
120 passthru.tests = {
121 nixos = nixosTests.man;
122 };
123
124 meta = with lib; {
125 homepage = "http://man-db.nongnu.org";
126 description = "Implementation of the standard Unix documentation system accessed using the man command";
127 license = licenses.gpl2Plus;
128 platforms = lib.platforms.unix;
129 mainProgram = "man";
130 };
131}