2023-02-14 10:04:10 +00:00
|
|
|
{ pkgs, config, ... }:
|
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
|
|
|
proxy-no-auth = {
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
proxyPass = "http://127.0.0.1:8001";
|
|
|
|
};
|
|
|
|
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";
|
|
|
|
Environment = [ "NITTER_CONF_FILE=${config.age.secrets.nitter-config.path}" ];
|
|
|
|
# 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
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
2023-02-20 19:24:34 +00:00
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedBrotliSettings = true;
|
|
|
|
|
2023-02-13 19:04:45 +00:00
|
|
|
virtualHosts."nitter.only.internal" = {
|
|
|
|
listen = [
|
|
|
|
{
|
|
|
|
addr = "127.0.0.1";
|
|
|
|
port = 80;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2023-02-14 10:04:10 +00:00
|
|
|
root = "${nitter-pkg}/share/nitter/public/";
|
2023-02-13 19:04:45 +00:00
|
|
|
forceSSL = false;
|
|
|
|
enableACME = false;
|
|
|
|
|
|
|
|
locations."/" = {
|
2023-02-14 10:04:10 +00:00
|
|
|
tryFiles = "$uri @proxy";
|
2023-02-13 20:39:00 +00:00
|
|
|
};
|
|
|
|
|
2023-02-13 21:06:22 +00:00
|
|
|
locations."/pic/" = proxy-no-auth;
|
|
|
|
locations."/video/" = proxy-no-auth;
|
2023-02-14 10:04:10 +00:00
|
|
|
|
|
|
|
locations."@proxy" = {
|
|
|
|
basicAuthFile = config.age.secrets.nitter-auth.path;
|
|
|
|
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
|
|
|
}
|