]> Git — Sourcephile - sourcephile-nix.git/blob - install/logical/friot.nix
gitolite: update
[sourcephile-nix.git] / install / logical / friot.nix
1 {pkgs, lib, config, system, ...}:
2 let inherit (builtins.extraBuiltins) pass;
3 inherit (lib) types;
4 inherit (config) networking;
5 inherit (config.services) dovecot2;
6 userPass = name: pass "${networking.domainBase}/${networking.hostName}/login/${name}";
7 in {
8 imports = [
9 <nixpkgs-commonsoft/install/modules.nix>
10 ../overlays/tools/networking/shorewall/service.nix
11 ../overlays/tools/networking/shorewall6/service.nix
12 ../overlays/servers/mail/rspamd/service.nix
13 friot/dovecot.nix
14 friot/gitolite.nix
15 friot/nginx.nix
16 friot/nsd.nix
17 friot/postfix.nix
18 friot/postgrey.nix
19 friot/postgresql.nix
20 #friot/rmilter.nix
21 friot/rspamd.nix
22 #friot/redmine.nix
23 friot/shorewall.nix
24 friot/openldap.nix
25 #friot/discourse.nix
26 ];
27 options = {
28 enable = lib.mkEnableOption "friot";
29 networking.domainBase = lib.mkOption {
30 type = types.str;
31 description = "Base network name.";
32 example = "example";
33 };
34 networking.domainAliases = lib.mkOption {
35 type = types.listOf types.str;
36 description = "Domain aliases.";
37 example = [ "example.org" "example.net" ];
38 };
39 networking.zones = lib.mkOption {
40 type = types.attrsOf (types.submodule ({name, options, config, ...}: {
41 options = {
42 iface = lib.mkOption {
43 type = types.str;
44 description = "Interface name.";
45 example = "eth0";
46 };
47 ipv4 = lib.mkOption {
48 type = types.str;
49 description = "Static IPv4 address of the machine.";
50 example = "1.2.3.4";
51 };
52 ipv6 = lib.mkOption {
53 type = types.str;
54 description = "Static IPv6 address of the machine.";
55 example = "fe80::1";
56 };
57 };
58 }));
59 };
60 };
61 config = {
62 nix = {
63 extraOptions = ''
64 auto-optimise-store = true
65 '';
66 gc = {
67 automatic = true;
68 dates = "weekly";
69 options = "--delete-older-than 30d";
70 };
71 };
72
73 nixpkgs = {
74 config = {
75 allowUnfree = false;
76 packageOverrides = pkgs: {
77 postfix = pkgs.postfix.override {
78 withLDAP = true;
79 };
80 };
81 };
82 overlays = import ../overlays.nix;
83 };
84
85 boot = {
86 initrd = {
87 network = {
88 enable = config.deployment.targetEnv != "virtualbox";
89 ssh = {
90 enable = true;
91 authorizedKeys = [ (pass "${networking.domain}/ssh/pub/julm") ];
92 };
93 };
94 };
95 kernel = {
96 sysctl = {
97 "vm.swappiness" = 10;
98 "vm.vfs_cache_pressure" = 50;
99 };
100 };
101 };
102
103 time = {
104 timeZone = "Europe/Paris";
105 };
106
107 i18n = {
108 consoleFont = "Lat2-Terminus16";
109 consoleKeyMap = "fr";
110 defaultLocale = "fr_FR.UTF-8";
111 };
112
113 networking = {
114 domainBase = "commonsoft";
115 domain = "${networking.domainBase}.org";
116 domainAliases = [
117 "${networking.domainBase}.net"
118 "${networking.domainBase}.coop"
119 ];
120 };
121
122 users = {
123 mutableUsers = false;
124 users = {
125 root.initialPassword = userPass "root";
126 root.password = config.users.users.root.initialPassword;
127 julm = {
128 uid = 1000;
129 extraGroups = [ "sudo" ];
130 description = "Julien Moutinho";
131 home = "/home/julm";
132 shell = lib.mkDefault config.users.defaultUserShell;
133 group = "users"; # FIXME: unknown group
134 initialPassword = userPass "julm";
135 password = config.users.users.julm.initialPassword;
136 };
137 };
138 groups = {
139 julm = {
140 gid = config.users.users.julm.uid;
141 };
142 };
143 };
144
145 documentation.nixos = {
146 enable = false; # NOTE: useless on this machine, and CPU intensive.
147 };
148
149 services = {
150 redis = {
151 enable = true;
152 };
153 disnix = {
154 enable = false;
155 };
156 openssh = {
157 enable = true;
158 extraConfig = ''
159 '';
160 };
161 gitea = {
162 enable = false;
163 };
164 sssd = {
165 enable = false;
166 };
167 dovecot2 = {
168 #debug = true;
169 };
170 journald = {
171 extraConfig = ''
172 SystemMaxUse=50M
173 '';
174 };
175 x509 = {
176 domains =
177 lib.concatMap
178 (dom: map (sub: "${sub}.${dom}")
179 ["www" "git" "mail"])
180 ([networking.domain] ++ networking.domainAliases)
181 ++ networking.domainAliases;
182 };
183 #postfix.aliases = {
184 # "root@${networking.domain}" = [ "test@${networking.domain}" ];
185 # "postmaster@${networking.domain}" = [ "test@${networking.domain}" ];
186 # "abuse@${networking.domain}" = [ "test@${networking.domain}" ];
187 #};
188 #dovecot2.domains = {
189 # "${networking.domain}" = {
190 # accounts = {
191 # julm = {
192 # password = pass "${networking.domain}/mail/julm";
193 # # "${networking.domain}/dovecot2/julm";
194 # # "{SSHA512}uyjL1KYx4z7HpfNvnKzuVxpMLD2KVueGGBvOcj7AF1EZCTVhT++IIKUVOC4xpZtWdqVD0OVmZqgYr2qpn/3t3Aj4oU0=";
195 # aliases = ["julien.moutinho@${networking.domain}"];
196 # quota = "512M";
197 # };
198 # test = {
199 # password = pass "${networking.domain}/mail/test";
200 # # "${networking.domain}/dovecot2/test";
201 # # "{SSHA512}uyjL1KYx4z7HpfNvnKzuVxpMLD2KVueGGBvOcj7AF1EZCTVhT++IIKUVOC4xpZtWdqVD0OVmZqgYr2qpn/3t3Aj4oU0=";
202 # aliases = ["test-alias@${networking.domain}"];
203 # quota = "512M";
204 # };
205 # };
206 # };
207 #};
208 };
209
210 environment = {
211 systemPackages = with pkgs; [
212 htop
213 tree
214 vim
215 tcpdump
216 #mysql
217 #procmail
218 postgrey
219 duplicity
220 pypolicyd-spf
221 unbound
222 dropbear
223 cryptsetup
224 openssl
225 postgresql
226 openldap
227 #mail
228 #sympa
229 multitail
230 dnsutils
231 inetutils
232 binutils
233 mailutils
234 ncdu
235 cgit
236 #sssd
237 #docker
238 #nss_ldap
239 #nss_pam_ldapd
240 tmux
241 socat
242 users-init
243 which
244 ];
245 etc."inputrc".text = ''
246 # /etc/inputrc - global inputrc for libreadline
247 # See readline(3readline) and `info rluserman' for more information.
248
249 # Be 8 bit clean.
250 set input-meta on
251 set output-meta on
252
253 # To allow the use of 8bit-characters like the german umlauts, uncomment
254 # the line below. However this makes the meta key not work as a meta key,
255 # which is annoying to those which don't need to type in 8-bit characters.
256
257 # set convert-meta off
258
259 # try to enable the application keypad when it is called. Some systems
260 # need this to enable the arrow keys.
261 # set enable-keypad on
262
263 # see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys
264
265 # do not bell on tab-completion
266 # set bell-style none
267 # set bell-style visible
268
269 # some defaults / modifications for the emacs mode
270 $if mode=emacs
271
272 # allow the use of the Home/End keys
273 "\e[1~": beginning-of-line
274 "\e[4~": end-of-line
275
276 # allow the use of the Delete/Insert keys
277 "\e[3~": delete-char
278 "\e[2~": quoted-insert
279
280 # mappings for "page up" and "page down" to step to the beginning/end
281 # of the history
282 # "\e[5~": beginning-of-history
283 # "\e[6~": end-of-history
284
285 # alternate mappings for "page up" and "page down" to search the history
286 # "\e[5~": history-search-backward
287 # "\e[6~": history-search-forward
288
289 # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
290 "\e[1;5C": forward-word
291 "\e[1;5D": backward-word
292 "\e[5C": forward-word
293 "\e[5D": backward-word
294 "\e\e[C": forward-word
295 "\e\e[D": backward-word
296
297 $if term=rxvt
298 "\e[7~": beginning-of-line
299 "\e[8~": end-of-line
300 "\eOc": forward-word
301 "\eOd": backward-word
302 $endif
303
304 # for non RH/Debian xterm, can't hurt for RH/Debian xterm
305 # "\eOH": beginning-of-line
306 # "\eOF": end-of-line
307
308 # for freebsd console
309 # "\e[H": beginning-of-line
310 # "\e[F": end-of-line
311
312 $endif
313 '';
314 };
315
316 programs = {
317 bash = {
318 interactiveShellInit = ''
319 bind '"\e[A":history-search-backward'
320 bind '"\e[B":history-search-forward'
321
322 # Ignore duplicate commands, ignore commands starting with a space
323 export HISTCONTROL=erasedups:ignorespace
324 export HISTSIZE=42000
325 # Append to the history instead of overwriting (good for multiple connections)
326 shopt -s histappend
327 '';
328 shellAliases = {
329 cl = "clear";
330 l = "ls -alh";
331 ll = "ls -l";
332 ls = "ls --color=tty";
333
334 s="sudo systemctl";
335 s-u="systemctl --user";
336
337 nix-clean="sudo nix-collect-garbage -d";
338 nix-history="sudo nix-env --list-generations --profile /nix/var/nix/profiles/system";
339 nix-rollback="sudo nixos-rebuild switch --rollback";
340 nix-update="sudo nix-channel --update";
341 nix-upgrade="sudo nixos-rebuild switch";
342 nix-upstream="sudo nix-channel --list";
343 nix-config="gvim ~/.config/nixos/*.nix";
344 };
345 };
346
347 /*
348 dconf.enable = true;
349
350 gnupg.agent = {
351 enable = true;
352 enableSSHSupport = true;
353 };
354 */
355
356 mtr.enable = true;
357 };
358 };
359 }