1 { lib, hostName, ... }:
3 domain = "sourcephile.fr";
4 nginxRoot = "/var/lib/nginx/${domain}/sftp";
5 sftpRoot = "/var/lib/sftp";
12 fileSystems.${sftpRoot} = {
13 device = "${hostName}/var/sftp";
16 services.sanoid.datasets."${hostName}/var/sftp" = {
17 use_template = [ "snap" ];
21 services.syncoid.commands = {
22 "${hostName}/var/sftp" = {
24 target = "backup@mermet.${networking.domain}:rpool/backup/${hostName}/var/sftp";
28 services.nginx.virtualHosts =
33 fancyindex_exact_size off;
34 fancyindex_name_length 255;
36 #open_file_cache_valid 1s;
40 locations = lib.listToAttrs
43 lib.nameValuePair "/${user}/" {
45 location /${user}/public/ {
48 location /${user}/perso/ {
51 auth_basic_user_file ${sftpRoot}/${user}/perso.htpasswd;
64 "sftp.${hostName}.sp" = lib.mkMerge [
67 listenAddresses = [ "${hostName}.sp" ];
69 access_log /var/log/nginx/wg-intra/${hostName}/sftp/access.json json buffer=32k;
70 error_log /var/log/nginx/wg-intra/${hostName}/sftp/error.log warn;
74 "sftp.${domain}" = lib.mkMerge [
80 access_log /var/log/nginx/${domain}/${hostName}/sftp/access.json json buffer=32k;
81 error_log /var/log/nginx/${domain}/${hostName}/sftp/error.log warn;
86 systemd.services.nginx = {
88 LogsDirectory = lib.mkForce [
89 "nginx/wg-intra/${hostName}/sftp"
90 "nginx/${domain}/${hostName}/sftp"
92 BindReadOnlyPaths = lib.concatMap
94 "${sftpRoot}/${user}/public:${nginxRoot}/${user}/public"
95 "${sftpRoot}/${user}/perso:${nginxRoot}/${user}/perso"
100 fileSystems."${sftpRoot}/torrents" = {
101 device = "/var/lib/transmission/downloaded";
102 options = [ "bind" "ro" ];
104 fileSystems."${sftpRoot}/podcasts" = {
105 device = "/home/julm/dl";
106 options = [ "bind" "ro" ];
108 services.openssh.extraConfig = ''
110 AllowAgentForwarding no
111 AllowTcpForwarding no
112 ChrootDirectory ${sftpRoot}
113 ForceCommand internal-sftp -u 0002