1
0
Fork 0
dotfiles/system/nixos/nitter.nix

75 lines
2.2 KiB
Nix
Raw Normal View History

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
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" ];
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.virtualHosts."${secret.nginx.hostnames.nitter}" = {
http3 = true;
2023-03-06 09:21:34 +00:00
root = "${nitter-pkg}/share/nitter/public/";
onlySSL = true;
useACMEHost = "daniel.sx";
2023-02-13 19:04:45 +00:00
locations."/" = {
tryFiles = "$uri @proxy";
};
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
}