2014-05-05 19:58:51 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2014-04-11 12:35:06 +01:00
|
|
|
|
2014-05-05 19:58:51 +01:00
|
|
|
with lib;
|
2014-04-11 12:35:06 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.rsyncd;
|
2020-08-13 14:31:17 +01:00
|
|
|
settingsFormat = pkgs.formats.ini { };
|
|
|
|
configFile = settingsFormat.generate "rsyncd.conf" cfg.settings;
|
|
|
|
in {
|
2014-04-11 12:35:06 +01:00
|
|
|
options = {
|
|
|
|
services.rsyncd = {
|
|
|
|
|
2020-04-20 19:05:26 +01:00
|
|
|
enable = mkEnableOption "the rsync daemon";
|
2014-04-11 12:35:06 +01:00
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
default = 873;
|
2020-08-13 14:31:17 +01:00
|
|
|
type = types.port;
|
2014-12-07 20:42:22 +00:00
|
|
|
description = "TCP port the daemon will listen on.";
|
2014-04-11 12:35:06 +01:00
|
|
|
};
|
|
|
|
|
2020-08-13 14:31:17 +01: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 20:15:27 +01:00
|
|
|
description = ''
|
2020-08-13 14:31:17 +01:00
|
|
|
Configuration for rsyncd. See
|
|
|
|
<citerefentry><refentrytitle>rsyncd.conf</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum></citerefentry>.
|
2017-07-21 20:15:27 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-04-11 12:35:06 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-08-13 14:31:17 +01: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 12:35:06 +01:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2020-08-13 14:31:17 +01:00
|
|
|
services.rsyncd.settings.global.port = toString cfg.port;
|
2014-04-11 12:35:06 +01:00
|
|
|
|
|
|
|
systemd.services.rsyncd = {
|
|
|
|
description = "Rsync daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2020-08-13 14:31:17 +01:00
|
|
|
serviceConfig.ExecStart =
|
|
|
|
"${pkgs.rsync}/bin/rsync --daemon --no-detach --config=${configFile}";
|
2014-04-11 12:35:06 +01:00
|
|
|
};
|
|
|
|
};
|
2020-08-13 14:31:17 +01:00
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ ehmry ];
|
|
|
|
|
|
|
|
# TODO: socket activated rsyncd
|
|
|
|
|
2014-05-05 19:58:51 +01:00
|
|
|
}
|