From 2959b8cf259f9dacda38db73a40a978732c783ca Mon Sep 17 00:00:00 2001 From: Andre Date: Fri, 25 Oct 2024 16:54:19 -0400 Subject: [PATCH] Services: add webdav service --- hosts/Hevana/default.nix | 7 ++++ modules/secrets/default.nix | Bin 4650 -> 4970 bytes modules/services/webdav.nix | 68 ++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 modules/services/webdav.nix diff --git a/hosts/Hevana/default.nix b/hosts/Hevana/default.nix index 9a988e7..2a0a7f0 100644 --- a/hosts/Hevana/default.nix +++ b/hosts/Hevana/default.nix @@ -20,6 +20,7 @@ let # List of subdomains to add to the TLS certificate subdomains = with config.secrets.services; [ + dav.url forgejo.url gremlin-lab.url jellyfin.url @@ -212,6 +213,12 @@ in ram = 4096; }; }; + webdav = { + enable = false; + home = "${services-root}/webdav"; + url = config.secrets.services.webdav.url; + users = config.secrets.services.webdav.users; + }; }; users.aires = { diff --git a/modules/secrets/default.nix b/modules/secrets/default.nix index 338ee0774196f97a414089ecb9b136e7d41be012..6eb92bfa03e9a256dd49f39a32a37ec2bdc549a9 100644 GIT binary patch literal 4970 zcmV-w6P4@$M@dveQdv+`02@O@G&w9psVlwGeR0o2!z>2kM`4onWN!@{JL{Vna!kQF z*bPJ6jRTj-Y@-s}zwmUNe-0eF0FvgG1?~^*66zNUk;5YTDO3XVV2*H2QeJ7~ta&)< z)uB~;Bf#3+yqow!l;N1Rm4KUwD{lJ}M^2$9=eMX^x+I^P%rM=C@B1E##;ABfSe&9y z{hHTOWi+06&mp32z>1-rmMwSHXbG{4(VdZgEG2IHr#H{mqY(MVcRn>L7%(g_F?1v{ z#pY%4tycQfKFf}1`&RtOBw!g!*+w=up$6TRaf3E`O7}DmxDn~F9j8YBQn2m>FRvDq z-m1^zxKsfMym&JeY-3n|!!+J}PP#qjsQ6C(R+1u4=+!gaiB}k)34Q|2>VL(MWd>C4Qe1)qrwXYf(A>7PXQ0@P&oN;MU_F6j z|FmS-EnJ-K*tT9K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Ep-iYUM8c zK0`QYa9g&`bKUBk5CuZb`?%$ITRb?|3m%S-&g39{?XitW{CqS{2SDuau|>>M-S!Mu g!@RF&kPY{uj-qfvoRf1}0;a#!y9bSCzGE;Ft-0(Ea{vGU diff --git a/modules/services/webdav.nix b/modules/services/webdav.nix new file mode 100644 index 0000000..2e6dde1 --- /dev/null +++ b/modules/services/webdav.nix @@ -0,0 +1,68 @@ +{ + pkgs, + config, + lib, + ... +}: +let + cfg = config.aux.system.services.webdav; + + port = 6065; # Internal port to run the server on +in +{ + options = { + aux.system.services.webdav = { + enable = lib.mkEnableOption "Enables Webdav server."; + home = lib.mkOption { + default = "/var/lib/webdav"; + type = lib.types.str; + description = "Where to store Webdav's files"; + example = "/home/webdav"; + }; + url = lib.mkOption { + default = ""; + type = lib.types.str; + description = "The complete URL where Webdav is hosted."; + example = "https://dav.example.com"; + }; + users = lib.mkOption { + default = [ ]; + type = lib.types.listOf lib.types.attrs; + description = "List of user accounts to create."; + example = lib.literalExpression "[ { username = \"user\"; password = \"pass\"; } ]"; + }; + }; + }; + + config = lib.mkIf cfg.enable { + services = { + webdav = { + enable = true; + settings = { + address = "127.0.0.1"; + port = port; + scope = cfg.home; + users = cfg.users; + }; + }; + + nginx.virtualHosts."${cfg.url}" = { + useACMEHost = pkgs.util.getDomainFromURL cfg.url; + forceSSL = true; + locations."/".extraConfig = '' + proxy_pass http://127.0.0.1:${builtins.toString port}; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header REMOTE-HOST $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_redirect off; + ''; + }; + }; + + systemd.services = { + webdav.unitConfig.RequiresMountsFor = cfg.home; + nginx.wants = [ config.systemd.services.webdav.name ]; + }; + }; +}