2009-02-24 20:17:25 +01:00
|
|
|
{pkgs, config, ...}:
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) mkOption mkIf;
|
|
|
|
inherit (pkgs) makePortmap;
|
|
|
|
|
|
|
|
uid = (import ../system/ids.nix).uids.portmap;
|
|
|
|
gid = (import ../system/ids.nix).gids.portmap;
|
|
|
|
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2008-03-16 00:40:44 +01:00
|
|
|
|
|
|
|
in
|
|
|
|
|
2009-02-24 20:17:25 +01:00
|
|
|
###### implementation
|
|
|
|
mkIf config.services.portmap.enable {
|
|
|
|
require = [
|
|
|
|
options
|
2008-03-16 00:40:44 +01:00
|
|
|
];
|
2009-02-24 20:17:25 +01:00
|
|
|
|
|
|
|
users = {
|
|
|
|
extraUsers = [
|
|
|
|
{ name = "portmap";
|
|
|
|
inherit uid;
|
|
|
|
description = "portmap daemon user";
|
|
|
|
home = "/var/empty";
|
|
|
|
}
|
|
|
|
];
|
2008-03-16 00:40:44 +01:00
|
|
|
|
2009-02-24 20:17:25 +01:00
|
|
|
extraGroups = [
|
|
|
|
{ name = "portmap";
|
|
|
|
inherit gid;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2008-03-16 00:40:44 +01:00
|
|
|
|
2009-02-24 20:17:25 +01:00
|
|
|
services = {
|
|
|
|
extraJobs = [{
|
|
|
|
name = "portmap";
|
2008-03-16 00:40:44 +01:00
|
|
|
|
2009-02-24 20:17:25 +01:00
|
|
|
job =
|
|
|
|
let portmap = makePortmap { daemonUID = uid; daemonGID = gid; };
|
|
|
|
in ''
|
|
|
|
description "ONC RPC portmap"
|
|
|
|
|
|
|
|
start on network-interfaces/started
|
|
|
|
stop on network-interfaces/stop
|
|
|
|
|
|
|
|
respawn ${portmap}/sbin/portmap
|
|
|
|
'';
|
|
|
|
}];
|
|
|
|
};
|
2008-03-16 00:40:44 +01:00
|
|
|
}
|