2012-03-09 15:37:58 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
inInitrd = any (fs: fs == "nfs") config.boot.initrd.supportedFilesystems;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2012-03-16 21:41:49 +01:00
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.nfs.client.enable = mkOption {
|
|
|
|
default = any (fs: fs.fsType == "nfs" || fs.fsType == "nfs4") config.fileSystems;
|
|
|
|
description = ''
|
|
|
|
Whether to enable support for mounting NFS filesystems.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.nfs.client.enable {
|
|
|
|
|
|
|
|
services.portmap.enable = true;
|
|
|
|
|
2012-03-09 15:37:58 +01:00
|
|
|
system.fsPackages = [ pkgs.nfsUtils ];
|
|
|
|
|
|
|
|
boot.initrd.kernelModules = mkIf inInitrd [ "nfs" ];
|
|
|
|
|
|
|
|
boot.initrd.extraUtilsCommands = mkIf inInitrd
|
|
|
|
''
|
|
|
|
# !!! Uh, why don't we just install mount.nfs?
|
|
|
|
cp -v ${pkgs.klibc}/lib/klibc/bin.static/nfsmount $out/bin
|
|
|
|
'';
|
|
|
|
|
2012-03-16 21:41:49 +01:00
|
|
|
jobs.statd =
|
|
|
|
{ description = "Kernel NFS server - Network Status Monitor";
|
|
|
|
|
|
|
|
path = [ pkgs.nfsUtils pkgs.sysvtools pkgs.utillinux ];
|
|
|
|
|
2012-03-17 19:00:20 +01:00
|
|
|
stopOn = ""; # needed during shutdown
|
2012-03-16 21:41:49 +01:00
|
|
|
|
|
|
|
preStart =
|
|
|
|
''
|
2012-03-17 20:12:33 +01:00
|
|
|
ensure portmap
|
2012-03-16 21:41:49 +01:00
|
|
|
mkdir -p /var/lib/nfs
|
|
|
|
mkdir -p /var/lib/nfs/sm
|
|
|
|
mkdir -p /var/lib/nfs/sm.bak
|
|
|
|
sm-notify -d
|
|
|
|
'';
|
|
|
|
|
|
|
|
daemonType = "fork";
|
|
|
|
|
|
|
|
exec = "rpc.statd --no-notify";
|
|
|
|
};
|
|
|
|
|
2012-03-09 15:37:58 +01:00
|
|
|
};
|
|
|
|
}
|