summary refs log tree commit diff stats
path: root/modules/by-name/re/redlib/module.nix
blob: 2b20c6606b18ff48638b9a3b33598fcbb67afff4 (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
{
  config,
  pkgsUnstable,
  lib,
  ...
}: let
  domain = "redlib.vhack.eu";

  cfg = config.vhack.redlib;
in {
  options.vhack.redlib = {
    enable = lib.mkEnableOption ''
      the redlib reddit frontend
    '';
  };

  config = lib.mkIf cfg.enable {
    services.redlib = {
      enable = true;
      package = pkgsUnstable.redlib;
      port = 8080;
      address = "127.0.0.1";
      openFirewall = false;
    };

    services.nginx = {
      enable = true;
      virtualHosts.${domain} = {
        locations."/".proxyPass = "http://127.0.0.1:${toString config.services.redlib.port}";

        enableACME = true;
        forceSSL = true;
      };

      # TODO: Remove this at a certain point. <2024-12-19>
      virtualHosts."libreddit.vhack.eu" = {
        locations."/".return = "301 https://${domain}";

        forceSSL = true;
        enableACME = true;
      };
    };
  };
}