nixos-config/config/services/nix-serve.nix

25 lines
801 B
Nix
Raw Normal View History

2022-04-12 08:00:35 +00:00
{ lib, config, ... }:
2022-04-12 07:56:04 +00:00
let
listenIPs = (import ../../utils/getInternalIP.nix config).listenIPs;
listenStatements = lib.concatStringsSep "\n" (builtins.map (ip: "listen ${ip}:443 http3;") listenIPs) + ''
add_header Alt-Svc 'h3=":443"';
'';
in
{
2022-04-12 07:56:04 +00:00
services.nix-serve = {
bindAddress = "127.0.0.1";
enable = true;
2022-04-12 12:18:20 +00:00
secretKeyFile = "/var/cache-priv-key.pem";
2022-04-12 09:33:58 +00:00
};
2022-04-12 07:56:04 +00:00
services.nginx.virtualHosts."cache.int.chir.rs" = {
listenAddresses = listenIPs;
sslCertificate = "/var/lib/acme/int.chir.rs/cert.pem";
sslCertificateKey = "/var/lib/acme/int.chir.rs/key.pem";
locations."/" = {
proxyPass = "http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}";
proxyWebsockets = true;
};
extraConfig = listenStatements;
};
}