blob: 78f7c794ce1fafab8eff6ab284192add4de96570 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.ftp;
in
{
options = {
ftp = {
files = mkOption {
default = {};
type = with types; attrsOf path;
description = ''
Files to serve on https://ftp.qyliss.net/
'';
example = literalExample ''
{
"foo/bar.txt" = pkgs.writeText "bar.txt" ''''
Hello, world!
'''';
}
'';
};
};
};
config = {
services.nginx.virtualHosts."ftp.qyliss.net" = {
forceSSL = true;
enableACME = true;
root = pkgs.runCommandNoCC "ftp.qyliss.net" {} ''
mkdir $out
${concatStrings (mapAttrsToList (httpPath: diskPath: ''
mkdir -p "$out/$(dirname ${escapeShellArg httpPath})"
ln -s ${escapeShellArg diskPath} $out/${escapeShellArg httpPath}
'') cfg.files)}
'';
extraConfig = ''
autoindex on;
'';
};
};
}
|