···
cfg = config.services.rsyncd;
9
-
motdFile = pkgs.writeText "rsyncd-motd" cfg.motd;
9
+
motdFile = builtins.toFile "rsyncd-motd" cfg.motd;
12
-
+ optionalString (cfg.motd != "") "motd file = ${motdFile}\n"
13
-
+ optionalString (cfg.address != "") "address = ${cfg.address}\n"
14
-
+ optionalString (cfg.port != 873) "port = ${toString cfg.port}\n"
17
-
+ flip concatMapStrings cfg.modules (m: "[${m.name}]\n\tpath = ${m.path}\n"
18
-
+ optionalString (m.comment != "") "\tcomment = ${m.comment}\n"
11
+
moduleConfig = name:
12
+
let module = getAttr name cfg.modules; in
13
+
"[${name}]\n " + (toString (
15
+
(key: "${key} = ${toString (getAttr key module)}\n")
23
-
rsyncdCfgFile = pkgs.writeText "rsyncd.conf" rsyncdCfg;
19
+
cfgFile = builtins.toFile "rsyncd.conf"
21
+
${optionalString (cfg.motd != "") "motd file = ${motdFile}"}
22
+
${optionalString (cfg.address != "") "address = ${cfg.address}"}
23
+
${optionalString (cfg.port != 873) "port = ${toString cfg.port}"}
25
+
${toString (map moduleConfig (attrNames cfg.modules))}
34
-
description = "Whether to enable the rsync daemon.";
35
+
description = "Whether to enable the rsync daemon.";
41
-
Message of the day to display to clients on each connect.
42
-
This usually contains site information and any legal notices.
42
+
Message of the day to display to clients on each connect.
43
+
This usually contains site information and any legal notices.
49
-
description = "TCP port the daemon will listen on.";
50
+
description = "TCP port the daemon will listen on.";
54
-
example = "192.168.1.2";
56
-
IP address the daemon will listen on; rsyncd will listen on
57
-
all addresses if this is not specified.
55
+
example = "192.168.1.2";
57
+
IP address the daemon will listen on; rsyncd will listen on
58
+
all addresses if this is not specified.
65
-
Lines of configuration to add to rsyncd globally.
66
-
See <literal>man rsyncd.conf</literal> for more options.
66
+
Lines of configuration to add to rsyncd globally.
67
+
See <command>man rsyncd.conf</command> for options.
75
-
comment = "ftp export area";
77
-
secrets file = /etc/rsyncd.secrets
81
-
description = "The list of file paths to export.";
82
-
type = types.listOf types.optionSet;
88
-
type = types.string;
89
-
description = "Name of export module.";
92
-
comment = mkOption {
95
-
Description string that is displayed next to the module name
96
-
when clients obtain a list of available modules.
101
-
example = "/home/ftp";
102
-
type = types.string;
103
-
description = "Directory to make available in this module.";
106
-
extraConfig = mkOption {
107
-
type = types.lines;
110
-
Lines of configuration to add to this module.
111
-
See <literal>man rsyncd.conf</literal> for more options.
74
+
A set describing exported directories.
75
+
See <command>man rsyncd.conf</command> for options.
77
+
type = types.attrsOf (types.attrsOf types.str);
81
+
"read only" = "yes";
82
+
comment = "Public rsync share.";
···
config = mkIf cfg.enable {
123
-
environment.etc = singleton
124
-
{ source = rsyncdCfgFile;
94
+
environment.etc = singleton {
systemd.services.rsyncd = {
description = "Rsync daemon";
wantedBy = [ "multi-user.target" ];
132
-
path = [ pkgs.rsync ];
serviceConfig.ExecStart = "${pkgs.rsync}/bin/rsync --daemon --no-detach";
137
-
networking.firewall.allowedTCPPorts = [ cfg.port ];