about summary refs log tree commit diff
path: root/modules/server
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-04-15 16:32:46 +0000
committerAlyssa Ross <hi@alyssa.is>2020-04-15 16:41:53 +0000
commitfc6bf53d4d788795a124edc07d9883df9190be0a (patch)
treed90780627a947ab012ab46cdff7ea13b99aa3b55 /modules/server
parentb394434a89f25fe74aa2c43f376454921216ad80 (diff)
downloadnixlib-fc6bf53d4d788795a124edc07d9883df9190be0a.tar
nixlib-fc6bf53d4d788795a124edc07d9883df9190be0a.tar.gz
nixlib-fc6bf53d4d788795a124edc07d9883df9190be0a.tar.bz2
nixlib-fc6bf53d4d788795a124edc07d9883df9190be0a.tar.lz
nixlib-fc6bf53d4d788795a124edc07d9883df9190be0a.tar.xz
nixlib-fc6bf53d4d788795a124edc07d9883df9190be0a.tar.zst
nixlib-fc6bf53d4d788795a124edc07d9883df9190be0a.zip
modules/ftp: init
Diffstat (limited to 'modules/server')
-rw-r--r--modules/server/ftp/default.nix46
1 files changed, 46 insertions, 0 deletions
diff --git a/modules/server/ftp/default.nix b/modules/server/ftp/default.nix
new file mode 100644
index 000000000000..2b444ae2b32f
--- /dev/null
+++ b/modules/server/ftp/default.nix
@@ -0,0 +1,46 @@
+{ 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" {} ''
+        ${concatStrings (mapAttrsToList (httpPath: diskPath: ''
+          mkdir -p "$out/$(dirname ${escapeShellArg httpPath})"
+          ln -s ${escapeShellArg diskPath} $out/${escapeShellArg httpPath}
+        '') cfg.files)}
+      '';
+
+      extraConfig = ''
+        autoindex on;
+      '';
+    };
+  };
+}