Skip to content
Snippets Groups Projects
grid.nix 1.93 KiB
Newer Older
let
  pkgs = import <nixpkgs> { };

  config = pkgs.lib.trivial.importJSON ./config.json;
  sshUsers = import ./secrets/users.nix;

  # Get absolute vpn key directory path, as a string:
  monitoringvpnKeyDir = toString ./. + "/${config.monitoringvpnKeyDir}";

  payments = let publicIPv4 = "192.168.67.21"; in {
    imports = [
      (import ./virtual-hardware.nix ({ inherit publicIPv4; }))
      (gridlib.customize-issuer config sshUsers monitoringvpnKeyDir "172.23.23.11" "19.03")
    ];
  };

  storage1 = let publicIPv4 = "192.168.67.22"; in {
    imports = [
      (import ./virtual-hardware.nix ({ inherit publicIPv4; }))
      (gridlib.customize-storage config sshUsers publicIPv4 monitoringvpnKeyDir "172.23.23.12" "19.09")
    ];
  };

  storage2 = let publicIPv4 = "192.168.67.23"; in {
    imports = [
      (import ./virtual-hardware.nix ({ inherit publicIPv4; }))
      (gridlib.customize-storage config sshUsers publicIPv4 monitoringvpnKeyDir "172.23.23.13" "19.09")
    ];
  };

  monitoring = let publicIPv4 = "192.168.67.24"; in {
    imports = [
      (import ./virtual-hardware.nix ({ inherit publicIPv4; }))
      (gridlib.customize-monitoring hostsMap monitoringvpnKeyDir publicIPv4 "172.23.23.1" vpnClientIPs nodeExporterTargets [] "19.09")
    ];
  };

  # TBD: derive these automatically:
  hostsMap = {
    "172.23.23.1"  = [ "monitoring" "monitoring.monitoringvpn" ];
    "172.23.23.11" = [ "payments" "payments.monitoringvpn" ];
    "172.23.23.12" = [ "storage1" "storage1.monitoringvpn" ];
    "172.23.23.13" = [ "storage2" "storage2.monitoringvpn" ];
  };
  vpnClientIPs = [ "172.23.23.11" "172.23.23.12" "172.23.23.13" ];
  nodeExporterTargets = [ "monitoring" "payments" "storage1" "storage2" ];

in {
  network = {
    description = "PrivateStorage.io LocalDev Grid";
  inherit payments monitoring storage1 storage2;