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