1 { config, pkgs, lib, ... }:
6 cfg = config.services.rsyncd;
7 settingsFormat = pkgs.formats.ini { };
8 configFile = settingsFormat.generate "rsyncd.conf" cfg.settings;
13 enable = mkEnableOption (lib.mdDoc "the rsync daemon");
18 description = lib.mdDoc "TCP port the daemon will listen on.";
22 inherit (settingsFormat) type;
29 "max connections" = 4;
32 path = "/var/ftp/./pub";
33 comment = "whole ftp area";
37 comment = "CVS repository (requires authentication)";
38 "auth users" = [ "tridge" "susan" ];
39 "secrets file" = "/etc/rsyncd.secrets";
42 description = lib.mdDoc ''
43 Configuration for rsyncd. See
44 {manpage}`rsyncd.conf(5)`.
48 socketActivated = mkOption {
52 lib.mdDoc "If enabled Rsync will be socket-activated rather than run persistently.";
58 imports = (map (option:
59 mkRemovedOptionModule [ "services" "rsyncd" option ]
60 "This option was removed in favor of `services.rsyncd.settings`.") [
68 config = mkIf cfg.enable {
70 services.rsyncd.settings.global.port = toString cfg.port;
73 serviceConfigSecurity = {
74 ProtectSystem = "full";
75 PrivateDevices = "on";
76 NoNewPrivileges = "on";
80 enable = !cfg.socketActivated;
81 aliases = [ "rsyncd.service" ];
83 description = "fast remote file copy program daemon";
84 after = [ "network.target" ];
85 documentation = [ "man:rsync(1)" "man:rsyncd.conf(5)" ];
87 serviceConfig = serviceConfigSecurity // {
89 "${pkgs.rsync}/bin/rsync --daemon --no-detach --config=${configFile}";
93 wantedBy = [ "multi-user.target" ];
97 description = "fast remote file copy program daemon";
98 after = [ "network.target" ];
100 serviceConfig = serviceConfigSecurity // {
101 ExecStart = "${pkgs.rsync}/bin/rsync --daemon --config=${configFile}";
102 StandardInput = "socket";
103 StandardOutput = "inherit";
104 StandardError = "journal";
109 enable = cfg.socketActivated;
111 description = "socket for fast remote file copy program daemon";
112 conflicts = [ "rsync.service" ];
114 listenStreams = [ (toString cfg.port) ];
115 socketConfig.Accept = true;
117 wantedBy = [ "sockets.target" ];
123 meta.maintainers = with lib.maintainers; [ ehmry ];
125 # TODO: socket activated rsyncd