1 { config, lib, pkgs, ... }:
4 cfg = config.services.diod;
6 diodBool = b: if b then "1" else "0";
8 diodConfig = pkgs.writeText "diod.conf" ''
9 allsquash = ${diodBool cfg.allsquash}
10 auth_required = ${diodBool cfg.authRequired}
11 exportall = ${diodBool cfg.exportall}
12 exportopts = "${concatStringsSep "," cfg.exportopts}"
13 exports = { ${concatStringsSep ", " (map (s: ''"${s}"'' ) cfg.exports)} }
14 listen = { ${concatStringsSep ", " (map (s: ''"${s}"'' ) cfg.listen)} }
15 logdest = "${cfg.logdest}"
16 nwthreads = ${toString cfg.nwthreads}
17 squashuser = "${cfg.squashuser}"
18 statfs_passthru = ${diodBool cfg.statfsPassthru}
19 userdb = ${diodBool cfg.userdb}
29 description = "Whether to enable the diod 9P file server.";
33 type = types.listOf types.str;
34 default = [ "0.0.0.0:564" ];
36 [ "IP:PORT" [,"IP:PORT",...] ]
37 List the interfaces and ports that diod should listen on.
42 type = types.listOf types.str;
45 List the file systems that clients will be allowed to mount. All paths should
46 be fully qualified. The exports table can include two types of element:
47 a string element (as above),
48 or an alternate table element form { path="/path", opts="ro" }.
49 In the alternate form, the (optional) opts attribute is a comma-separated list
50 of export options. The two table element forms can be mixed in the exports
51 table. Note that although diod will not traverse file system boundaries for a
52 given mount due to inode uniqueness constraints, subdirectories of a file
53 system can be separately exported.
57 exportall = mkOption {
61 Export all file systems listed in /proc/mounts. If new file systems are mounted
62 after diod has started, they will become immediately mountable. If there is a
63 duplicate entry for a file system in the exports list, any options listed in
64 the exports entry will apply.
68 exportopts = mkOption {
69 type = types.listOf types.str;
72 Establish a default set of export options. These are overridden, not appended
73 to, by opts attributes in an "exports" entry.
77 nwthreads = mkOption {
81 Sets the (fixed) number of worker threads created to handle 9P
82 requests for a unique aname.
86 authRequired = mkOption {
90 Allow clients to connect without authentication, i.e. without a valid MUNGE credential.
98 This option disables password/group lookups. It allows any uid to attach and
99 assumes gid=uid, and supplementary groups contain only the primary gid.
103 allsquash = mkOption {
107 Remap all users to "nobody". The attaching user need not be present in the
112 squashuser = mkOption {
116 Change the squash user. The squash user must be present in the password file.
122 default = "syslog:daemon:err";
124 Set the destination for logging.
125 The value has the form of "syslog:facility:level" or "filename".
130 statfsPassthru = mkOption {
134 This option configures statfs to return the host file system's type
135 rather than V9FS_MAGIC.
139 extraConfig = mkOption {
142 description = "Extra configuration options for diod.conf.";
147 config = mkIf config.services.diod.enable {
148 environment.systemPackages = [ pkgs.diod ];
150 systemd.services.diod = {
151 description = "diod 9P file server";
152 wantedBy = [ "multi-user.target" ];
153 after = [ "network.target" ];
155 ExecStart = "${pkgs.diod}/sbin/diod -f -c ${diodConfig}";