1 { stdenv, fetchurl, fetchpatch, lib, pkg-config, util-linux, libcap, libtirpc, libevent
2 , sqlite, libkrb5, kmod, libuuid, keyutils, lvm2, systemd, coreutils, tcp_wrappers
3 , python3, buildPackages, nixosTests, rpcsvc-proto, openldap, cyrus_sasl, libxml2
4 , enablePython ? true, enableLdap ? true
8 statdPath = lib.makeBinPath [ systemd util-linux coreutils ];
11 stdenv.mkDerivation rec {
16 url = "mirror://kernel/linux/utils/nfs-utils/${version}/${pname}-${version}.tar.xz";
17 hash = "sha256-iFyUioSli8pBSPRZWI+ac2nbtA3MRm8E5FXGsQ/Qqkg=";
20 # libnfsidmap is built together with nfs-utils from the same source,
21 # put it in the "lib" output, and the headers in "dev"
22 outputs = [ "out" "dev" "lib" "man" ];
24 nativeBuildInputs = [ pkg-config buildPackages.stdenv.cc rpcsvc-proto ];
27 libtirpc libcap libevent sqlite lvm2
28 libuuid keyutils libkrb5 tcp_wrappers libxml2
29 ] ++ lib.optional enablePython python3
30 ++ lib.optionals enableLdap [
35 enableParallelBuilding = true;
39 substituteInPlace configure \
40 --replace '$dir/include/gssapi' ${lib.getDev libkrb5}/include/gssapi \
41 --replace '$dir/bin/krb5-config' ${lib.getDev libkrb5}/bin/krb5-config
47 "--with-statedir=/var/lib/nfs"
48 "--with-krb5=${lib.getLib libkrb5}"
49 "--with-systemd=${placeholder "out"}/etc/systemd/system"
50 "--enable-libmount-mount"
51 "--with-pluginpath=${placeholder "lib"}/lib/libnfsidmap" # this installs libnfsidmap
52 "--with-rpcgen=${buildPackages.rpcsvc-proto}/bin/rpcgen"
53 "--with-modprobedir=${placeholder "out"}/etc/modprobe.d"
54 ] ++ lib.optional enableLdap "--enable-ldap";
56 patches = lib.optionals stdenv.hostPlatform.isMusl [
57 # http://openwall.com/lists/musl/2015/08/18/10
59 url = "https://raw.githubusercontent.com/alpinelinux/aports/cb880042d48d77af412d4688f24b8310ae44f55f/main/nfs-utils/musl-getservbyport.patch";
60 sha256 = "1fqws9dz8n1d9a418c54r11y3w330qgy2652dpwcy96cm44sqyhf";
67 sed -i "s,/usr/sbin,$out/bin,g" utils/statd/statd.c
68 sed -i "s,^PATH=.*,PATH=$out/bin:${statdPath}," utils/statd/start-statd
70 configureFlags="--with-start-statd=$out/bin/start-statd $configureFlags"
72 substituteInPlace systemd/nfs-utils.service \
73 --replace "/bin/true" "${coreutils}/bin/true"
75 substituteInPlace tools/nfsrahead/Makefile.in systemd/Makefile.in \
76 --replace "/usr/lib/udev/rules.d/" "$out/lib/udev/rules.d/"
78 substituteInPlace utils/mount/Makefile.in \
79 --replace "chmod 4511" "chmod 0511"
81 sed '1i#include <stdint.h>' -i support/nsm/rpc.c
86 "generator_dir=$(out)/etc/systemd/system-generators"
94 stripDebugList = [ "lib" "libexec" "bin" "etc/systemd/system-generators" ];
100 -e "s,/sbin/modprobe,${kmod}/bin/modprobe,g" \
101 -e "s,/usr/sbin,$out/bin,g" \
102 $out/etc/systemd/system/*
103 '' + lib.optionalString (!enablePython) ''
104 # Remove all scripts that require python (currently mountstats and nfsiostat)
105 grep -l /usr/bin/python $out/bin/* | xargs -I {} rm -v {}
108 # One test fails on mips.
109 # doCheck = !stdenv.hostPlatform.isMips;
110 # https://bugzilla.kernel.org/show_bug.cgi?id=203793
113 disallowedReferences = [ (lib.getDev libkrb5) ];
116 nfs3-simple = nixosTests.nfs3.simple;
117 nfs4-simple = nixosTests.nfs4.simple;
118 nfs4-kerberos = nixosTests.nfs4.kerberos;
122 description = "Linux user-space NFS utilities";
125 This package contains various Linux user-space Network File
126 System (NFS) utilities, including RPC `mount' and `nfs'
130 homepage = "https://linux-nfs.org/";
131 license = licenses.gpl2Plus;
132 platforms = platforms.linux;
133 maintainers = with maintainers; [ abbradar ];