]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/eldiron.nix
69231d1336278e19bc620325e894e99babdde36e
[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, myconfig, ... }:
9 {
10 nixpkgs.overlays = builtins.attrValues (import ../overlays);
11 _module.args = {
12 pkgsNext = import <nixpkgsNext> {};
13 pkgsPrevious = import <nixpkgsPrevious> {};
14 myconfig = {
15 inherit privateFiles;
16 env = import "${privateFiles}/environment.nix";
17 };
18 };
19
20 boot.kernelPackages = pkgs.linuxPackages_latest;
21
22 networking = {
23 firewall.enable = true;
24 # 176.9.151.89 declared in nixops -> infra / tools
25 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
26 (n: ips: { address = ips.ip4; prefixLength = 32; })
27 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.eldiron.ips);
28 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
29 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
30 myconfig.env.servers.eldiron.ips);
31 };
32
33 imports = [
34 ./modules/ssh
35 ./modules/certificates.nix
36 ./modules/gitolite
37 ./modules/mpd.nix
38 ./modules/mail.nix
39 ./modules/ftp.nix
40 ./modules/pub
41 ./modules/task
42 ./modules/buildbot
43 ./modules/dns.nix
44 ] ++ (builtins.attrValues (import ../modules));
45 myServices.databases.enable = true;
46 myServices.irc.enable = true;
47 services.myGitolite.enable = true;
48 services.pure-ftpd.enable = true;
49 services.pub.enable = true;
50 services.myTasks.enable = true;
51 services.buildbot.enable = true;
52
53 services.journald.extraConfig = ''
54 MaxLevelStore="warning"
55 MaxRetentionSec="1year"
56 '';
57
58 deployment = {
59 targetEnv = "hetzner";
60 hetzner = {
61 robotUser = myconfig.env.hetzner.user;
62 robotPass = myconfig.env.hetzner.pass;
63 mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4;
64 partitions = ''
65 clearpart --all --initlabel --drives=sda,sdb
66
67 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
68 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
69
70 part raid.1 --grow --ondisk=sda
71 part raid.2 --grow --ondisk=sdb
72
73 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
74 '';
75 };
76 };
77
78 users.users.root.packages = [
79 pkgs.telnet
80 pkgs.htop
81 pkgs.iftop
82 ];
83
84 environment.systemPackages = [
85 pkgs.vim
86 ];
87
88 services.cron = {
89 enable = true;
90 systemCronJobs = [
91 ''
92 # The star after /var/lib/* avoids deleting all folders in case of problem
93 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
94 ''
95 ];
96 };
97
98 # This value determines the NixOS release with which your system is
99 # to be compatible, in order to avoid breaking some software such as
100 # database servers. You should change this only after NixOS release
101 # notes say you should.
102 system.stateVersion = "18.09"; # Did you read the comment?
103 };
104 }