add miniflux service

This commit is contained in:
Gerg-L 2023-09-19 18:41:35 -04:00
parent 88e10eb230
commit cde35b5766
Signed by: gerg-l
SSH key fingerprint: SHA256:FPYDHIkvMocr4wdmZXpgpJjsb2Tw6rASs2ISPbOb0KI
4 changed files with 105 additions and 4 deletions

View file

@ -0,0 +1,83 @@
_: {
config,
lib,
pkgs,
...
}: {
sops.secrets.minifluxenv = {
owner = "miniflux";
group = "miniflux";
};
systemd.services = {
miniflux = {
description = "Miniflux service";
wantedBy = ["multi-user.target"];
requires = ["miniflux-dbsetup.service"];
after = ["network.target" "postgresql.service" "miniflux-dbsetup.service"];
script = lib.getExe' pkgs.miniflux "miniflux";
serviceConfig = {
User = "miniflux";
RuntimeDirectory = "miniflux";
RuntimeDirectoryMode = "0770";
EnvironmentFile = config.sops.secrets.minifluxenv.path;
# Hardening
CapabilityBoundingSet = [""];
DeviceAllow = [""];
LockPersonality = true;
MemoryDenyWriteExecute = true;
PrivateDevices = true;
PrivateUsers = true;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictAddressFamilies = ["AF_INET" "AF_INET6" "AF_UNIX"];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = ["@system-service" "~@privileged"];
UMask = "0077";
};
environment = {
LISTEN_ADDR = "/run/miniflux/miniflux.sock";
DATABASE_URL = "user=miniflux host=/run/postgresql dbname=miniflux";
RUN_MIGRATIONS = "1";
CREATE_ADMIN = "1";
};
};
miniflux-dbsetup = {
description = "Miniflux database setup";
requires = ["postgresql.service"];
after = ["network.target" "postgresql.service"];
script = ''
${lib.getExe' config.services.postgresql.package "psql"} "miniflux" -c "CREATE EXTENSION IF NOT EXISTS hstore"
'';
serviceConfig = {
Type = "oneshot";
User = config.services.postgresql.superUser;
};
};
};
users = {
groups.miniflux = {
gid = 377;
};
users = {
miniflux = {
group = "miniflux";
isSystemUser = true;
uid = 377;
};
${config.services.nginx.user}.extraGroups = ["miniflux"];
};
};
}

View file

@ -22,6 +22,13 @@ _: {
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts = {
"_" = {
default = true;
forceSSL = true;
sslCertificate = config.sops.secrets.gerg_ssl_cert.path;
sslCertificateKey = config.sops.secrets.gerg_ssl_key.path;
locations."/".return = "404";
};
"nix-fu.com" = {
forceSSL = true;
sslCertificate = config.sops.secrets.nixfu_ssl_cert.path;
@ -47,6 +54,12 @@ _: {
sslCertificate = config.sops.secrets.gerg_ssl_cert.path;
sslCertificateKey = config.sops.secrets.gerg_ssl_key.path;
};
"flux.gerg-L.com" = {
forceSSL = true;
sslCertificate = config.sops.secrets.gerg_ssl_cert.path;
sslCertificateKey = config.sops.secrets.gerg_ssl_key.path;
locations."/".proxyPass = "http://unix:${config.systemd.services.miniflux.environment.LISTEN_ADDR}";
};
};
};
networking.firewall.allowedTCPPorts = [80 443];

View file

@ -8,17 +8,21 @@ _: {
package = pkgs.postgresql_13;
dataDir = "/persist/services/postgresql";
ensureDatabases = [
"miniflux"
config.services.nextcloud.config.dbname
config.services.gitea.database.user
];
ensureUsers = [
{
name = "miniflux";
ensurePermissions."DATABASE miniflux" = "ALL PRIVILEGES";
}
{
name = config.services.nextcloud.config.dbuser;
ensurePermissions."DATABASE ${config.services.nextcloud.config.dbname}" = "ALL PRIVILEGES";
}
{
name = config.services.gitea.database.user;
ensurePermissions."DATABASE ${config.services.gitea.database.name}" = "ALL PRIVILEGES";
}
];