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