aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-22 21:01:44 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-22 21:01:44 +0200
commitf807d9177bb795f034bfd11932e4fbfa6671805f (patch)
treebfc5f0b403f17713350476ca3a9c0d93ad813806
parent8d213e2b1c934f6861f76aad5eb7c11097fa97de (diff)
downloadNix-f807d9177bb795f034bfd11932e4fbfa6671805f.tar.gz
Nix-f807d9177bb795f034bfd11932e4fbfa6671805f.tar.zst
Nix-f807d9177bb795f034bfd11932e4fbfa6671805f.zip
Move eldiron config to modules
-rw-r--r--modules/private/system/eldiron.nix63
-rw-r--r--nixops/eldiron.nix63
2 files changed, 64 insertions, 62 deletions
diff --git a/modules/private/system/eldiron.nix b/modules/private/system/eldiron.nix
new file mode 100644
index 0000000..b71df33
--- /dev/null
+++ b/modules/private/system/eldiron.nix
@@ -0,0 +1,63 @@
1{ privateFiles }:
2{ config, pkgs, myconfig, ... }:
3{
4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 _module.args.privateFiles = privateFiles;
6
7 networking = {
8 firewall.enable = true;
9 # 176.9.151.89 declared in nixops -> infra / tools
10 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
11 (n: ips: { address = ips.ip4; prefixLength = 32; })
12 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.eldiron.ips);
13 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
14 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
15 myconfig.env.servers.eldiron.ips);
16 };
17
18 imports = builtins.attrValues (import ../..);
19
20 myServices.buildbot.enable = true;
21 myServices.databases.enable = true;
22 myServices.gitolite.enable = true;
23 myServices.irc.enable = true;
24 myServices.pub.enable = true;
25 myServices.tasks.enable = true;
26 services.pure-ftpd.enable = true;
27
28 deployment = {
29 targetEnv = "hetzner";
30 hetzner = {
31 robotUser = myconfig.env.hetzner.user;
32 robotPass = myconfig.env.hetzner.pass;
33 mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4;
34 partitions = ''
35 clearpart --all --initlabel --drives=sda,sdb
36
37 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
38 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
39
40 part raid.1 --grow --ondisk=sda
41 part raid.2 --grow --ondisk=sdb
42
43 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
44 '';
45 };
46 };
47
48 services.cron = {
49 enable = true;
50 systemCronJobs = [
51 ''
52 # The star after /var/lib/* avoids deleting all folders in case of problem
53 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
54 ''
55 ];
56 };
57
58 # This value determines the NixOS release with which your system is
59 # to be compatible, in order to avoid breaking some software such as
60 # database servers. You should change this only after NixOS release
61 # notes say you should.
62 system.stateVersion = "18.09"; # Did you read the comment?
63}
diff --git a/nixops/eldiron.nix b/nixops/eldiron.nix
index 51af1f6..649e431 100644
--- a/nixops/eldiron.nix
+++ b/nixops/eldiron.nix
@@ -5,66 +5,5 @@
5 enableRollback = true; 5 enableRollback = true;
6 }; 6 };
7 7
8 eldiron = { config, pkgs, myconfig, ... }: 8 eldiron = import ../modules/private/system/eldiron.nix { inherit privateFiles; };
9 {
10 boot.kernelPackages = pkgs.linuxPackages_latest;
11 _module.args.privateFiles = privateFiles;
12
13 networking = {
14 firewall.enable = true;
15 # 176.9.151.89 declared in nixops -> infra / tools
16 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
17 (n: ips: { address = ips.ip4; prefixLength = 32; })
18 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.eldiron.ips);
19 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
20 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
21 myconfig.env.servers.eldiron.ips);
22 };
23
24 imports = builtins.attrValues (import ../modules);
25
26 myServices.buildbot.enable = true;
27 myServices.databases.enable = true;
28 myServices.gitolite.enable = true;
29 myServices.irc.enable = true;
30 myServices.pub.enable = true;
31 myServices.tasks.enable = true;
32 services.pure-ftpd.enable = true;
33
34 deployment = {
35 targetEnv = "hetzner";
36 hetzner = {
37 robotUser = myconfig.env.hetzner.user;
38 robotPass = myconfig.env.hetzner.pass;
39 mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4;
40 partitions = ''
41 clearpart --all --initlabel --drives=sda,sdb
42
43 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
44 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
45
46 part raid.1 --grow --ondisk=sda
47 part raid.2 --grow --ondisk=sdb
48
49 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
50 '';
51 };
52 };
53
54 services.cron = {
55 enable = true;
56 systemCronJobs = [
57 ''
58 # The star after /var/lib/* avoids deleting all folders in case of problem
59 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
60 ''
61 ];
62 };
63
64 # This value determines the NixOS release with which your system is
65 # to be compatible, in order to avoid breaking some software such as
66 # database servers. You should change this only after NixOS release
67 # notes say you should.
68 system.stateVersion = "18.09"; # Did you read the comment?
69 };
70} 9}