]>
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 { nixpkgs = pkgs; }; | |
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 | ./modules/pub | |
34 | ./modules/task | |
35 | ./modules/irc | |
36 | ]; | |
37 | services.myGitolite.enable = true; | |
38 | services.myDatabases.enable = true; | |
39 | services.myWebsites.production.enable = true; | |
40 | services.myWebsites.integration.enable = true; | |
41 | services.myWebsites.tools.enable = true; | |
42 | services.pure-ftpd.enable = true; | |
43 | services.irc.enable = true; | |
44 | services.pub.enable = true; | |
45 | services.myTasks.enable = true; | |
46 | ||
47 | services.journald.extraConfig = '' | |
48 | MaxLevelStore="warning" | |
49 | MaxRetentionSec="1year" | |
50 | ''; | |
51 | networking = { | |
52 | firewall = { | |
53 | enable = true; | |
54 | allowedTCPPorts = [ 22 ]; | |
55 | }; | |
56 | }; | |
57 | ||
58 | deployment = { | |
59 | targetEnv = "hetzner"; | |
60 | hetzner = { | |
61 | robotUser = myconfig.env.hetzner.user; | |
62 | robotPass = myconfig.env.hetzner.pass; | |
63 | mainIPv4 = myconfig.ips.main; | |
64 | partitions = '' | |
65 | clearpart --all --initlabel --drives=sda,sdb | |
66 | ||
67 | part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda | |
68 | part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb | |
69 | ||
70 | part raid.1 --grow --ondisk=sda | |
71 | part raid.2 --grow --ondisk=sdb | |
72 | ||
73 | raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2 | |
74 | ''; | |
75 | }; | |
76 | }; | |
77 | ||
78 | environment.systemPackages = [ | |
79 | pkgs.telnet | |
80 | pkgs.htop | |
81 | pkgs.vim | |
82 | ]; | |
83 | ||
84 | services.openssh.extraConfig = '' | |
85 | AuthorizedKeysCommand /etc/ssh/ldap_authorized_keys | |
86 | AuthorizedKeysCommandUser nobody | |
87 | ''; | |
88 | ||
89 | environment.etc."ssh/ldap_authorized_keys" = let | |
90 | ldap_authorized_keys = | |
91 | wrap { | |
92 | name = "ldap_authorized_keys"; | |
93 | file = ./ldap_authorized_keys.sh; | |
94 | vars = { | |
95 | LDAP_PASS = myconfig.env.sshd.ldap.password; | |
96 | GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell"; | |
97 | ECHO = "${pkgs.coreutils}/bin/echo"; | |
98 | }; | |
99 | paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ]; | |
100 | }; | |
101 | in { | |
102 | enable = true; | |
103 | mode = "0755"; | |
104 | user = "root"; | |
105 | source = ldap_authorized_keys; | |
106 | }; | |
107 | ||
108 | services.cron = { | |
109 | enable = true; | |
110 | systemCronJobs = [ | |
111 | '' | |
112 | # The star after /var/lib/* avoids deleting all folders in case of problem | |
113 | 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 | |
114 | '' | |
115 | ]; | |
116 | }; | |
117 | ||
118 | # This value determines the NixOS release with which your system is | |
119 | # to be compatible, in order to avoid breaking some software such as | |
120 | # database servers. You should change this only after NixOS release | |
121 | # notes say you should. | |
122 | system.stateVersion = "18.09"; # Did you read the comment? | |
123 | }; | |
124 | } |