1 { lib, pkgs, config, myconfig, ... }:
4 services.pure-ftpd.enable = lib.mkOption {
8 Whether to enable pure-ftpd.
13 config = lib.mkIf config.services.pure-ftpd.enable {
14 security.acme.certs."ftp" = config.services.myCertificates.certConfig // {
15 domain = "eldiron.immae.eu";
17 systemctl restart pure-ftpd.service
21 nixpkgs.config.packageOverrides = oldpkgs: rec {
22 pure-ftpd = pkgs.callPackage ./pure-ftpd.nix {};
27 allowedTCPPorts = [ 21 ];
28 allowedTCPPortRanges = [ { from = 40000; to = 50000; } ];
35 uid = config.ids.uids.ftp;
37 description = "Anonymous FTP user";
38 home = "/homeless-shelter";
42 users.groups.ftp.gid = config.ids.gids.ftp;
44 system.activationScripts.pure-ftpd = ''
45 install -m 0755 -o ftp -g ftp -d /var/lib/ftp
48 systemd.services.pure-ftpd = let
49 ldapConfigFile = pkgs.writeText "pure-ftpd-ldap.conf" ''
50 LDAPServer ${myconfig.env.ftp.ldap.host}
53 LDAPBaseDN ${myconfig.env.ftp.ldap.base}
54 LDAPBindDN ${myconfig.env.ftp.ldap.dn}
55 LDAPBindPW ${myconfig.env.ftp.ldap.password}
57 LDAPForceDefaultUID False
59 LDAPForceDefaultGID False
60 LDAPFilter ${myconfig.env.ftp.ldap.filter}
64 # Pas de possibilité de donner l'Uid/Gid !
65 # Compilé dans pure-ftpd directement avec immaeFtpUid / immaeFtpGid
66 LDAPHomeDir immaeFtpDirectory
68 configFile = pkgs.writeText "pure-ftpd.conf" ''
69 PassivePortRange 40000 50000
72 BrokenClientsCompatibility yes
83 LDAPConfigFile ${ldapConfigFile}
84 LimitRecursion 10000 8
85 AnonymousCanCreateDirs no
93 ProhibitDotFilesWrite no
94 ProhibitDotFilesRead no
96 AnonymousCantUpload no
100 CertFile /var/lib/acme/ftp/full.pem
103 description = "Pure-FTPd server";
104 wantedBy = [ "multi-user.target" ];
105 after = [ "network.target" ];
107 serviceConfig.ExecStart = "${pkgs.pure-ftpd}/bin/pure-ftpd ${configFile}";
108 serviceConfig.Type = "forking";
109 serviceConfig.PIDFile = "/run/pure-ftpd.pid";