This repository has no description
8.4 kB
332 lines
1{
2 self,
3 config,
4 lib,
5 pkgs,
6 ...
7}:
8{
9 # Stockholm configuration
10 krebs.secret.directory = config.clan.core.vars.password-store.secretLocation;
11
12 # Nixpkgs overlays
13 nixpkgs.overlays = [
14 self.inputs.stockholm.overlays.default
15 (import (self.inputs.stockholm.inputs.nix-writers + "/pkgs")) # TODO get rid of that overlay
16 ];
17
18 imports = [
19 # Import 3modules
20 ../3modules
21
22 # Import stockholm krebs module
23 self.inputs.stockholm.nixosModules.krebs
24
25 # Import individual configurations
26 ./security-workarounds.nix
27 # ./binary-cache/client.nix
28 ./gc.nix
29 ./mc.nix
30 ./zsh.nix
31 ./htop.nix
32 ./tor-ssh.nix
33 ./networkd.nix
34 ./pinned-registry.nix
35 ./nix.nix
36
37 # Import stockholm modules
38 self.inputs.stockholm.nixosModules.users
39 self.inputs.stockholm.nixosModules.hosts
40 self.inputs.stockholm.nixosModules.kartei
41 self.inputs.stockholm.nixosModules.build
42 self.inputs.stockholm.nixosModules.dns
43 self.inputs.stockholm.nixosModules.iptables
44 self.inputs.stockholm.nixosModules.secret
45 self.inputs.stockholm.nixosModules.setuid
46 self.inputs.stockholm.nixosModules.sitemap
47 self.inputs.stockholm.nixosModules.ssl
48 self.inputs.stockholm.nixosModules.systemd
49 self.inputs.stockholm.nixosModules.ssh
50 {
51 # nix-index
52 imports = [
53 self.inputs.nix-index-database.nixosModules.nix-index
54 ];
55 programs.nix-index-database.comma.enable = true;
56 }
57 {
58 # We need to mount these vars before the users phase, since that is the moment where the hashsed password are put into /etc/shadown
59 users.extraUsers.mainUser.hashedPasswordFile =
60 config.clan.core.vars.generators.password.files.passwordHash.path;
61 users.extraUsers.root.hashedPasswordFile =
62 config.clan.core.vars.generators.password.files.passwordHash.path;
63 boot.initrd.systemd.emergencyAccess = true;
64 clan.core.vars.generators.password = {
65 prompts.password = {
66 description = "Password for the main user";
67 type = "hidden";
68 };
69 files.password.deploy = false;
70 files.passwordHash.neededFor = "users";
71 runtimeInputs = with pkgs; [
72 coreutils
73 mkpasswd
74 ];
75 script = ''
76 cp $prompts/password $out/password
77 cat $out/password | mkpasswd -s -m sha-512 > $out/passwordHash
78 '';
79 };
80 }
81 {
82 services.openssh.enable = true;
83 services.openssh.settings.PasswordAuthentication = false;
84 services.openssh.hostKeys = [
85 {
86 path = config.clan.core.vars.generators.ssh.files."ssh.id_ed25519".path;
87 type = "ed25519";
88 }
89 ];
90 clan.core.vars.generators.ssh = {
91 files."ssh.id_ed25519" = { };
92 files."ssh.id_ed25519.pub".secret = false;
93 runtimeInputs = with pkgs; [
94 coreutils
95 openssh
96 ];
97 script = ''
98 ssh-keygen -t ed25519 -N "" -f $out/ssh.id_ed25519
99 '';
100 };
101 }
102 {
103 users.extraUsers = {
104 root = {
105 openssh.authorizedKeys.keys = [
106 self.keys.ssh.barnacle.public
107 self.keys.ssh.yubi_pgp.public
108 self.keys.ssh.termux_massulus.public
109 self.keys.ssh.yubi1.public
110 self.keys.ssh.yubi2.public
111 self.keys.ssh.solo2.public
112 self.keys.ssh.xerxes.public
113 self.keys.ssh.ignavia.public
114 ];
115 };
116 mainUser = {
117 name = "lass";
118 uid = 1337;
119 home = "/home/lass";
120 group = "users";
121 createHome = true;
122 useDefaultShell = true;
123 isNormalUser = true;
124 linger = true;
125 extraGroups = [
126 "audio"
127 "video"
128 "fuse"
129 "wheel"
130 "tor"
131 "dialout"
132 ];
133 openssh.authorizedKeys.keys = [
134 self.keys.ssh.barnacle.public
135 self.keys.ssh.yubi_pgp.public
136 self.keys.ssh.termux_massulus.public
137 self.keys.ssh.yubi1.public
138 self.keys.ssh.yubi2.public
139 self.keys.ssh.solo2.public
140 self.keys.ssh.xerxes.public
141 self.keys.ssh.ignavia.public
142 ];
143 };
144 };
145 }
146 (
147 let
148 ca-bundle = "/etc/ssl/certs/ca-bundle.crt";
149 in
150 {
151 environment.variables = {
152 CURL_CA_BUNDLE = ca-bundle;
153 GIT_SSL_CAINFO = ca-bundle;
154 SSL_CERT_FILE = ca-bundle;
155 };
156 }
157 )
158 {
159 #for sshuttle
160 environment.systemPackages = [
161 pkgs.python3Packages.python
162 ];
163 }
164 ];
165
166 networking.hostName = config.krebs.build.host.name;
167
168 krebs = {
169 enable = true;
170 build.user = config.krebs.users.lass;
171 ssl.trustIntermediate = true;
172 };
173
174 users.mutableUsers = false;
175
176 # multiple-definition-problem when defining environment.variables.EDITOR
177 environment.extraInit = ''
178 EDITOR=vim
179 '';
180
181 nixpkgs.config.allowUnfree = true;
182
183 environment.systemPackages = with pkgs; [
184 self.packages.${pkgs.system}.nvim
185 self.packages.${pkgs.system}.tmux
186 self.packages.${pkgs.system}.s
187
188 git
189 git-absorb
190 gnumake
191 jq
192 nix-output-monitor
193 comma
194
195 #style
196 rxvt-unicode-unwrapped.terminfo
197 alacritty.terminfo
198
199 #monitoring tools
200 htop
201 iotop
202
203 #network
204 iptables
205 iftop
206 tcpdump
207 mosh
208 eternal-terminal
209 self.packages.${pkgs.system}.sshify
210
211 #stuff for dl
212 aria2
213
214 # decentralized git hosting
215 radicle-node
216
217 #neat utils
218 file
219 xkcdpass
220 kpaste
221 cyberlocker-tools
222 pciutils
223 pop
224 q
225 untilport
226 (pkgs.writeDashBin "urgent" ''
227 printf '\a'
228 '')
229 usbutils
230 goify
231
232 #unpack stuff
233 libarchive
234
235 (pkgs.writeDashBin "sshn" ''
236 ${pkgs.openssh}/bin/ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$@"
237 '')
238 ];
239
240 environment.shellAliases = {
241 ll = "ls -l";
242 la = "ls -la";
243 ls = "ls --color";
244 ip = "ip -color=auto";
245 grep = "grep --color=auto";
246 nosleep = "systemd-inhibit --what=handle-lid-switch sleep infinity";
247 };
248
249 programs.bash = {
250 completion.enable = true;
251 interactiveShellInit = ''
252 HISTCONTROL='erasedups:ignorespace'
253 HISTSIZE=65536
254 HISTFILESIZE=$HISTSIZE
255
256 shopt -s checkhash
257 shopt -s histappend histreedit histverify
258 shopt -s no_empty_cmd_completion
259 complete -d cd
260 LS_COLORS=$LS_COLORS:'di=1;31:' ; export LS_COLORS
261 '';
262 promptInit = ''
263 if test $UID = 0; then
264 PS1='\[\033[1;31m\]\w\[\033[0m\] '
265 PROMPT_COMMAND='echo -ne "\033]0;$$ $USER@$PWD\007"'
266 elif test $UID = 1337; then
267 PS1='\[\033[1;32m\]\w\[\033[0m\] '
268 PROMPT_COMMAND='echo -ne "\033]0;$$ $PWD\007"'
269 else
270 PS1='\[\033[1;33m\]\u@\w\[\033[0m\] '
271 PROMPT_COMMAND='echo -ne "\033]0;$$ $USER@$PWD\007"'
272 fi
273 if test -n "$SSH_CLIENT"; then
274 PS1='\[\033[35m\]\h'" $PS1"
275 PROMPT_COMMAND='echo -ne "\033]0;$$ $HOSTNAME $USER@$PWD\007"'
276 fi
277 '';
278 };
279
280 services.journald.extraConfig = ''
281 SystemMaxUse=1G
282 RuntimeMaxUse=128M
283 Storage=persistent
284 '';
285
286 krebs.iptables = {
287 enable = true;
288 tables = {
289 filter.INPUT.policy = "DROP";
290 filter.FORWARD.policy = lib.mkDefault "DROP";
291 filter.INPUT.rules = lib.mkMerge [
292 (lib.mkBefore [
293 {
294 predicate = "-m conntrack --ctstate RELATED,ESTABLISHED";
295 target = "ACCEPT";
296 }
297 {
298 predicate = "-p icmp";
299 target = "ACCEPT";
300 }
301 {
302 predicate = "-p ipv6-icmp";
303 target = "ACCEPT";
304 v4 = false;
305 }
306 {
307 predicate = "-i lo";
308 target = "ACCEPT";
309 }
310 ])
311 ];
312 };
313 };
314
315 networking.firewall.allowedTCPPorts = [ 22 ]; # ssh
316 networking.firewall.allowedUDPPortRanges = [
317 {
318 from = 60000;
319 to = 61000;
320 }
321 ]; # mosh
322 networking.extraHosts = ''
323 10.42.0.1 styx.gg23
324 '';
325
326 # use 24:00 time format, the default got sneakily changed around 20.03
327 i18n.defaultLocale = lib.mkDefault "C.UTF-8";
328 time.timeZone = lib.mkDefault "Europe/Berlin";
329
330 # disable doc usually
331 documentation.nixos.enable = lib.mkDefault false;
332}