]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/eldiron.nix
Upgrade to latest nixpkgs
[perso/Immae/Config/Nix.git] / nixops / eldiron.nix
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 pkgsNext = import <nixpkgsNext> {};
13 pkgsPrevious = import <nixpkgsPrevious> {};
14 mylibs = import ../libs.nix { nixpkgs = pkgs; };
15 mypkgs = import ../default.nix;
16 myconfig = {
17 inherit privateFiles;
18 env = import "${privateFiles}/environment.nix";
19 ips = {
20 main = "176.9.151.89";
21 production = "176.9.151.154";
22 integration = "176.9.151.155";
23 };
24 };
25 };
26
27 imports = [
28 ./modules/certificates.nix
29 ./modules/gitolite
30 ./modules/databases
31 ./modules/mpd
32 ./modules/websites
33 ./modules/mail
34 ./modules/ftp
35 ./modules/pub
36 ./modules/task
37 ./modules/irc
38 ./modules/buildbot
39 ];
40 services.myGitolite.enable = true;
41 services.myDatabases.enable = true;
42 services.myWebsites.production.enable = true;
43 services.myWebsites.integration.enable = true;
44 services.myWebsites.tools.enable = true;
45 services.pure-ftpd.enable = true;
46 services.irc.enable = true;
47 services.pub.enable = true;
48 services.myTasks.enable = true;
49 services.buildbot.enable = true;
50
51 services.journald.extraConfig = ''
52 MaxLevelStore="warning"
53 MaxRetentionSec="1year"
54 '';
55 networking = {
56 firewall = {
57 enable = true;
58 allowedTCPPorts = [ 22 ];
59 };
60 };
61
62 deployment = {
63 targetEnv = "hetzner";
64 hetzner = {
65 robotUser = myconfig.env.hetzner.user;
66 robotPass = myconfig.env.hetzner.pass;
67 mainIPv4 = myconfig.ips.main;
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
82 environment.systemPackages = [
83 pkgs.telnet
84 pkgs.htop
85 pkgs.vim
86 ];
87
88 services.openssh.extraConfig = ''
89 AuthorizedKeysCommand /etc/ssh/ldap_authorized_keys
90 AuthorizedKeysCommandUser nobody
91 '';
92
93 environment.etc."ssh/ldap_authorized_keys" = let
94 ldap_authorized_keys =
95 wrap {
96 name = "ldap_authorized_keys";
97 file = ./ldap_authorized_keys.sh;
98 vars = {
99 LDAP_PASS = myconfig.env.sshd.ldap.password;
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;
110 };
111
112 services.cron = {
113 enable = true;
114 systemCronJobs = [
115 ''
116 # The star after /var/lib/* avoids deleting all folders in case of problem
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
118 ''
119 ];
120 };
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?
127 };
128 }