a395e46192
nfsd, as suggested by the nfs-utils README. Also, rather than relying on Upstart events (which have all sorts of problems, especially if you have jobs that have multiple dependencies), we know just let jobs start their on prerequisites. That is, nfsd starts mountd in its preStart script; mountd starts statd; statd starts portmap. Likewise, mountall starts statd to ensure that it can mount NFS filesystems. This means that doing something like "start nfsd" from the command line will Do The Right Thing and start the dependencies of nfsd. svn path=/nixos/trunk/; revision=33172
97 lines
1.9 KiB
Nix
97 lines
1.9 KiB
Nix
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
let
|
|
|
|
uid = config.ids.uids.portmap;
|
|
gid = config.ids.gids.portmap;
|
|
|
|
portmap = pkgs.portmap.override { daemonUID = uid; daemonGID = gid; };
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.portmap = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
description = ''
|
|
Whether to enable `portmap', an ONC RPC directory service
|
|
notably used by NFS and NIS, and which can be queried
|
|
using the rpcinfo(1) command.
|
|
'';
|
|
};
|
|
|
|
verbose = mkOption {
|
|
default = false;
|
|
description = ''
|
|
Whether to enable verbose output.
|
|
'';
|
|
};
|
|
|
|
chroot = mkOption {
|
|
default = "/var/empty";
|
|
description = ''
|
|
If non-empty, a path to change root to.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf config.services.portmap.enable {
|
|
|
|
environment.systemPackages = [ portmap ];
|
|
|
|
users.extraUsers = singleton
|
|
{ name = "portmap";
|
|
inherit uid;
|
|
description = "Portmap daemon user";
|
|
home = "/var/empty";
|
|
};
|
|
|
|
users.extraGroups = singleton
|
|
{ name = "portmap";
|
|
inherit gid;
|
|
};
|
|
|
|
jobs.portmap =
|
|
{ description = "ONC RPC portmap";
|
|
|
|
startOn = "started network-interfaces";
|
|
stopOn = "never";
|
|
|
|
daemonType = "fork"; # needed during shutdown
|
|
|
|
path = [ portmap pkgs.netcat ];
|
|
|
|
exec =
|
|
''
|
|
portmap \
|
|
${optionalString (config.services.portmap.chroot != "")
|
|
"-t '${config.services.portmap.chroot}'"} \
|
|
${if config.services.portmap.verbose then "-v" else ""}
|
|
'';
|
|
|
|
postStart =
|
|
''
|
|
# Portmap forks into the background before it starts
|
|
# listening, so wait until its ready.
|
|
while ! nc -z localhost 111; do sleep 1; done
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
}
|