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