From f807d9177bb795f034bfd11932e4fbfa6671805f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 22 May 2019 21:01:44 +0200 Subject: [PATCH] Move eldiron config to modules --- modules/private/system/eldiron.nix | 63 ++++++++++++++++++++++++++++++ nixops/eldiron.nix | 63 +----------------------------- 2 files changed, 64 insertions(+), 62 deletions(-) create mode 100644 modules/private/system/eldiron.nix 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 @@ +{ privateFiles }: +{ config, pkgs, myconfig, ... }: +{ + boot.kernelPackages = pkgs.linuxPackages_latest; + _module.args.privateFiles = privateFiles; + + networking = { + firewall.enable = true; + # 176.9.151.89 declared in nixops -> infra / tools + interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList + (n: ips: { address = ips.ip4; prefixLength = 32; }) + (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.eldiron.ips); + interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList + (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) + myconfig.env.servers.eldiron.ips); + }; + + imports = builtins.attrValues (import ../..); + + myServices.buildbot.enable = true; + myServices.databases.enable = true; + myServices.gitolite.enable = true; + myServices.irc.enable = true; + myServices.pub.enable = true; + myServices.tasks.enable = true; + services.pure-ftpd.enable = true; + + deployment = { + targetEnv = "hetzner"; + hetzner = { + robotUser = myconfig.env.hetzner.user; + robotPass = myconfig.env.hetzner.pass; + mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4; + partitions = '' + clearpart --all --initlabel --drives=sda,sdb + + part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda + part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb + + part raid.1 --grow --ondisk=sda + part raid.2 --grow --ondisk=sdb + + raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2 + ''; + }; + }; + + services.cron = { + enable = true; + systemCronJobs = [ + '' + # The star after /var/lib/* avoids deleting all folders in case of problem + 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 + '' + ]; + }; + + # This value determines the NixOS release with which your system is + # to be compatible, in order to avoid breaking some software such as + # database servers. You should change this only after NixOS release + # notes say you should. + system.stateVersion = "18.09"; # Did you read the comment? +} 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 @@ enableRollback = true; }; - eldiron = { config, pkgs, myconfig, ... }: - { - boot.kernelPackages = pkgs.linuxPackages_latest; - _module.args.privateFiles = privateFiles; - - networking = { - firewall.enable = true; - # 176.9.151.89 declared in nixops -> infra / tools - interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList - (n: ips: { address = ips.ip4; prefixLength = 32; }) - (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.eldiron.ips); - interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList - (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) - myconfig.env.servers.eldiron.ips); - }; - - imports = builtins.attrValues (import ../modules); - - myServices.buildbot.enable = true; - myServices.databases.enable = true; - myServices.gitolite.enable = true; - myServices.irc.enable = true; - myServices.pub.enable = true; - myServices.tasks.enable = true; - services.pure-ftpd.enable = true; - - deployment = { - targetEnv = "hetzner"; - hetzner = { - robotUser = myconfig.env.hetzner.user; - robotPass = myconfig.env.hetzner.pass; - mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4; - partitions = '' - clearpart --all --initlabel --drives=sda,sdb - - part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda - part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb - - part raid.1 --grow --ondisk=sda - part raid.2 --grow --ondisk=sdb - - raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2 - ''; - }; - }; - - services.cron = { - enable = true; - systemCronJobs = [ - '' - # The star after /var/lib/* avoids deleting all folders in case of problem - 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 - '' - ]; - }; - - # This value determines the NixOS release with which your system is - # to be compatible, in order to avoid breaking some software such as - # database servers. You should change this only after NixOS release - # notes say you should. - system.stateVersion = "18.09"; # Did you read the comment? - }; + eldiron = import ../modules/private/system/eldiron.nix { inherit privateFiles; }; } -- 2.41.0