2019-04-28 02:53:26 +03:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2019-04-28 01:27:25 +03:00
|
|
|
let
|
2019-04-27 22:21:45 +03:00
|
|
|
defaultHardening = {
|
|
|
|
PrivateTmp = "true";
|
|
|
|
ProtectSystem = "full";
|
2019-04-28 01:27:25 +03:00
|
|
|
ProtectHome = "true";
|
2019-04-27 22:21:45 +03:00
|
|
|
NoNewPrivileges = "true";
|
|
|
|
PrivateDevices = "true";
|
|
|
|
MemoryDenyWriteExecute = "true";
|
2019-04-28 01:27:25 +03:00
|
|
|
ProtectKernelTunables = "true";
|
|
|
|
ProtectKernelModules = "true";
|
|
|
|
ProtectControlGroups = "true";
|
|
|
|
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6";
|
2019-04-28 16:11:27 +03:00
|
|
|
RestrictNamespaces = "true";
|
2019-04-28 01:27:25 +03:00
|
|
|
LockPersonality = "true";
|
2019-04-28 02:53:26 +03:00
|
|
|
IPAddressDeny = "any";
|
2019-04-27 22:21:45 +03:00
|
|
|
};
|
2019-04-28 01:27:25 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit defaultHardening;
|
2019-05-03 13:44:16 +03:00
|
|
|
# nodejs applications apparently rely on memory write execute
|
|
|
|
nodejs = { MemoryDenyWriteExecute = "false"; };
|
2019-04-28 02:53:26 +03:00
|
|
|
# Allow tor traffic. Allow takes precedence over Deny.
|
2019-04-28 21:54:13 +03:00
|
|
|
allowTor = {
|
|
|
|
IPAddressAllow = "127.0.0.1/32 ::1/128";
|
|
|
|
};
|
2019-04-28 02:53:26 +03:00
|
|
|
# Allow any traffic
|
|
|
|
allowAnyIP = { IPAddressAllow = "any"; };
|
|
|
|
|
|
|
|
enforceTor = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
"Whether to force Tor on a service by only allowing connections from and
|
|
|
|
to 127.0.0.1;";
|
|
|
|
'';
|
|
|
|
};
|
2019-04-27 22:21:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|