# Import nixpkgs with niv. https://dataswamp.org/~solene/2022-01-12-nix-niv-shell.html#_Create_a_shell.nix_file
let
  sources = import ./nix/sources.nix;
in
{
  # Colmena config: https://colmena.cli.rs/0.4/tutorial/index.html#basic-configuration
  # Colmena local node: https://colmena.cli.rs/0.4/features/apply-local.html

  meta = {
    # Pin the Nixpkgs version with niv.
    # Note: You can also override Nixpkgs by node.
    nixpkgs = import sources.nixpkgs {};
  };

  defaults = { ... }: {
    # This module will be imported by all hosts.
  };

  #
  # LOCAL DEPLOYMENT
  #

  yodaTux = { name, nodes, ... }: {
    # Import the per-host configuration file.
    imports = [ ./hosts/${name}/configuration.nix ];

    deployment = {
      # Local deployment.
      allowLocalDeployment = true;
      targetHost = null;
    };
  };

  yodaTab = { name, nodes, ... }: {
    # Import the per-host configuration file.
    imports = [ ./hosts/${name}/configuration.nix ];

    deployment = {
      # Local deployment.
      allowLocalDeployment = true;
      targetHost = null;
    };
  };

  yodaGaming = { name, nodes, ... }: {
    # Import the per-host configuration file.
    imports = [ ./hosts/${name}/configuration.nix ];

    deployment = {
      # Local deployment.
      allowLocalDeployment = true;
      targetHost = null;
    };
  };

  #
  # SSH DEPLOYMENT
  #

  remoteTab = { name, nodes, ... }: {
    # Import the per-host configuration file.
    imports = [ ./hosts/yodaTab/configuration.nix ];

    deployment = {
      # SSH deployment.
      targetHost = "192.168.178.20";
      targetPort = 22;

      tags = [];
    };
  };

  remoteGaming = { name, nodes, ... }: {
    # Import the per-host configuration file.
    imports = [ ./hosts/yodaGaming/configuration.nix ];

    deployment = {
      # SSH deployment.
      targetHost = "192.168.178.54";
      targetPort = 22;

      tags = [];
    };
  };

#  yodaYoga = { name, nodes, ... }: {
#    # Import the per-host configuration file.
#    imports = [ ./hosts/${name}/configuration.nix ];
#
#    deployment = {
#      # SSH deployment.
#      targetHost = "yodayoga.p1st.de";
#      targetPort = 2224;
#
#      tags = [ "server" ];
#    };
#  };

  yodaHedgehog = { name, nodes, ... }: {
    # Import the per-host configuration file.
    imports = [ ./hosts/${name}/configuration.nix ];

    # local IP: 192.168.178.118
    deployment = {
      # Local deployment.
      #allowLocalDeployment = true;
      # SSH deployment.
      targetHost = "yodahedgehog.p1st.de";
      targetPort = 2226;

      tags = [ "server" ];
    };
  };

  yodaNas = { name, nodes, ... }: {
    # Import the per-host configuration file.
    imports = [ ./hosts/${name}/configuration.nix ];

    deployment = {
      # Local deployment.
      #allowLocalDeployment = true;
      # SSH deployment.
      # local IP: 192.168.178.190
      targetHost = "yodanas.p1st.de";
      targetPort = 2222;

      tags = [ "server" ];
    };
  };
}