]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/eldiron.nix
Move rest of the modules outside of nixops
[perso/Immae/Config/Nix.git] / nixops / eldiron.nix
index 7ce33a927f194985f9f3e0b2199d9e8baa63afcb..51af1f626622c55f0d9ab62bac7537bb144c0360 100644 (file)
@@ -1,50 +1,42 @@
+{ privateFiles ? ./. }:
 {
   network = {
     description = "Immae's network";
     enableRollback = true;
   };
 
-  eldiron = { config, pkgs, mylibs, myconfig, ... }:
-    with mylibs;
+  eldiron = { config, pkgs, myconfig, ... }:
   {
-    _module.args = {
-      mylibs = import ../libs.nix;
-      myconfig = {
-        env = import ./environment.nix;
-        ips = {
-          main = "176.9.151.89";
-          production = "176.9.151.154";
-          integration = "176.9.151.155";
-        };
-      };
-    };
-
-    imports = [
-      ./modules/certificates.nix
-      ./modules/gitolite
-      ./modules/databases
-      ./modules/websites
-      ./modules/mail
-    ];
-    services.myGitolite.enable = true;
-    services.myDatabases.enable = true;
-    services.myWebsites.production.enable = true;
-    services.myWebsites.integration.enable = true;
-    services.myWebsites.tools.enable = true;
+    boot.kernelPackages = pkgs.linuxPackages_latest;
+    _module.args.privateFiles = privateFiles;
 
     networking = {
-      firewall = {
-        enable = true;
-        allowedTCPPorts = [ 22 ];
-      };
+      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.ips.main;
+        mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4;
         partitions = ''
           clearpart --all --initlabel --drives=sda,sdb
 
       };
     };
 
-    environment.systemPackages = [
-      pkgs.telnet
-      pkgs.htop
-      pkgs.vim
-    ];
-
-    services.openssh.extraConfig = ''
-      AuthorizedKeysCommand     /etc/ssh/ldap_authorized_keys
-      AuthorizedKeysCommandUser nobody
-      '';
-
-    environment.etc."ssh/ldap_authorized_keys" = let
-      ldap_authorized_keys =
-        wrap {
-          name = "ldap_authorized_keys";
-          file = ./ldap_authorized_keys.sh;
-          vars = {
-            LDAP_PASS = myconfig.env.sshd.ldap.password;
-            GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell";
-            ECHO = "${pkgs.coreutils}/bin/echo";
-          };
-          paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ];
-        };
-    in {
+    services.cron = {
       enable = true;
-      mode = "0755";
-      user = "root";
-      source = ldap_authorized_keys;
+      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?
   };
 }