1 { inputs, pkgs, lib, config, 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 = let
32 fancyindex_exact_size off;
33 fancyindex_name_length 255;
35 #open_file_cache_valid 1s;
39 locations = lib.listToAttrs (map (user:
40 lib.nameValuePair "/${user}/" {
42 location /${user}/public/ {
45 location /${user}/perso/ {
48 auth_basic_user_file ${sftpRoot}/${user}/perso.htpasswd;
59 "sftp.${hostName}.wg" = lib.mkMerge [ virtualHost {
60 listenAddresses = [ "${hostName}.wg" ];
62 access_log /var/log/nginx/wg-intra/${hostName}/sftp/access.json json buffer=32k;
63 error_log /var/log/nginx/wg-intra/${hostName}/sftp/error.log warn;
66 "sftp.${domain}" = lib.mkMerge [ virtualHost {
70 access_log /var/log/nginx/${domain}/${hostName}/sftp/access.json json buffer=32k;
71 error_log /var/log/nginx/${domain}/${hostName}/sftp/error.log warn;
75 systemd.services.nginx = {
77 LogsDirectory = lib.mkForce [
78 "nginx/wg-intra/${hostName}/sftp"
79 "nginx/${domain}/${hostName}/sftp"
81 BindReadOnlyPaths = lib.concatMap (user: [
82 "${sftpRoot}/${user}/public:${nginxRoot}/${user}/public"
83 "${sftpRoot}/${user}/perso:${nginxRoot}/${user}/perso"
87 fileSystems."${sftpRoot}/torrents" = {
88 device = "/var/lib/transmission/downloaded";
89 options = [ "bind" "ro" ];
91 fileSystems."${sftpRoot}/podcasts" = {
92 device = "/home/julm/dl";
93 options = [ "bind" "ro" ];
95 services.openssh.extraConfig = ''
97 AllowAgentForwarding no
99 ChrootDirectory ${sftpRoot}
100 ForceCommand internal-sftp -u 0002