forked from mirrors/nixpkgs
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
128 lines
3.6 KiB
Nix
128 lines
3.6 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
let
|
|
cfg = config.services.miniflux;
|
|
|
|
defaultAddress = "localhost:8080";
|
|
|
|
dbUser = "miniflux";
|
|
dbName = "miniflux";
|
|
|
|
pgbin = "${config.services.postgresql.package}/bin";
|
|
preStart = pkgs.writeScript "miniflux-pre-start" ''
|
|
#!${pkgs.runtimeShell}
|
|
${pgbin}/psql "${dbName}" -c "CREATE EXTENSION IF NOT EXISTS hstore"
|
|
'';
|
|
in
|
|
|
|
{
|
|
options = {
|
|
services.miniflux = {
|
|
enable = mkEnableOption "miniflux and creates a local postgres database for it";
|
|
|
|
config = mkOption {
|
|
type = types.attrsOf types.str;
|
|
example = literalExpression ''
|
|
{
|
|
CLEANUP_FREQUENCY = "48";
|
|
LISTEN_ADDR = "localhost:8080";
|
|
}
|
|
'';
|
|
description = lib.mdDoc ''
|
|
Configuration for Miniflux, refer to
|
|
<https://miniflux.app/docs/configuration.html>
|
|
for documentation on the supported values.
|
|
|
|
Correct configuration for the database is already provided.
|
|
By default, listens on ${defaultAddress}.
|
|
'';
|
|
};
|
|
|
|
adminCredentialsFile = mkOption {
|
|
type = types.path;
|
|
description = lib.mdDoc ''
|
|
File containing the ADMIN_USERNAME and
|
|
ADMIN_PASSWORD (length >= 6) in the format of
|
|
an EnvironmentFile=, as described by systemd.exec(5).
|
|
'';
|
|
example = "/etc/nixos/miniflux-admin-credentials";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.miniflux.config = {
|
|
LISTEN_ADDR = mkDefault defaultAddress;
|
|
DATABASE_URL = "user=${dbUser} host=/run/postgresql dbname=${dbName}";
|
|
RUN_MIGRATIONS = "1";
|
|
CREATE_ADMIN = "1";
|
|
};
|
|
|
|
services.postgresql = {
|
|
enable = true;
|
|
ensureUsers = [ {
|
|
name = dbUser;
|
|
ensurePermissions = {
|
|
"DATABASE ${dbName}" = "ALL PRIVILEGES";
|
|
};
|
|
} ];
|
|
ensureDatabases = [ dbName ];
|
|
};
|
|
|
|
systemd.services.miniflux-dbsetup = {
|
|
description = "Miniflux database setup";
|
|
requires = [ "postgresql.service" ];
|
|
after = [ "network.target" "postgresql.service" ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = config.services.postgresql.superUser;
|
|
ExecStart = preStart;
|
|
};
|
|
};
|
|
|
|
systemd.services.miniflux = {
|
|
description = "Miniflux service";
|
|
wantedBy = [ "multi-user.target" ];
|
|
requires = [ "miniflux-dbsetup.service" ];
|
|
after = [ "network.target" "postgresql.service" "miniflux-dbsetup.service" ];
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${pkgs.miniflux}/bin/miniflux";
|
|
User = dbUser;
|
|
DynamicUser = true;
|
|
RuntimeDirectory = "miniflux";
|
|
RuntimeDirectoryMode = "0700";
|
|
EnvironmentFile = cfg.adminCredentialsFile;
|
|
# 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" "~@resources" ];
|
|
UMask = "0077";
|
|
};
|
|
|
|
environment = cfg.config;
|
|
};
|
|
environment.systemPackages = [ pkgs.miniflux ];
|
|
};
|
|
}
|