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";
20 security.acme.certs."ftp" = config.myServices.certificates.certConfig // {
21 domain = "eldiron.immae.eu";
23 systemctl restart pure-ftpd.service
25 extraDomains = { "ftp.immae.eu" = null; };
30 allowedTCPPorts = [ 21 ];
31 allowedTCPPortRanges = [ { from = 40000; to = 50000; } ];
36 uid = config.ids.uids.ftp; # 8
38 description = "Anonymous FTP user";
39 home = "/homeless-shelter";
40 extraGroups = [ "keys" ];
43 users.groups.ftp.gid = config.ids.gids.ftp;
45 system.activationScripts.pure-ftpd = ''
46 install -m 0755 -o ftp -g ftp -d /var/lib/ftp
50 dest = "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 = [ "/var/secrets/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 /var/secrets/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";