1
0
Fork 0
piped-flake/module/frontend.nix

29 lines
769 B
Nix

{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.services.piped;
frontendPackage =
cfg.frontendPackage.override {backendDomain = cfg.backendDomain;};
in {
config = mkIf (cfg.enable && !cfg.disableFrontend && !cfg.disableNginx) {
# https://github.com/TeamPiped/Piped/blob/master/docker/nginx.conf
services.nginx.virtualHosts."${cfg.frontendDomain}" = {
forceSSL = cfg.nginxForceSSL;
enableACME = cfg.nginxEnableACME;
locations."/" = {
root = "${frontendPackage}/share/piped-frontend";
index = "index.html index.htm";
};
# I have no idea why try_files for Single Page Apps doesn't work here
extraConfig = ''
error_page 404 =200 /index.html;
'';
};
};
}