1 { lib, pkgs, config, ... }:
3 package = pkgs.pure-ftpd.override { ldapFtpId = "immaeFtp"; };
7 services.pure-ftpd.enable = lib.mkOption {
11 Whether to enable pure-ftpd.
16 config = lib.mkIf config.services.pure-ftpd.enable {
17 services.duplyBackup.profiles.ftp = {
18 rootDir = "/var/lib/ftp";
19 remotes = [ "eriomem" "ovh" ];
21 security.acme.certs."ftp" = config.myServices.certificates.certConfig // {
22 domain = "eldiron.immae.eu";
24 systemctl restart pure-ftpd.service
26 extraDomains = { "ftp.immae.eu" = null; };
31 allowedTCPPorts = [ 21 ];
32 allowedTCPPortRanges = [ { from = 40000; to = 50000; } ];
37 uid = config.ids.uids.ftp; # 8
39 description = "Anonymous FTP user";
40 home = "/homeless-shelter";
41 extraGroups = [ "keys" ];
44 users.groups.ftp.gid = config.ids.gids.ftp;
46 system.activationScripts.pure-ftpd = ''
47 install -m 0755 -o ftp -g ftp -d /var/lib/ftp
50 secrets.keys."pure-ftpd-ldap" = {
55 LDAPServer ${config.myEnv.ftp.ldap.host}
58 LDAPBaseDN ${config.myEnv.ftp.ldap.base}
59 LDAPBindDN ${config.myEnv.ftp.ldap.dn}
60 LDAPBindPW ${config.myEnv.ftp.ldap.password}
62 LDAPForceDefaultUID False
64 LDAPForceDefaultGID False
65 LDAPFilter ${config.myEnv.ftp.ldap.filter}
69 # Pas de possibilite de donner l'Uid/Gid !
70 # Compile dans pure-ftpd directement avec immaeFtpUid / immaeFtpGid
71 LDAPHomeDir immaeFtpDirectory
75 services.filesWatcher.pure-ftpd = {
77 paths = [ config.secrets.fullPaths."pure-ftpd-ldap" ];
80 systemd.services.pure-ftpd = let
81 configFile = pkgs.writeText "pure-ftpd.conf" ''
82 PassivePortRange 40000 50000
85 BrokenClientsCompatibility yes
96 LDAPConfigFile ${config.secrets.fullPaths."pure-ftpd-ldap"}
97 LimitRecursion 10000 8
98 AnonymousCanCreateDirs no
106 ProhibitDotFilesWrite no
107 ProhibitDotFilesRead no
109 AnonymousCantUpload no
113 CertFile ${config.security.acme.certs.ftp.directory}/full.pem
116 description = "Pure-FTPd server";
117 wantedBy = [ "multi-user.target" ];
118 after = [ "network.target" ];
120 serviceConfig.ExecStart = "${package}/bin/pure-ftpd ${configFile}";
121 serviceConfig.Type = "forking";
122 serviceConfig.PIDFile = "/run/pure-ftpd.pid";