2023-03-06 08:55:28 +00:00
|
|
|
{ pkgs, config, secret, ... }:
|
2023-02-13 18:44:04 +00:00
|
|
|
|
2023-02-13 21:06:22 +00:00
|
|
|
let
|
2023-12-03 17:03:24 +00:00
|
|
|
nitter-pkg = pkgs.nitter;
|
2023-02-13 21:06:22 +00:00
|
|
|
in
|
2023-02-13 18:44:04 +00:00
|
|
|
{
|
2023-02-14 10:04:10 +00:00
|
|
|
# Based on: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/misc/nitter.nix
|
|
|
|
|
|
|
|
systemd.services.nitter = {
|
|
|
|
description = "Nitter (An alternative Twitter front-end)";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2023-06-21 12:21:40 +00:00
|
|
|
requires = [ "redis-nitter.service" ];
|
|
|
|
after = [ "network.target" "network-online.target" "redis-nitter.service" ];
|
2023-02-14 10:04:10 +00:00
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
StateDirectory = "nitter";
|
2023-03-20 18:47:31 +00:00
|
|
|
LoadCredential = [ "config:${config.age.secrets.nitter-config.path}" ];
|
2023-09-17 21:25:43 +00:00
|
|
|
Environment = [
|
|
|
|
"NITTER_CONF_FILE=%d/config"
|
|
|
|
"NITTER_ACCOUNTS_FILE=/var/lib/nitter/guest_accounts.json"
|
|
|
|
];
|
2023-02-14 10:04:10 +00:00
|
|
|
# Some parts of Nitter expect `public` folder in working directory,
|
|
|
|
# see https://github.com/zedeus/nitter/issues/414
|
|
|
|
WorkingDirectory = "${nitter-pkg}/share/nitter";
|
|
|
|
ExecStart = "${nitter-pkg}/bin/nitter";
|
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSec = "5s";
|
|
|
|
# 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" ];
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
SystemCallFilter = [ "@system-service" "~@privileged" "~@resources" ];
|
|
|
|
UMask = "0077";
|
2023-02-13 18:44:04 +00:00
|
|
|
};
|
|
|
|
};
|
2023-02-13 19:04:45 +00:00
|
|
|
|
2023-06-21 12:21:40 +00:00
|
|
|
services.redis.servers.nitter = {
|
|
|
|
enable = true;
|
|
|
|
bind = "127.0.0.1";
|
|
|
|
port = 6380;
|
|
|
|
|
|
|
|
databases = 1;
|
|
|
|
save = [ ];
|
|
|
|
appendFsync = "no";
|
|
|
|
};
|
|
|
|
|
2023-03-12 20:03:36 +00:00
|
|
|
services.nginx.virtualHosts."${secret.nginx.hostnames.nitter}" = {
|
2023-09-21 19:38:44 +00:00
|
|
|
listenAddresses = [ "100.64.10.2" "[fd7a:115c:a1e0:1010::2]" ];
|
2023-04-03 13:03:52 +00:00
|
|
|
quic = true;
|
2023-03-12 20:03:36 +00:00
|
|
|
http3 = true;
|
2023-03-06 09:21:34 +00:00
|
|
|
|
2023-03-12 20:03:36 +00:00
|
|
|
root = "${nitter-pkg}/share/nitter/public/";
|
|
|
|
onlySSL = true;
|
|
|
|
useACMEHost = "daniel.sx";
|
2023-02-13 19:04:45 +00:00
|
|
|
|
2023-03-12 20:03:36 +00:00
|
|
|
locations."/" = {
|
|
|
|
tryFiles = "$uri @proxy";
|
|
|
|
};
|
2023-02-13 20:39:00 +00:00
|
|
|
|
2023-03-12 20:03:36 +00:00
|
|
|
locations."@proxy" = {
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
proxyPass = "http://127.0.0.1:8001";
|
2023-02-13 19:04:45 +00:00
|
|
|
};
|
|
|
|
};
|
2023-02-13 18:44:04 +00:00
|
|
|
}
|