]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/eldiron.nix
Use more up to date version of yarn2nix
[perso/Immae/Config/Nix.git] / nixops / eldiron.nix
1 { environment ? ./environment.nix }:
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 env = import environment;
16 ips = {
17 main = "176.9.151.89";
18 production = "176.9.151.154";
19 integration = "176.9.151.155";
20 };
21 };
22 };
23
24 imports = [
25 ./modules/certificates.nix
26 ./modules/gitolite
27 ./modules/databases
28 ./modules/mpd
29 ./modules/websites
30 ./modules/mail
31 ./modules/ftp
32 ];
33 services.myGitolite.enable = true;
34 services.myDatabases.enable = true;
35 services.myWebsites.production.enable = true;
36 services.myWebsites.integration.enable = true;
37 services.myWebsites.tools.enable = true;
38 services.pure-ftpd.enable = true;
39
40 services.journald.extraConfig = ''
41 MaxLevelStore="warning"
42 MaxRetentionSec="1year"
43 '';
44 networking = {
45 firewall = {
46 enable = true;
47 allowedTCPPorts = [ 22 ];
48 };
49 };
50
51 deployment = {
52 targetEnv = "hetzner";
53 hetzner = {
54 robotUser = myconfig.env.hetzner.user;
55 robotPass = myconfig.env.hetzner.pass;
56 mainIPv4 = myconfig.ips.main;
57 partitions = ''
58 clearpart --all --initlabel --drives=sda,sdb
59
60 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
61 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
62
63 part raid.1 --grow --ondisk=sda
64 part raid.2 --grow --ondisk=sdb
65
66 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
67 '';
68 };
69 };
70
71 environment.systemPackages = [
72 pkgs.telnet
73 pkgs.htop
74 pkgs.vim
75 ];
76
77 services.openssh.extraConfig = ''
78 AuthorizedKeysCommand /etc/ssh/ldap_authorized_keys
79 AuthorizedKeysCommandUser nobody
80 '';
81
82 environment.etc."ssh/ldap_authorized_keys" = let
83 ldap_authorized_keys =
84 wrap {
85 name = "ldap_authorized_keys";
86 file = ./ldap_authorized_keys.sh;
87 vars = {
88 LDAP_PASS = myconfig.env.sshd.ldap.password;
89 GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell";
90 ECHO = "${pkgs.coreutils}/bin/echo";
91 };
92 paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ];
93 };
94 in {
95 enable = true;
96 mode = "0755";
97 user = "root";
98 source = ldap_authorized_keys;
99 };
100
101 services.cron = {
102 enable = true;
103 systemCronJobs = [
104 ''
105 # The star after /var/lib/* avoids deleting all folders in case of problem
106 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
107 ''
108 ];
109 };
110 };
111 }