2022-04-10 11:54:58 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
2022-01-11 16:08:21 +01:00
|
|
|
mkEnableOption
|
|
|
|
mkIf
|
|
|
|
mkOption
|
2022-04-10 11:54:58 +02:00
|
|
|
;
|
2022-01-11 16:08:21 +01:00
|
|
|
|
2021-01-30 21:14:27 +01:00
|
|
|
cfg = config.my.services.miniflux;
|
2021-01-30 22:15:33 +01:00
|
|
|
my = config.my;
|
2021-01-30 21:14:27 +01:00
|
|
|
|
|
|
|
domain = config.networking.domain;
|
|
|
|
in {
|
2022-04-10 11:54:58 +02:00
|
|
|
options.my.services.miniflux = let
|
|
|
|
inherit (lib) types;
|
|
|
|
in {
|
2021-01-30 21:14:27 +01:00
|
|
|
enable = mkEnableOption "Serve a Miniflux instance";
|
|
|
|
|
|
|
|
adminCredentialsFile = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = null;
|
|
|
|
example = "./secrets/miniflux-admin-credentials";
|
|
|
|
description = "File containing ADMIN_USERNAME= and ADMIN_PASSWORD=";
|
|
|
|
};
|
|
|
|
|
|
|
|
privatePort = mkOption {
|
2021-02-02 18:24:28 +01:00
|
|
|
type = types.port;
|
2021-01-30 21:14:27 +01:00
|
|
|
default = 8080;
|
|
|
|
example = 8080;
|
|
|
|
description = "Port to serve the app";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# services.postgresql is automatically enabled by services.miniflux, let's
|
|
|
|
# back it up
|
2021-03-23 22:24:12 +01:00
|
|
|
services.postgresqlBackup = {
|
2022-04-10 11:54:58 +02:00
|
|
|
databases = ["miniflux"];
|
2021-01-30 21:14:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.miniflux = {
|
|
|
|
enable = true;
|
|
|
|
adminCredentialsFile = cfg.adminCredentialsFile;
|
|
|
|
# TODO: setup metrics collection
|
|
|
|
config = {
|
|
|
|
LISTEN_ADDR = "127.0.0.1:${toString cfg.privatePort}";
|
|
|
|
BASE_URL = "https://reader.${domain}/";
|
2021-02-05 22:00:15 +01:00
|
|
|
|
|
|
|
CLEANUP_ARCHIVE_UNREAD_DAYS = "-1";
|
|
|
|
CLEANUP_ARCHIVE_READ_DAYS = "-1";
|
2021-01-30 21:14:27 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
virtualHosts = {
|
|
|
|
"reader.${domain}" = {
|
|
|
|
forceSSL = true;
|
2021-07-13 00:57:33 +02:00
|
|
|
useACMEHost = domain;
|
2021-01-30 21:14:27 +01:00
|
|
|
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:${toString cfg.privatePort}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|