This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.nix
233 lines (219 loc) · 5.58 KB
/
configuration.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
{ config, pkgs, lib, ... }: {
imports = [
./hardware-configuration.nix
];
# NVIDIA GP104 [GeForce GTX 1070] 01:00.0
services.xserver.videoDrivers = ["nvidia"]; # proprietary
hardware.nvidia.nvidiaPersistenced = true; # keep GPUs awake in headless-mode
nixpkgs.config = {
allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
"nvidia-x11"
"nvidia-settings"
"nvidia-persistenced"
];
};
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
networking = {
hostName = "charmander";
interfaces = {
enp0s31f6.ipv4.addresses = [{
address = "192.168.1.39";
prefixLength = 24;
}];
};
defaultGateway = {
address = "192.168.1.1";
interface = "enp0s31f6";
};
# TODO https://nixos.wiki/wiki/Encrypted_DNS
nameservers = [ "1.1.1.1" "8.8.8.8" ];
};
time.timeZone = "America/Los_Angeles";
users = {
groups = {
a1 = {};
acme = {};
steam = {};
};
users = {
root = {
openssh.authorizedKeys.keyFiles = [
/etc/nixos/ssh/authorized_keys
];
};
a1 = {
isSystemUser = true;
home = "/opt/automatic1111";
shell = "/run/current-system/sw/bin/bash";
packages = with pkgs; [
git
tmux
];
group = "a1";
};
acme = {
isSystemUser = true;
createHome = true;
home = "/var/acme";
shell = "/run/current-system/sw/bin/nologin";
group = "acme";
};
blee = {
openssh.authorizedKeys.keyFiles = [
/etc/nixos/ssh/authorized_keys
];
isNormalUser = true;
extraGroups = [ "wheel" ];
packages = with pkgs; [
curl
dnsutils
git
jq
netcat
tmux
wget
];
};
nginx = {
extraGroups = [ "acme" ];
};
steam = {
openssh.authorizedKeys.keyFiles = [
/etc/nixos/ssh/authorized_keys
];
isNormalUser = true;
};
timburr = {
openssh.authorizedKeys.keyFiles = [
/etc/nixos/ssh/authorized_timburr_keys
];
isNormalUser = true;
extraGroups = [ "wheel" ];
};
};
};
# permit read access to certificates for the users in the acme group, such as nginx
systemd.tmpfiles.rules = [
"d /var/acme 0750 acme acme - -"
"d /var/acme/certificates 0750 acme acme - -"
];
#services.udev.packages = with pkgs; [ gnome.gnome-settings-daemon ];
environment = {
systemPackages = with pkgs; [
doas
file
htop
libressl
nettools
nginx # for running nginx -t
psmisc
rsync
tcpdump
tree
vim
# GPU tools
inxi
glxinfo
pciutils # lspci
];
shellInit = ''
export EDITOR=vim
export VISUAL=vim
pheonix() {
systemctl restart "$1"
journalctl -fu "$1"
}
'';
};
programs = {
bash.shellAliases = {
ll = "ls -lAF --classify --group-directories-first";
l = "ls -lF --classify --group-directories-first";
};
mtr.enable = true;
gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
};
networking.firewall.enable = false;
security = {
sudo.enable = false;
doas = {
enable = true;
extraRules = [
{
users = [ "blee" ];
noPass = true;
}
{ # troubleshooting
users = [ "steam" ];
noPass = true;
cmd = "dmesg";
}
{ # remotely reboot this PC remotely via Termius on Android
users = [ "timburr" ];
noPass = true;
cmd = "reboot";
}
];
};
dhparams.enable = true; # seems to not work, had to generate one manually
};
services = {
openssh.enable = true;
journald.extraConfig = "MaxRetentionSec=30day";
# https://github.com/NixOS/nixpkgs/blob/nixos-23.05/nixos/modules/services/monitoring/prometheus/exporters.nix
prometheus.exporters.node = {
enable = true;
port = 8030;
enabledCollectors = [
"cpu.info"
"interrupts"
"netstat"
"vmstat"
"systemd"
"tcpstat"
"processes"
];
};
# https://github.com/NixOS/nixpkgs/blob/nixos-23.05/nixos/modules/services/web-servers/nginx/default.nix
nginx = {
enable = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
recommendedOptimisation = true;
sslProtocols = "TLSv1.3";
# sslDhparam = config.security.dhparams.path;
sslDhparam = "/etc/ssl/dhparams.pem";
virtualHosts =
let
domainName = "${config.networking.hostName}.satstack.net";
tlsConfig = {
onlySSL = true;
serverName = domainName;
sslCertificate = "/var/acme/certificates/${domainName}.crt";
sslCertificateKey = "/var/acme/certificates/${domainName}.key";
};
in
{
"node_exporter" = (tlsConfig // {
listen = [{ addr = "0.0.0.0"; port = 4430; ssl = true; }];
locations."/" = { proxyPass = "http://127.0.0.1:8030"; };
});
"sd-webui" = (tlsConfig // {
listen = [{ addr = "0.0.0.0"; port = 4431; ssl = true; }];
locations."/" = {
proxyPass = "http://127.0.0.1:7860";
proxyWebsockets = true;
};
});
};
};
};
system.stateVersion = "23.05";
}