tyo0/miniflux: use systemd socket activation

This commit is contained in:
Guanran Wang 2024-09-27 18:56:44 +08:00
parent 3360dcf978
commit ec793dab58
Signed by: nyancat
GPG key ID: 91F97D9ED12639CF
2 changed files with 15 additions and 6 deletions

View file

@ -1,7 +1,6 @@
{ {
lib.ports = { lib.ports = {
keycloak = 8010; keycloak = 8010;
miniflux = 8020;
vaultwarden = 8040; vaultwarden = 8040;
wastebin = 8050; wastebin = 8050;

View file

@ -1,14 +1,24 @@
{ lib, config, ... }: { lib, config, ... }:
let
port = config.lib.ports.miniflux;
in
{ {
# https://miniflux.app/docs/howto.html#systemd-socket-activation
systemd = {
sockets.miniflux = {
description = "Miniflux Socket";
wantedBy = [ "sockets.target" ];
requiredBy = [ "miniflux.service" ];
listenStreams = [ "/run/miniflux.sock" ];
socketConfig.NoDelay = true;
};
services.miniflux = {
serviceConfig.NonBlocking = true;
};
};
services.miniflux = { services.miniflux = {
enable = true; enable = true;
adminCredentialsFile = config.sops.secrets."miniflux/environment".path; adminCredentialsFile = config.sops.secrets."miniflux/environment".path;
config = { config = {
CREATE_ADMIN = 0; CREATE_ADMIN = 0;
LISTEN_ADDR = "127.0.0.1:${toString port}";
BASE_URL = "https://rss.ny4.dev"; BASE_URL = "https://rss.ny4.dev";
OAUTH2_PROVIDER = "oidc"; OAUTH2_PROVIDER = "oidc";
@ -23,7 +33,7 @@ in
match = lib.singleton { host = [ "rss.ny4.dev" ]; }; match = lib.singleton { host = [ "rss.ny4.dev" ]; };
handle = lib.singleton { handle = lib.singleton {
handler = "reverse_proxy"; handler = "reverse_proxy";
upstreams = [ { dial = "localhost:${toString port}"; } ]; upstreams = [ { dial = "unix//run/miniflux.sock"; } ];
}; };
}; };
} }