2019-04-27 23:53:26 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2019-04-27 22:27:25 +00:00
|
|
|
let
|
2019-04-27 19:21:45 +00:00
|
|
|
defaultHardening = {
|
|
|
|
PrivateTmp = "true";
|
|
|
|
ProtectSystem = "full";
|
2019-04-27 22:27:25 +00:00
|
|
|
ProtectHome = "true";
|
2019-04-27 19:21:45 +00:00
|
|
|
NoNewPrivileges = "true";
|
|
|
|
PrivateDevices = "true";
|
|
|
|
MemoryDenyWriteExecute = "true";
|
2019-04-27 22:27:25 +00:00
|
|
|
ProtectKernelTunables = "true";
|
|
|
|
ProtectKernelModules = "true";
|
|
|
|
ProtectControlGroups = "true";
|
|
|
|
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6";
|
2019-04-28 13:11:27 +00:00
|
|
|
RestrictNamespaces = "true";
|
2019-04-27 22:27:25 +00:00
|
|
|
LockPersonality = "true";
|
2019-04-27 23:53:26 +00:00
|
|
|
IPAddressDeny = "any";
|
2019-04-27 19:21:45 +00:00
|
|
|
};
|
2019-04-27 22:27:25 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit defaultHardening;
|
2019-05-03 10:44:16 +00:00
|
|
|
# nodejs applications apparently rely on memory write execute
|
|
|
|
nodejs = { MemoryDenyWriteExecute = "false"; };
|
2019-04-27 23:53:26 +00:00
|
|
|
# Allow tor traffic. Allow takes precedence over Deny.
|
2019-04-28 18:54:13 +00:00
|
|
|
allowTor = {
|
|
|
|
IPAddressAllow = "127.0.0.1/32 ::1/128";
|
|
|
|
};
|
2019-04-27 23:53:26 +00: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 19:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|