-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathschizo.nix
176 lines (165 loc) · 4.37 KB
/
schizo.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
{pkgs, ...}:
# this makes our system more secure
# note that it might break some stuff, eg webcam
{
services = {
physlock = {
enable = true;
allowAnyUser = true;
};
tor = {
enable = true;
client.enable = true;
};
networkd-dispatcher = {
enable = true;
rules."restart-tor" = {
onState = ["routable" "off"];
script = ''
#!${pkgs.runtimeShell}
if [[ $IFACE == "wlan0" && $AdministrativeState == "configured" ]]; then
echo "Restarting Tor ..."
systemctl restart tor
fi
exit 0
'';
};
};
};
programs.proxychains = {
enable = true;
quietMode = false;
proxyDNS = true;
package = pkgs.proxychains-ng;
proxies = {
tor = {
type = "socks5";
host = "127.0.0.1";
port = 9050;
};
};
};
programs.ssh.startAgent = true;
security = {
protectKernelImage = false;
lockKernelModules = false;
forcePageTableIsolation = true;
rtkit.enable = true;
apparmor = {
enable = true;
killUnconfinedConfinables = true;
packages = [pkgs.apparmor-profiles];
};
pam = {
services.swaylock.text = "auth include login";
loginLimits = [
{
domain = "@wheel";
item = "nofile";
type = "soft";
value = "524288";
}
{
domain = "@wheel";
item = "nofile";
type = "hard";
value = "1048576";
}
];
services = {
login.enableGnomeKeyring = true;
};
};
sudo = {
enable = true;
extraRules = [
{
commands =
builtins.map (command: {
command = "/run/current-system/sw/bin/${command}";
options = ["NOPASSWD"];
})
["poweroff" "reboot" "nixos-rebuild" "nix-env" "bandwhich" "mic-light-on" "mic-light-off" "systemctl"];
groups = ["wheel"];
}
];
};
};
boot.kernel.sysctl = {
# Hide kernel pointers from processes without the CAP_SYSLOG capability.
"kernel.kptr_restrict" = 1;
"kernel.printk" = "3 3 3 3";
# Restrict loading TTY line disciplines to the CAP_SYS_MODULE capability.
"dev.tty.ldisc_autoload" = 0;
# Make it so a user can only use the secure attention key which is required to access root securely.
"kernel.sysrq" = 4;
# Protect against SYN flooding.
"net.ipv4.tcp_syncookies" = 1;
# Protect against time-wait assasination.
"net.ipv4.tcp_rfc1337" = 1;
# Enable strict reverse path filtering (that is, do not attempt to route
# packets that "obviously" do not belong to the iface's network; dropped
# packets are logged as martians).
"net.ipv4.conf.all.log_martians" = true;
"net.ipv4.conf.all.rp_filter" = "1";
"net.ipv4.conf.default.log_martians" = true;
"net.ipv4.conf.default.rp_filter" = "1";
# Protect against SMURF attacks and clock fingerprinting via ICMP timestamping.
"net.ipv4.icmp_echo_ignore_all" = "1";
# Ignore incoming ICMP redirects (note: default is needed to ensure that the
# setting is applied to interfaces added after the sysctls are set)
"net.ipv4.conf.all.accept_redirects" = false;
"net.ipv4.conf.all.secure_redirects" = false;
"net.ipv4.conf.default.accept_redirects" = false;
"net.ipv4.conf.default.secure_redirects" = false;
"net.ipv6.conf.all.accept_redirects" = false;
"net.ipv6.conf.default.accept_redirects" = false;
# Ignore outgoing ICMP redirects (this is ipv4 only)
"net.ipv4.conf.all.send_redirects" = false;
"net.ipv4.conf.default.send_redirects" = false;
# Restrict abritrary use of ptrace to the CAP_SYS_PTRACE capability.
"kernel.yama.ptrace_scope" = 2;
"net.core.bpf_jit_enable" = false;
"kernel.ftrace_enabled" = false;
};
# Security
boot.blacklistedKernelModules = [
# Obscure network protocols
"ax25"
"netrom"
"rose"
# Old or rare or insufficiently audited filesystems
"adfs"
"affs"
"bfs"
"befs"
"cramfs"
"efs"
"erofs"
"exofs"
"freevxfs"
"f2fs"
"vivid"
"gfs2"
"ksmbd"
"nfsv4"
"nfsv3"
"cifs"
"nfs"
"cramfs"
"freevxfs"
"jffs2"
"hfs"
"hfsplus"
"squashfs"
"udf"
"hpfs"
"jfs"
"minix"
"nilfs2"
"omfs"
"qnx4"
"qnx6"
"sysv"
];
}