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