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