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-02-14 10:04:10 +00:00
|
|
|
nitter-pkg = pkgs.nitter-unstable;
|
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-02-14 19:05:02 +00:00
|
|
|
after = [ "network.target" "network-online.target" ];
|
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}" ];
|
|
|
|
Environment = [ "NITTER_CONF_FILE=%d/config" ];
|
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-03-12 20:03:36 +00:00
|
|
|
services.nginx.virtualHosts."${secret.nginx.hostnames.nitter}" = {
|
2023-04-03 12:52:41 +00:00
|
|
|
listenAddresses = [ "100.113.242.85" "[fd7a:115c:a1e0:ab12:4843:cd96:6271:f255]" ];
|
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
|
|
|
}
|