]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/system/eldiron.nix
Switch to colemna
[perso/Immae/Config/Nix.git] / modules / private / system / eldiron.nix
index 5fb9887cd2f79f95de85ac6c60546c8c88a15f64..091c9f46e8d63ccbd564e78b1399cea81153adfd 100644 (file)
@@ -2,8 +2,7 @@
 {
   deployment = {
     targetUser = "root";
-    targetHost = config.hostEnv.ips.main.ip4;
-    substituteOnDestination = true;
+    targetHost = lib.head config.hostEnv.ips.main.ip4;
   };
   # ssh-keyscan eldiron | nix-shell -p ssh-to-age --run ssh-to-age
   secrets.ageKeys = [ "age1dxr5lhvtnjssfaqpnf6qx80h8gfwkxg3tdf35m6n9wljmk7wadfs3kmahj" ];
@@ -18,7 +17,7 @@
     };
     supportedFilesystems = [ "zfs" ];
     kernelParams = ["zfs.zfs_arc_max=6442450944"];
-    kernelPackages = pkgs.linuxPackages_latest;
+    kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
     initrd.availableKernelModules = [ "ahci" "sd_mod" ];
     initrd.secrets = {
       "/boot/pass.key" = "/boot/pass.key";
@@ -27,7 +26,7 @@
   services.udev.extraRules = ''
     ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="c8:60:00:56:a0:88", NAME="eth0"
   '';
-  nix.maxJobs = 8;
+  nix.settings.max-jobs = 8;
   powerManagement.cpuFreqGovernor = "powersave";
   myEnv = import ../../../nixops/secrets/environment.nix;
 
   networking = {
     hostId = "8262ca33"; # generated with head -c4 /dev/urandom | od -A none -t x4
     firewall.enable = true;
+    firewall.allowedTCPPorts = [ config.myEnv.ports.zrepl_flony ];
     # FIXME: on next reboot, remove the /27 and the localCommands
-    interfaces."eth0".ipv4.addresses =
-      pkgs.lib.attrsets.mapAttrsToList
-        (n: ips: { address = ips.ip4; prefixLength = 32; })
-        (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips)
-      ++ [ { address = config.hostEnv.ips.main.ip4; prefixLength = 27; } ];
+    interfaces."eth0".ipv4.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
+      (n: ips: map (ip: { address = ip; prefixLength = 32; }) (ips.ip4 or []))
+      (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips))
+      ++ [ { address = lib.head config.hostEnv.ips.main.ip4; prefixLength = 27; } ];
     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 []))
       config.hostEnv.ips);
   myServices.ejabberd.enable = true;
   myServices.vpn.enable = true;
   myServices.ftp.enable = true;
-  services.duplyBackup.enable = false;
-  services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies";
 
   services.netdata.enable = true;
   services.netdata.config.global."memory mode" = "none";
   services.netdata.config.health."enabled" = "no";
   services.netdata.config.web.mode = "none";
   users.users."${config.services.netdata.user}".extraGroups = [ "keys" ];
-  environment.etc."netdata/stream.conf".source = config.secrets.fullPaths."netdata-stream.conf";
+  services.netdata.configDir."stream.conf" = config.secrets.fullPaths."netdata-stream.conf";
   secrets.keys = {
     "netdata-stream.conf" = {
       user = config.services.netdata.user;
     };
   };
   programs.ssh.knownHosts.dilion = {
-    hostNames = ["dilion.immae.eu"];
+    extraHostNames = ["dilion.immae.eu"];
     publicKey = let
       profile = config.myEnv.rsync_backup.profiles.dilion;
     in
     ];
   };
 
-  fileSystems."/var/lib/pub/immae/devtools" = {
-    device = "/run/current-system/sw/bin/bindfs#/var/lib/ftp/devtools.immae.eu/";
-    fsType = "fuse";
-    options = [ "force-user=pub" "create-for-user=wwwrun" "create-for-group=wwwrun" ];
-  };
   environment.systemPackages = [ pkgs.bindfs ];
 
-  services.zrepl = {
+  immaeServices.zrepl = {
     enable = true;
     config = let
       redis_dump = pkgs.writeScript "redis-dump" ''
             "zpool/root/etc": true
             "zpool/root/var<": true
           connect:
-            type: ssh+stdinserver
-            host: dilion.immae.eu
-            user: backup
-            port: 22
-            identity_file: ${config.secrets.fullPaths."zrepl_backup/identity"}
+            address: dilion.immae.eu:19000
+            type: tls
+            server_cn: dilion
+            ca: ${config.secrets.fullPaths."zrepl/certificates/dilion.crt"}
+            cert: ${config.secrets.fullPaths."zrepl/certificates/eldiron.crt"}
+            key: ${config.secrets.fullPaths."zrepl/eldiron.key"}
           snapshotting:
             type: periodic
             prefix: zrepl_
               - type: grid
                 grid: 6x4h | 7x1d | 4x7d | 6x30d
                 regex: "^zrepl_.*"
+        - type: source
+          # must not change
+          name: "backup-to-wd-zpool"
+          serve:
+            type: tls
+            listen: :${builtins.toString config.myEnv.ports.zrepl_flony}
+            ca: ${config.secrets.fullPaths."zrepl/certificates/flony.crt"}
+            cert: ${config.secrets.fullPaths."zrepl/certificates/eldiron.crt"}
+            key: ${config.secrets.fullPaths."zrepl/eldiron.key"}
+            client_cns:
+              - flony
+          filesystems:
+            "zpool/root": true
+            "zpool/root/etc": true
+            "zpool/root/var<": true
+            "zfast/root/var<": true
+          send:
+            encrypted: true
+          snapshotting:
+            type: manual
     '';
   };
   # This value determines the NixOS release with which your system is