This repository has no description
7.3 kB
271 lines
1{ self, config, lib, pkgs, ... }:
2{
3 imports = [
4 ./binary-cache/client.nix
5 ./gc.nix
6 ./mc.nix
7 ./zsh.nix
8 ./htop.nix
9 ./wiregrill.nix
10 ./tmux.nix
11 ./tor-ssh.nix
12 ./networkd.nix
13 ./pinned-registry.nix
14 ./zerotier.nix
15 ./nether.nix
16 self.inputs.stockholm.nixosModules.users
17 self.inputs.stockholm.nixosModules.hosts
18 self.inputs.stockholm.nixosModules.kartei
19 self.inputs.stockholm.nixosModules.build
20 self.inputs.stockholm.nixosModules.dns
21 self.inputs.stockholm.nixosModules.exim
22 self.inputs.stockholm.nixosModules.exim-retiolum
23 self.inputs.stockholm.nixosModules.tinc
24 self.inputs.stockholm.nixosModules.iptables
25 self.inputs.stockholm.nixosModules.power-action
26 self.inputs.stockholm.nixosModules.setuid
27 self.inputs.stockholm.nixosModules.secret
28 self.inputs.stockholm.nixosModules.sitemap
29 self.inputs.stockholm.nixosModules.ssl
30 self.inputs.stockholm.nixosModules.systemd
31 self.inputs.stockholm.nixosModules.xresources
32 self.inputs.stockholm.nixosModules.ssh
33 self.inputs.stockholm.nixosModules.sync-containers3
34 {
35 users.extraUsers.mainUser.hashedPasswordFile = "${config.krebs.secret.directory}/passwordHash";
36 users.extraUsers.root.hashedPasswordFile = "${config.krebs.secret.directory}/passwordHash";
37 clanCore.secrets.password = {
38 secrets.password = { };
39 secrets.passwordHash = { };
40 generator.path = with pkgs; [ coreutils xkcdpass mkpasswd ];
41 generator.script = ''
42 xkcdpass -n 4 -d - > $secrets/password
43 cat $secrets/password | mkpasswd -s -m sha-512 > $secrets/passwordHash
44 '';
45 };
46 }
47 {
48 services.openssh.enable = true;
49 services.openssh.hostKeys = [{
50 path = "${config.krebs.secret.directory}/ssh.id_ed25519";
51 type = "ed25519";
52 }];
53 clanCore.secrets.ssh = {
54 secrets."ssh.id_ed25519" = { };
55 facts."ssh.id_ed25519.pub" = { };
56 generator.path = with pkgs; [ coreutils openssh ];
57 generator.script = ''
58 ssh-keygen -t ed25519 -N "" -f $secrets/ssh.id_ed25519
59 mv $secrets/ssh.id_ed25519.pub $facts/ssh.id_ed25519.pub
60 '';
61 };
62 }
63 {
64 users.extraUsers = {
65 root = {
66 openssh.authorizedKeys.keys = [
67 config.krebs.users.lass.pubkey
68 ];
69 };
70 mainUser = {
71 name = "lass";
72 uid = 1337;
73 home = "/home/lass";
74 group = "users";
75 createHome = true;
76 useDefaultShell = true;
77 isNormalUser = true;
78 extraGroups = [
79 "audio"
80 "video"
81 "fuse"
82 "wheel"
83 "tor"
84 ];
85 openssh.authorizedKeys.keys = [
86 config.krebs.users.lass.pubkey
87 ];
88 };
89 };
90 }
91 (let ca-bundle = "/etc/ssl/certs/ca-bundle.crt"; in {
92 environment.variables = {
93 CURL_CA_BUNDLE = ca-bundle;
94 GIT_SSL_CAINFO = ca-bundle;
95 SSL_CERT_FILE = ca-bundle;
96 };
97 })
98 {
99 #for sshuttle
100 environment.systemPackages = [
101 pkgs.python3Packages.python
102 ];
103 }
104 ];
105
106 networking.hostName = config.krebs.build.host.name;
107
108 krebs = {
109 enable = true;
110 build.user = config.krebs.users.lass;
111 ssl.trustIntermediate = true;
112 };
113
114 nix.useSandbox = true;
115
116 users.mutableUsers = false;
117
118 # multiple-definition-problem when defining environment.variables.EDITOR
119 environment.extraInit = ''
120 EDITOR=vim
121 '';
122
123 nixpkgs.config.allowUnfree = true;
124
125 environment.systemPackages = with pkgs; [
126 self.packages.${pkgs.system}.vim
127
128 #stockholm
129 git
130 git-absorb
131 git-preview
132 gnumake
133 jq
134 nix-output-monitor
135
136 #style
137 rxvt-unicode-unwrapped.terminfo
138 alacritty.terminfo
139
140 #monitoring tools
141 htop
142 iotop
143
144 #network
145 iptables
146 iftop
147 tcpdump
148 mosh
149 eternal-terminal
150 self.packages.${pkgs.system}.sshify
151
152 #stuff for dl
153 aria2
154
155 #neat utils
156 file
157 hashPassword
158 kpaste
159 cyberlocker-tools
160 pciutils
161 pop
162 q
163 rs
164 untilport
165 (pkgs.writeDashBin "urgent" ''
166 printf '\a'
167 '')
168 usbutils
169 self.packages.${pkgs.system}.logify
170 goify
171
172 #unpack stuff
173 libarchive
174
175 (pkgs.writeDashBin "sshn" ''
176 ${pkgs.openssh}/bin/ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$@"
177 '')
178 ];
179
180 environment.shellAliases = {
181 ll = "ls -l";
182 la = "ls -la";
183 ls = "ls --color";
184 ip = "ip -color=auto";
185 grep = "grep --color=auto";
186 };
187
188 programs.bash = {
189 enableCompletion = true;
190 interactiveShellInit = ''
191 HISTCONTROL='erasedups:ignorespace'
192 HISTSIZE=65536
193 HISTFILESIZE=$HISTSIZE
194
195 shopt -s checkhash
196 shopt -s histappend histreedit histverify
197 shopt -s no_empty_cmd_completion
198 complete -d cd
199 LS_COLORS=$LS_COLORS:'di=1;31:' ; export LS_COLORS
200 '';
201 promptInit = ''
202 if test $UID = 0; then
203 PS1='\[\033[1;31m\]\w\[\033[0m\] '
204 PROMPT_COMMAND='echo -ne "\033]0;$$ $USER@$PWD\007"'
205 elif test $UID = 1337; then
206 PS1='\[\033[1;32m\]\w\[\033[0m\] '
207 PROMPT_COMMAND='echo -ne "\033]0;$$ $PWD\007"'
208 else
209 PS1='\[\033[1;33m\]\u@\w\[\033[0m\] '
210 PROMPT_COMMAND='echo -ne "\033]0;$$ $USER@$PWD\007"'
211 fi
212 if test -n "$SSH_CLIENT"; then
213 PS1='\[\033[35m\]\h'" $PS1"
214 PROMPT_COMMAND='echo -ne "\033]0;$$ $HOSTNAME $USER@$PWD\007"'
215 fi
216 '';
217 };
218
219 services.journald.extraConfig = ''
220 SystemMaxUse=1G
221 RuntimeMaxUse=128M
222 Storage=persistent
223 '';
224
225 krebs.iptables = {
226 enable = true;
227 tables = {
228 filter.INPUT.policy = "DROP";
229 filter.FORWARD.policy = lib.mkDefault "DROP";
230 filter.INPUT.rules = lib.mkMerge [
231 (lib.mkBefore [
232 { predicate = "-m conntrack --ctstate RELATED,ESTABLISHED"; target = "ACCEPT"; }
233 { predicate = "-p icmp"; target = "ACCEPT"; }
234 { predicate = "-p ipv6-icmp"; target = "ACCEPT"; v4 = false; }
235 { predicate = "-i lo"; target = "ACCEPT"; }
236 { predicate = "-p tcp --dport 22"; target = "ACCEPT"; }
237 ])
238 (lib.mkOrder 1000 [
239 { predicate = "-p udp --dport 60000:61000"; target = "ACCEPT"; } # mosh
240 { predicate = "-i retiolum -p udp -m udp --dport 53"; target = "ACCEPT"; }
241 { predicate = "-i retiolum -p tcp --dport 19999"; target = "ACCEPT"; }
242 ])
243 (lib.mkAfter [
244 { predicate = "-p tcp -i retiolum"; target = "REJECT --reject-with tcp-reset"; }
245 { predicate = "-p udp -i retiolum"; target = "REJECT --reject-with icmp-port-unreachable"; v6 = false; }
246 { predicate = "-i retiolum"; target = "REJECT --reject-with icmp-proto-unreachable"; v6 = false; }
247 ])
248 ];
249 };
250 };
251
252 networking.dhcpcd.extraConfig = ''
253 noipv4ll
254 '';
255
256 networking.extraHosts = ''
257 10.42.0.1 styx.gg23
258 '';
259
260 nix.settings.experimental-features = [
261 "nix-command"
262 "flakes"
263 ];
264
265 # use 24:00 time format, the default got sneakily changed around 20.03
266 i18n.defaultLocale = lib.mkDefault "C.UTF-8";
267 time.timeZone = lib.mkDefault"Europe/Berlin";
268
269 # disable doc usually
270 documentation.nixos.enable = lib.mkDefault false;
271}