1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7 netconfigFile = {
8 target = "netconfig";
9 source = pkgs.writeText "netconfig" ''
10 #
11 # The network configuration file. This file is currently only used in
12 # conjunction with the TI-RPC code in the libtirpc library.
13 #
14 # Entries consist of:
15 #
16 # <network_id> <semantics> <flags> <protofamily> <protoname> \
17 # <device> <nametoaddr_libs>
18 #
19 # The <device> and <nametoaddr_libs> fields are always empty in this
20 # implementation.
21 #
22 udp tpi_clts v inet udp - -
23 tcp tpi_cots_ord v inet tcp - -
24 udp6 tpi_clts v inet6 udp - -
25 tcp6 tpi_cots_ord v inet6 tcp - -
26 rawip tpi_raw - inet - - -
27 local tpi_cots_ord - loopback - - -
28 unix tpi_cots_ord - loopback - - -
29 '';
30 };
31
32in
33
34{
35
36 ###### interface
37
38 options = {
39
40 services.rpcbind = {
41
42 enable = mkOption {
43 type = types.bool;
44 default = false;
45 description = ''
46 Whether to enable `rpcbind', an ONC RPC directory service
47 notably used by NFS and NIS, and which can be queried
48 using the rpcinfo(1) command. `rpcbind` is a replacement for
49 `portmap`.
50 '';
51 };
52
53 };
54
55 };
56
57
58 ###### implementation
59
60 config = mkIf config.services.rpcbind.enable {
61
62 environment.systemPackages = [ pkgs.rpcbind ];
63
64 environment.etc = [ netconfigFile ];
65
66 systemd.services.rpcbind =
67 { description = "ONC RPC Directory Service";
68
69 wantedBy = [ "multi-user.target" ];
70
71 requires = [ "basic.target" ];
72 after = [ "basic.target" ];
73
74 unitConfig.DefaultDependencies = false; # don't stop during shutdown
75
76 serviceConfig.Type = "forking";
77 serviceConfig.ExecStart = "@${pkgs.rpcbind}/bin/rpcbind rpcbind";
78 };
79
80 };
81
82}