summary refs log tree commit diff stats
path: root/modules/by-name/mi/miniflux/module.nix
blob: ca6f476aa9ea905703700cc3da84b2a73088ca06 (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
{
  config,
  lib,
  ...
}: let
  cfg = config.vhack.miniflux;
in {
  options.vhack.miniflux = {
    enable = lib.mkEnableOption "miniflux, an simple web rss reading software";
    domain = lib.mkOption {
      type = lib.types.str;
      description = "The primary domain miniflux should be served on";
    };
    extraDomains = lib.mkOption {
      type = lib.types.listOf lib.types.str;
      description = "Additional domains to serve miniflux on";
      default = [];
    };
  };
  config = lib.mkIf cfg.enable {
    age.secrets = {
      minifluxAdmin = {
        file = ./secrets/admin.age;
        mode = "700";
        owner = "root";
        group = "root";
      };
    };
    services.miniflux = {
      enable = true;
      config = {
        LISTEN_ADDR = "127.0.0.1:5892";
      };
      adminCredentialsFile = config.age.secrets.minifluxAdmin.path;
    };

    vhack = {
      nginx.enable = true;
      postgresql.enable = true;
    };
    services.nginx = {
      virtualHosts.${cfg.domain} = {
        locations."/".proxyPass = "http://${config.services.miniflux.config.LISTEN_ADDR}";

        enableACME = true;
        forceSSL = true;
        serverAliases = cfg.extraDomains;
      };
    };
  };
}