1{ stdenv, fetchurl, lib, pkgconfig, utillinux, libcap, libtirpc, libevent, libnfsidmap
2, sqlite, kerberos, kmod, libuuid, keyutils, lvm2, systemd, coreutils, tcp_wrappers
3, buildEnv
4}:
5
6let
7 statdPath = lib.makeBinPath [ systemd utillinux coreutils ];
8
9 # Not nice; feel free to find a nicer solution.
10 kerberosEnv = buildEnv {
11 name = "kerberos-env-${kerberos.version}";
12 paths = with lib; [ (getDev kerberos) (getLib kerberos) ];
13 };
14
15in stdenv.mkDerivation rec {
16 name = "nfs-utils-${version}";
17 version = "2.1.1";
18
19 src = fetchurl {
20 url = "mirror://sourceforge/nfs/${name}.tar.bz2";
21 sha256 = "02dvxphndpm8vpqqnl0zvij97dq9vsq2a179pzrjcv2i91ll2a0a";
22 };
23
24 nativeBuildInputs = [ pkgconfig ];
25
26 buildInputs = [
27 libtirpc libcap libevent libnfsidmap sqlite lvm2
28 libuuid keyutils kerberos tcp_wrappers
29 ];
30
31 enableParallelBuilding = true;
32
33 configureFlags =
34 [ "--enable-gss"
35 "--with-statedir=/var/lib/nfs"
36 "--with-krb5=${kerberosEnv}"
37 "--with-systemd=$(out)/etc/systemd/system"
38 "--enable-libmount-mount"
39 ]
40 ++ lib.optional (stdenv ? glibc) "--with-rpcgen=${stdenv.glibc.bin}/bin/rpcgen";
41
42 postPatch =
43 ''
44 patchShebangs tests
45 sed -i "s,/usr/sbin,$out/bin,g" utils/statd/statd.c
46 sed -i "s,^PATH=.*,PATH=$out/bin:${statdPath}," utils/statd/start-statd
47
48 configureFlags="--with-start-statd=$out/bin/start-statd $configureFlags"
49
50 substituteInPlace systemd/nfs-utils.service \
51 --replace "/bin/true" "${coreutils}/bin/true"
52
53 substituteInPlace utils/mount/Makefile.in \
54 --replace "chmod 4511" "chmod 0511"
55
56 sed '1i#include <stdint.h>' -i support/nsm/rpc.c
57 '';
58
59 makeFlags = [
60 "sbindir=$(out)/bin"
61 "generator_dir=$(out)/etc/systemd/system-generators"
62 ];
63
64 installFlags = [
65 "statedir=$(TMPDIR)"
66 "statdpath=$(TMPDIR)"
67 ];
68
69 postInstall =
70 ''
71 # Not used on NixOS
72 sed -i \
73 -e "s,/sbin/modprobe,${kmod}/bin/modprobe,g" \
74 -e "s,/usr/sbin,$out/bin,g" \
75 $out/etc/systemd/system/*
76 '';
77
78 # One test fails on mips.
79 doCheck = !stdenv.isMips;
80
81 meta = with stdenv.lib; {
82 description = "Linux user-space NFS utilities";
83
84 longDescription = ''
85 This package contains various Linux user-space Network File
86 System (NFS) utilities, including RPC `mount' and `nfs'
87 daemons.
88 '';
89
90 homepage = https://sourceforge.net/projects/nfs/;
91 license = licenses.gpl2;
92 platforms = platforms.linux;
93 maintainers = with maintainers; [ abbradar ];
94 };
95}