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; } ];
38 uid = config.ids.uids.ftp; # 8
40 description = "Anonymous FTP user";
41 home = "/homeless-shelter";
42 extraGroups = [ "keys" ];
46 users.groups.ftp.gid = config.ids.gids.ftp;
48 system.activationScripts.pure-ftpd = ''
49 install -m 0755 -o ftp -g ftp -d /var/lib/ftp
53 dest = "pure-ftpd-ldap";
58 LDAPServer ${config.myEnv.ftp.ldap.host}
61 LDAPBaseDN ${config.myEnv.ftp.ldap.base}
62 LDAPBindDN ${config.myEnv.ftp.ldap.dn}
63 LDAPBindPW ${config.myEnv.ftp.ldap.password}
65 LDAPForceDefaultUID False
67 LDAPForceDefaultGID False
68 LDAPFilter ${config.myEnv.ftp.ldap.filter}
72 # Pas de possibilite de donner l'Uid/Gid !
73 # Compile dans pure-ftpd directement avec immaeFtpUid / immaeFtpGid
74 LDAPHomeDir immaeFtpDirectory
78 services.filesWatcher.pure-ftpd = {
80 paths = [ "/var/secrets/pure-ftpd-ldap" ];
83 systemd.services.pure-ftpd = let
84 configFile = pkgs.writeText "pure-ftpd.conf" ''
85 PassivePortRange 40000 50000
88 BrokenClientsCompatibility yes
99 LDAPConfigFile /var/secrets/pure-ftpd-ldap
100 LimitRecursion 10000 8
101 AnonymousCanCreateDirs no
109 ProhibitDotFilesWrite no
110 ProhibitDotFilesRead no
112 AnonymousCantUpload no
116 CertFile ${config.security.acme.directory}/ftp/full.pem
119 description = "Pure-FTPd server";
120 wantedBy = [ "multi-user.target" ];
121 after = [ "network.target" ];
123 serviceConfig.ExecStart = "${package}/bin/pure-ftpd ${configFile}";
124 serviceConfig.Type = "forking";
125 serviceConfig.PIDFile = "/run/pure-ftpd.pid";