2009-03-06 13:26:22 +01:00
|
|
|
{pkgs, config, ...}:
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) mkOption mkIf;
|
|
|
|
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
2009-02-24 20:17:25 +01:00
|
|
|
|
2009-02-24 21:41:58 +01:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-03-06 13:26:22 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
###### implementation
|
2008-03-16 00:40:44 +01:00
|
|
|
|
2009-05-29 16:25:56 +02:00
|
|
|
let uid = config.ids.uids.portmap;
|
|
|
|
gid = config.ids.gids.portmap;
|
2008-03-16 00:40:44 +01:00
|
|
|
in
|
|
|
|
|
2009-03-06 13:26:22 +01:00
|
|
|
mkIf config.services.portmap.enable {
|
|
|
|
|
|
|
|
require = [
|
|
|
|
options
|
2008-03-16 00:40:44 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
2009-03-06 13:26:22 +01:00
|
|
|
users = {
|
|
|
|
extraUsers = [
|
|
|
|
{ name = "portmap";
|
|
|
|
inherit uid;
|
|
|
|
description = "portmap daemon user";
|
|
|
|
home = "/var/empty";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
extraGroups = [
|
|
|
|
{ name = "portmap";
|
|
|
|
inherit gid;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
|
|
|
extraJobs = [{
|
|
|
|
name = "portmap";
|
|
|
|
|
|
|
|
|
|
|
|
job =
|
2009-03-20 17:17:23 +01:00
|
|
|
let portmap = pkgs.portmap.override { daemonUID = uid; daemonGID = gid; };
|
2009-03-06 13:26:22 +01:00
|
|
|
in
|
|
|
|
''
|
|
|
|
description "ONC RPC portmap"
|
|
|
|
|
|
|
|
start on network-interfaces/started
|
|
|
|
stop on network-interfaces/stop
|
2008-03-16 00:40:44 +01:00
|
|
|
|
2009-04-21 18:25:37 +02:00
|
|
|
respawn ${portmap}/sbin/portmap -f \
|
2009-02-24 21:41:58 +01:00
|
|
|
${if config.services.portmap.chroot == ""
|
|
|
|
then ""
|
|
|
|
else "-t \"${config.services.portmap.chroot}\""} \
|
|
|
|
${if config.services.portmap.verbose then "-v" else ""}
|
2009-02-24 20:17:25 +01:00
|
|
|
'';
|
2009-03-06 13:26:22 +01:00
|
|
|
}];
|
|
|
|
};
|
2008-03-16 00:40:44 +01:00
|
|
|
}
|