about summary refs log tree commit diff
path: root/nixosConfigurations/manwe/webserver.nix
blob: d0784e87a25aea67aec2ae3e32c0ac5a7bd97b5f (plain) (blame)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
  inputs,
  lib,
  libNginx,
  libPlausible,
  ...
}:
with lib; {
  nixfiles.modules.nginx = {
    enable = true;
    virtualHosts = with my.domain;
      {
        # TODO Start using this.
        # "start.local" = {
        #   root = pkgs.hiccup;
        #   locations = {
        #     "/".tryFiles = "$uri $uri/ /index.html";
        #     "~* ^.+config.json$".extraConfig = let
        #       config = pkgs.writeText "config.json" (generators.toJSON {} {
        #         version = "2.0";
        #         id = "default";
        #         title = "Demo Config";
        #         url = "./configs/config.json";
        #         featured = [
        #           {
        #             name = "GitHub";
        #             background = "/assets/card.png";
        #             link = "https://github.com/ashwin-pc/hiccup";
        #           }
        #         ];
        #         categories = [
        #           {
        #             title = "Category 1";
        #             links = [
        #               {
        #                 name = "Link 1";
        #                 link = "https://example.com";
        #               }
        #             ];
        #           }
        #           {
        #             title = "Category 2";
        #             links = [
        #               {
        #                 name = "Link 1";
        #                 link = "https://example.com";
        #               }
        #             ];
        #           }
        #           {
        #             title = "Category 3";
        #             links = [
        #               {
        #                 name = "Link 1";
        #                 link = "https://example.com";
        #               }
        #             ];
        #           }
        #           {
        #             title = "Category 4";
        #             links = [
        #               {
        #                 name = "Link 1";
        #                 link = "https://example.com";
        #               }
        #             ];
        #           }
        #         ];
        #       });
        #     in ''
        #       alias ${config};
        #     '';
        #   };
        #   enableACME = false;
        #   forceSSL = false;
        # };
        ${shire}.locations."/".return = "301 https://www.youtube.com/watch?v=dQw4w9WgXcQ";
        "git.${shire}".locations."/".return = "301 https://git.${azahi}";
        "bitwarden.${shire}".locations."/".return = "301 https://vaultwarden.${shire}";
        ${azahi} = {
          serverAliases = ["frodo.${gondor}" "frodo.${rohan}"];
          locations."/" = {
            root = inputs.azahi-cc;
            extraConfig = libNginx.config.appendHead [
              (libPlausible.htmlPlausibleScript {domain = azahi;})
            ];
          };
        };
      }
      // (let
        frodo = "301 https://frodo.";
      in {
        ${gondor}.locations."/".return = concatStrings [frodo gondor];
        ${rohan}.locations."/".return = concatStrings [frodo rohan];
      });
  };
}

Consider giving Nix/NixOS a try! <3