ctucx.git: nixfiles

ctucx' nixfiles

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 { inputs, lib, pkgs, config, ... }:

let

  configFile = pkgs.writeTextDir "config.json" (builtins.toJSON (import ./config.nix));

in {

  services.dnsmasq.settings.cname                  = [ "smart.home.ctu.cx, home.ctu.cx" ];


  services = {
    nginx    = {
      enable = true;
      virtualHosts."smart.home.ctu.cx" = {
        enableACME = lib.mkIf config.networking.usePBBUplink true;
        forceSSL   = lib.mkIf config.networking.usePBBUplink true;
        kTLS       = lib.mkIf config.networking.usePBBUplink true;

        locations  = {
          "/" = {
            root  = "${pkgs.buildEnv {
              name  = "mqtt-webui-env";
              paths = [
                pkgs.mqtt-webui
                configFile
                ./extra-css
              ];
            }}/";
          };
          "/mqtt" = {
            proxyPass       = "http://[::1]:9005";
            proxyWebsockets = true;
          };
        };
      };
    };

  };

}