2014-05-05 20:58:51 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
2014-04-11 13:35:06 +02:00
|
|
|
|
2014-05-05 20:58:51 +02:00
|
|
|
with lib;
|
2014-04-11 13:35:06 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.rsyncd;
|
2020-08-13 15:31:17 +02:00
|
|
|
settingsFormat = pkgs.formats.ini { };
|
|
|
|
configFile = settingsFormat.generate "rsyncd.conf" cfg.settings;
|
|
|
|
in {
|
2014-04-11 13:35:06 +02:00
|
|
|
options = {
|
|
|
|
services.rsyncd = {
|
|
|
|
|
2020-04-20 20:05:26 +02:00
|
|
|
enable = mkEnableOption "the rsync daemon";
|
2014-04-11 13:35:06 +02:00
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
default = 873;
|
2020-08-13 15:31:17 +02:00
|
|
|
type = types.port;
|
2014-12-07 21:42:22 +01:00
|
|
|
description = "TCP port the daemon will listen on.";
|
2014-04-11 13:35:06 +02:00
|
|
|
};
|
|
|
|
|
2020-08-13 15:31:17 +02:00
|
|
|
settings = mkOption {
|
|
|
|
inherit (settingsFormat) type;
|
|
|
|
default = { };
|
|
|
|
example = {
|
|
|
|
global = {
|
|
|
|
uid = "nobody";
|
|
|
|
gid = "nobody";
|
|
|
|
"use chroot" = true;
|
|
|
|
"max connections" = 4;
|
|
|
|
};
|
|
|
|
ftp = {
|
|
|
|
path = "/var/ftp/./pub";
|
|
|
|
comment = "whole ftp area";
|
|
|
|
};
|
|
|
|
cvs = {
|
|
|
|
path = "/data/cvs";
|
|
|
|
comment = "CVS repository (requires authentication)";
|
|
|
|
"auth users" = [ "tridge" "susan" ];
|
|
|
|
"secrets file" = "/etc/rsyncd.secrets";
|
|
|
|
};
|
|
|
|
};
|
2017-07-21 21:15:27 +02:00
|
|
|
description = ''
|
2020-08-13 15:31:17 +02:00
|
|
|
Configuration for rsyncd. See
|
|
|
|
<citerefentry><refentrytitle>rsyncd.conf</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry>.
|
2017-07-21 21:15:27 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-04-11 13:35:06 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-08-13 15:31:17 +02:00
|
|
|
imports = (map (option:
|
|
|
|
mkRemovedOptionModule [ "services" "rsyncd" option ]
|
|
|
|
"This option was removed in favor of `services.rsyncd.settings`.") [
|
|
|
|
"address"
|
|
|
|
"extraConfig"
|
|
|
|
"motd"
|
|
|
|
"user"
|
|
|
|
"group"
|
|
|
|
]);
|
2014-04-11 13:35:06 +02:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2020-08-13 15:31:17 +02:00
|
|
|
services.rsyncd.settings.global.port = toString cfg.port;
|
2014-04-11 13:35:06 +02:00
|
|
|
|
|
|
|
systemd.services.rsyncd = {
|
|
|
|
description = "Rsync daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2020-08-13 15:31:17 +02:00
|
|
|
serviceConfig.ExecStart =
|
|
|
|
"${pkgs.rsync}/bin/rsync --daemon --no-detach --config=${configFile}";
|
2014-04-11 13:35:06 +02:00
|
|
|
};
|
|
|
|
};
|
2020-08-13 15:31:17 +02:00
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ ehmry ];
|
|
|
|
|
|
|
|
# TODO: socket activated rsyncd
|
|
|
|
|
2014-05-05 20:58:51 +02:00
|
|
|
}
|