]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - nixops/eldiron.nix
Add caldance buildbot and optimize a bit the drivations
[perso/Immae/Config/Nix.git] / nixops / eldiron.nix
CommitLineData
9fb4205e 1{ privateFiles ? ./., nixpkgsNext ? null }:
a1bb33c4
IB
2{
3 network = {
4 description = "Immae's network";
5 enableRollback = true;
6 };
7
f8bde3d6 8 eldiron = { config, pkgs, mylibs, myconfig, ... }:
4d4f13f4 9 with mylibs;
ab5d04b8 10 {
4d4f13f4 11 _module.args = {
9fb4205e 12 pkgsNext = if builtins.isNull nixpkgsNext then pkgs else import nixpkgsNext {};
596e62a6 13 mylibs = import ../libs.nix { nixpkgs = pkgs; };
7636abc6 14 mypkgs = import ../default.nix;
f8bde3d6 15 myconfig = {
9690acd9
IB
16 inherit privateFiles;
17 env = import "${privateFiles}/environment.nix";
f8bde3d6
IB
18 ips = {
19 main = "176.9.151.89";
20 production = "176.9.151.154";
21 integration = "176.9.151.155";
22 };
23 };
4d4f13f4
IB
24 };
25
26 imports = [
3013caf1 27 ./modules/certificates.nix
10889174
IB
28 ./modules/gitolite
29 ./modules/databases
e229e6f2 30 ./modules/mpd
54307da4 31 ./modules/websites
af421a8f 32 ./modules/mail
439049e5 33 ./modules/ftp
5ccc61bb 34 ./modules/pub
22149d17 35 ./modules/task
31a38b9f 36 ./modules/irc
9fb4205e 37 ./modules/buildbot
4d4f13f4
IB
38 ];
39 services.myGitolite.enable = true;
4d4f13f4 40 services.myDatabases.enable = true;
42429ef0
IB
41 services.myWebsites.production.enable = true;
42 services.myWebsites.integration.enable = true;
10889174 43 services.myWebsites.tools.enable = true;
439049e5 44 services.pure-ftpd.enable = true;
31a38b9f 45 services.irc.enable = true;
5ccc61bb 46 services.pub.enable = true;
22149d17 47 services.myTasks.enable = true;
9fb4205e 48 services.buildbot.enable = true;
4d4f13f4 49
46228a29
IB
50 services.journald.extraConfig = ''
51 MaxLevelStore="warning"
52 MaxRetentionSec="1year"
53 '';
a1bb33c4
IB
54 networking = {
55 firewall = {
56 enable = true;
10889174 57 allowedTCPPorts = [ 22 ];
a1bb33c4
IB
58 };
59 };
60
61 deployment = {
62 targetEnv = "hetzner";
63 hetzner = {
9d90e7e2
IB
64 robotUser = myconfig.env.hetzner.user;
65 robotPass = myconfig.env.hetzner.pass;
f8bde3d6 66 mainIPv4 = myconfig.ips.main;
a1bb33c4
IB
67 partitions = ''
68 clearpart --all --initlabel --drives=sda,sdb
69
70 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
71 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
72
73 part raid.1 --grow --ondisk=sda
74 part raid.2 --grow --ondisk=sdb
75
76 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
77 '';
78 };
79 };
80
10889174 81 environment.systemPackages = [
ce6ee3b8 82 pkgs.telnet
beeed847 83 pkgs.htop
ce6ee3b8
IB
84 pkgs.vim
85 ];
86
5566d26d
IB
87 services.openssh.extraConfig = ''
88 AuthorizedKeysCommand /etc/ssh/ldap_authorized_keys
89 AuthorizedKeysCommandUser nobody
90 '';
91
5566d26d
IB
92 environment.etc."ssh/ldap_authorized_keys" = let
93 ldap_authorized_keys =
5c101474 94 wrap {
5566d26d
IB
95 name = "ldap_authorized_keys";
96 file = ./ldap_authorized_keys.sh;
97 vars = {
9d90e7e2 98 LDAP_PASS = myconfig.env.sshd.ldap.password;
5566d26d
IB
99 GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell";
100 ECHO = "${pkgs.coreutils}/bin/echo";
101 };
102 paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ];
103 };
104 in {
105 enable = true;
106 mode = "0755";
107 user = "root";
108 source = ldap_authorized_keys;
65fe7543
IB
109 };
110
6533428a
IB
111 services.cron = {
112 enable = true;
113 systemCronJobs = [
114 ''
115 # The star after /var/lib/* avoids deleting all folders in case of problem
9d8d1425 116 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
6533428a
IB
117 ''
118 ];
119 };
3de01f9b
IB
120
121 # This value determines the NixOS release with which your system is
122 # to be compatible, in order to avoid breaking some software such as
123 # database servers. You should change this only after NixOS release
124 # notes say you should.
125 system.stateVersion = "18.09"; # Did you read the comment?
a1bb33c4
IB
126 };
127}