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