]>
Commit | Line | Data |
---|---|---|
1 | { privateFiles ? ./. }: | |
2 | { | |
3 | network = { | |
4 | description = "Immae's network"; | |
5 | enableRollback = true; | |
6 | }; | |
7 | ||
8 | eldiron = { config, pkgs, mylibs, myconfig, ... }: | |
9 | with mylibs; | |
10 | { | |
11 | _module.args = { | |
12 | mylibs = import ../libs.nix; | |
13 | mypkgs = import ../default.nix; | |
14 | myconfig = { | |
15 | inherit privateFiles; | |
16 | env = import "${privateFiles}/environment.nix"; | |
17 | ips = { | |
18 | main = "176.9.151.89"; | |
19 | production = "176.9.151.154"; | |
20 | integration = "176.9.151.155"; | |
21 | }; | |
22 | }; | |
23 | }; | |
24 | ||
25 | imports = [ | |
26 | ./modules/certificates.nix | |
27 | ./modules/gitolite | |
28 | ./modules/databases | |
29 | ./modules/mpd | |
30 | ./modules/websites | |
31 | ./modules/mail | |
32 | ./modules/ftp | |
33 | ]; | |
34 | services.myGitolite.enable = true; | |
35 | services.myDatabases.enable = true; | |
36 | services.myWebsites.production.enable = true; | |
37 | services.myWebsites.integration.enable = true; | |
38 | services.myWebsites.tools.enable = true; | |
39 | services.pure-ftpd.enable = true; | |
40 | ||
41 | services.journald.extraConfig = '' | |
42 | MaxLevelStore="warning" | |
43 | MaxRetentionSec="1year" | |
44 | ''; | |
45 | networking = { | |
46 | firewall = { | |
47 | enable = true; | |
48 | allowedTCPPorts = [ 22 ]; | |
49 | }; | |
50 | }; | |
51 | ||
52 | deployment = { | |
53 | targetEnv = "hetzner"; | |
54 | hetzner = { | |
55 | robotUser = myconfig.env.hetzner.user; | |
56 | robotPass = myconfig.env.hetzner.pass; | |
57 | mainIPv4 = myconfig.ips.main; | |
58 | partitions = '' | |
59 | clearpart --all --initlabel --drives=sda,sdb | |
60 | ||
61 | part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda | |
62 | part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb | |
63 | ||
64 | part raid.1 --grow --ondisk=sda | |
65 | part raid.2 --grow --ondisk=sdb | |
66 | ||
67 | raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2 | |
68 | ''; | |
69 | }; | |
70 | }; | |
71 | ||
72 | environment.systemPackages = [ | |
73 | pkgs.telnet | |
74 | pkgs.htop | |
75 | pkgs.vim | |
76 | ]; | |
77 | ||
78 | services.openssh.extraConfig = '' | |
79 | AuthorizedKeysCommand /etc/ssh/ldap_authorized_keys | |
80 | AuthorizedKeysCommandUser nobody | |
81 | ''; | |
82 | ||
83 | environment.etc."ssh/ldap_authorized_keys" = let | |
84 | ldap_authorized_keys = | |
85 | wrap { | |
86 | name = "ldap_authorized_keys"; | |
87 | file = ./ldap_authorized_keys.sh; | |
88 | vars = { | |
89 | LDAP_PASS = myconfig.env.sshd.ldap.password; | |
90 | GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell"; | |
91 | ECHO = "${pkgs.coreutils}/bin/echo"; | |
92 | }; | |
93 | paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ]; | |
94 | }; | |
95 | in { | |
96 | enable = true; | |
97 | mode = "0755"; | |
98 | user = "root"; | |
99 | source = ldap_authorized_keys; | |
100 | }; | |
101 | ||
102 | services.cron = { | |
103 | enable = true; | |
104 | systemCronJobs = [ | |
105 | '' | |
106 | # The star after /var/lib/* avoids deleting all folders in case of problem | |
107 | 0 3,9,15,21 * * * root rsync -e "ssh -i /root/.ssh/id_charon_vpn" -aAXvz --delete --numeric-ids --super --rsync-path="sudo rsync" /var/lib/* immae@immae.eu: > /dev/null | |
108 | '' | |
109 | ]; | |
110 | }; | |
111 | ||
112 | # This value determines the NixOS release with which your system is | |
113 | # to be compatible, in order to avoid breaking some software such as | |
114 | # database servers. You should change this only after NixOS release | |
115 | # notes say you should. | |
116 | system.stateVersion = "18.09"; # Did you read the comment? | |
117 | }; | |
118 | } |