summary refs log tree commit diff
path: root/modules/services/networking/rpcbind.nix
blob: 00c958c5a4a2786c121ee7eb159883ab93e0db9e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ config, pkgs, ... }:

with pkgs.lib;

let

  netconfigFile = {
    target = "netconfig";
    source = pkgs.writeText "netconfig" ''
      #
      # The network configuration file. This file is currently only used in
      # conjunction with the TI-RPC code in the libtirpc library.
      #
      # Entries consist of:
      #
      #       <network_id> <semantics> <flags> <protofamily> <protoname> \
      #               <device> <nametoaddr_libs>
      #
      # The <device> and <nametoaddr_libs> fields are always empty in this
      # implementation.
      #
      udp        tpi_clts      v     inet     udp     -       -
      tcp        tpi_cots_ord  v     inet     tcp     -       -
      udp6       tpi_clts      v     inet6    udp     -       -
      tcp6       tpi_cots_ord  v     inet6    tcp     -       -
      rawip      tpi_raw       -     inet      -      -       -
      local      tpi_cots_ord  -     loopback  -      -       -
      unix       tpi_cots_ord  -     loopback  -      -       -
    '';
  };

in

{

  ###### interface

  options = {

    services.rpcbind = {

      enable = mkOption {
        default = false;
        description = ''
          Whether to enable `rpcbind', an ONC RPC directory service
          notably used by NFS and NIS, and which can be queried
          using the rpcinfo(1) command. `rpcbind` is a replacement for
          `portmap`.
        '';
      };

    };

  };


  ###### implementation

  config = mkIf config.services.rpcbind.enable {

    environment.systemPackages = [ pkgs.rpcbind ];

    environment.etc = [ netconfigFile ];

    systemd.services.rpcbind =
      { description = "ONC RPC Directory Service";

        wantedBy = [ "multi-user.target" ];

        requires = [ "basic.target" ];
        after = [ "basic.target" ];

        unitConfig.DefaultDependencies = false; # don't stop during shutdown

        serviceConfig.Type = "forking";
        serviceConfig.ExecStart = "@${pkgs.rpcbind}/bin/rpcbind rpcbind";
      };

  };

}