1 { config, pkgs, lib, ... }:
3 cfg = config.services.rsyncd;
4 settingsFormat = pkgs.formats.ini { };
5 configFile = settingsFormat.generate "rsyncd.conf" cfg.settings;
10 enable = lib.mkEnableOption "the rsync daemon";
14 type = lib.types.port;
15 description = "TCP port the daemon will listen on.";
18 settings = lib.mkOption {
19 inherit (settingsFormat) type;
26 "max connections" = 4;
29 path = "/var/ftp/./pub";
30 comment = "whole ftp area";
34 comment = "CVS repository (requires authentication)";
35 "auth users" = [ "tridge" "susan" ];
36 "secrets file" = "/etc/rsyncd.secrets";
40 Configuration for rsyncd. See
41 {manpage}`rsyncd.conf(5)`.
45 socketActivated = lib.mkOption {
47 type = lib.types.bool;
48 description = "If enabled Rsync will be socket-activated rather than run persistently.";
54 imports = (map (option:
55 lib.mkRemovedOptionModule [ "services" "rsyncd" option ]
56 "This option was removed in favor of `services.rsyncd.settings`.") [
64 config = lib.mkIf cfg.enable {
66 services.rsyncd.settings.global.port = toString cfg.port;
69 serviceConfigSecurity = {
70 ProtectSystem = "full";
71 PrivateDevices = "on";
72 NoNewPrivileges = "on";
76 enable = !cfg.socketActivated;
77 aliases = [ "rsyncd.service" ];
79 description = "fast remote file copy program daemon";
80 after = [ "network.target" ];
81 documentation = [ "man:rsync(1)" "man:rsyncd.conf(5)" ];
83 serviceConfig = serviceConfigSecurity // {
85 "${pkgs.rsync}/bin/rsync --daemon --no-detach --config=${configFile}";
89 wantedBy = [ "multi-user.target" ];
93 description = "fast remote file copy program daemon";
94 after = [ "network.target" ];
96 serviceConfig = serviceConfigSecurity // {
97 ExecStart = "${pkgs.rsync}/bin/rsync --daemon --config=${configFile}";
98 StandardInput = "socket";
99 StandardOutput = "inherit";
100 StandardError = "journal";
105 enable = cfg.socketActivated;
107 description = "socket for fast remote file copy program daemon";
108 conflicts = [ "rsync.service" ];
110 listenStreams = [ (toString cfg.port) ];
111 socketConfig.Accept = true;
113 wantedBy = [ "sockets.target" ];
119 meta.maintainers = with lib.maintainers; [ ehmry ];
121 # TODO: socket activated rsyncd