]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - nixops/eldiron.nix
Fix scripts environment and upgrade nixops
[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, ... }:
ab5d04b8 9 {
4d4f13f4 10 _module.args = {
30a78336 11 pkgsNext = import <nixpkgsNext> {};
587b9e34 12 pkgsPrevious = import <nixpkgsPrevious> {};
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 18 };
4d4f13f4
IB
19 };
20
d68bb46b
IB
21 networking = {
22 firewall.enable = true;
23 # 176.9.151.89 declared in nixops -> infra / tools
24 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
25 (n: ips: { address = ips.ip4; prefixLength = 32; })
26 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.eldiron.ips);
27 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
28 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
29 myconfig.env.servers.eldiron.ips);
30 };
31
4d4f13f4 32 imports = [
7e6f1fb4 33 ./modules/ssh
3013caf1 34 ./modules/certificates.nix
10889174
IB
35 ./modules/gitolite
36 ./modules/databases
e229e6f2 37 ./modules/mpd
54307da4 38 ./modules/websites
af421a8f 39 ./modules/mail
439049e5 40 ./modules/ftp
5ccc61bb 41 ./modules/pub
22149d17 42 ./modules/task
31a38b9f 43 ./modules/irc
9fb4205e 44 ./modules/buildbot
bb5e0900 45 ./modules/dns
44742a43 46 ./modules/secrets
4d4f13f4
IB
47 ];
48 services.myGitolite.enable = true;
4d4f13f4 49 services.myDatabases.enable = true;
42429ef0
IB
50 services.myWebsites.production.enable = true;
51 services.myWebsites.integration.enable = true;
10889174 52 services.myWebsites.tools.enable = true;
439049e5 53 services.pure-ftpd.enable = true;
31a38b9f 54 services.irc.enable = true;
5ccc61bb 55 services.pub.enable = true;
22149d17 56 services.myTasks.enable = true;
9fb4205e 57 services.buildbot.enable = true;
4d4f13f4 58
46228a29
IB
59 services.journald.extraConfig = ''
60 MaxLevelStore="warning"
61 MaxRetentionSec="1year"
62 '';
a1bb33c4
IB
63
64 deployment = {
65 targetEnv = "hetzner";
66 hetzner = {
9d90e7e2
IB
67 robotUser = myconfig.env.hetzner.user;
68 robotPass = myconfig.env.hetzner.pass;
d68bb46b 69 mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4;
a1bb33c4
IB
70 partitions = ''
71 clearpart --all --initlabel --drives=sda,sdb
72
73 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
74 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
75
76 part raid.1 --grow --ondisk=sda
77 part raid.2 --grow --ondisk=sdb
78
79 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
80 '';
81 };
82 };
83
10889174 84 environment.systemPackages = [
ce6ee3b8 85 pkgs.telnet
beeed847 86 pkgs.htop
ce6ee3b8 87 pkgs.vim
5ad177c6 88 pkgs.iftop
ce6ee3b8
IB
89 ];
90
6533428a
IB
91 services.cron = {
92 enable = true;
93 systemCronJobs = [
94 ''
95 # The star after /var/lib/* avoids deleting all folders in case of problem
9d8d1425 96 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
97 ''
98 ];
99 };
3de01f9b
IB
100
101 # This value determines the NixOS release with which your system is
102 # to be compatible, in order to avoid breaking some software such as
103 # database servers. You should change this only after NixOS release
104 # notes say you should.
105 system.stateVersion = "18.09"; # Did you read the comment?
a1bb33c4
IB
106 };
107}