2010-11-25 00:00:21 +01:00
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
2011-10-25 03:59:39 +02:00
|
|
|
|
let cfg = config.deployment; in
|
|
|
|
|
|
2010-11-25 00:00:21 +01:00
|
|
|
|
{
|
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2011-04-29 13:28:43 +02:00
|
|
|
|
deployment.targetEnv = mkOption {
|
|
|
|
|
default = "none";
|
|
|
|
|
example = "ec2";
|
2011-10-26 20:08:58 +02:00
|
|
|
|
type = types.uniq types.string;
|
2011-04-29 13:28:43 +02:00
|
|
|
|
description = ''
|
|
|
|
|
This option specifies the type of the environment in which the
|
|
|
|
|
machine is to be deployed by
|
|
|
|
|
<command>nixos-deploy-network</command>. Currently, it can
|
|
|
|
|
have the following values. <literal>"none"</literal> means
|
|
|
|
|
deploying to a pre-existing physical or virtual NixOS machine,
|
|
|
|
|
reachable via SSH under the hostname or IP address specified
|
|
|
|
|
in <option>deployment.targetHost</option>.
|
|
|
|
|
<literal>"ec2"</literal> means that a virtual machine should be
|
|
|
|
|
instantiated in an Amazon EC2-compatible cloud environment
|
|
|
|
|
(see <option>deployment.ec2.*</option>).
|
|
|
|
|
<literal>"adhoc-cloud"</literal> means that a virtual machine
|
|
|
|
|
should be instantiated by executing certain commands via SSH
|
|
|
|
|
on a cloud controller machine (see
|
|
|
|
|
<option>deployment.adhoc.*</option>). This is primarily
|
|
|
|
|
useful for debugging <command>nixos-deploy-network</command>.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2010-12-14 14:36:54 +01:00
|
|
|
|
deployment.targetHost = mkOption {
|
|
|
|
|
default = config.networking.hostName;
|
2011-10-26 20:08:58 +02:00
|
|
|
|
type = types.uniq types.string;
|
2010-12-14 14:36:54 +01:00
|
|
|
|
description = ''
|
2011-04-29 13:28:43 +02:00
|
|
|
|
This option specifies a hostname or IP address which can be
|
|
|
|
|
used by <command>nixos-deploy-network</command> to execute
|
|
|
|
|
remote deployment operations.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# EC2/Nova/Eucalyptus-specific options.
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2011-06-16 16:14:50 +02:00
|
|
|
|
deployment.ec2.type = mkOption {
|
|
|
|
|
default = "ec2";
|
|
|
|
|
example = "nova";
|
2011-10-26 20:08:58 +02:00
|
|
|
|
type = types.uniq types.string;
|
2011-06-16 16:14:50 +02:00
|
|
|
|
description = ''
|
|
|
|
|
Specifies the type of cloud. This affects the machine
|
|
|
|
|
configuration. Current values are <literal>"ec2"</literal>
|
|
|
|
|
and <literal>"nova"</literal>.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-12 17:30:56 +02:00
|
|
|
|
deployment.ec2.controller = mkOption {
|
2011-10-25 03:59:39 +02:00
|
|
|
|
example = https://ec2.eu-west-1.amazonaws.com/;
|
|
|
|
|
type = types.uniq types.string;
|
2011-04-29 13:28:43 +02:00
|
|
|
|
description = ''
|
2011-05-12 17:30:56 +02:00
|
|
|
|
URI of an Amazon EC2-compatible cloud controller web service,
|
2011-10-25 03:59:39 +02:00
|
|
|
|
used to create and manage virtual machines. If you're using
|
|
|
|
|
EC2, it's more convenient to set
|
2011-10-27 01:44:13 +02:00
|
|
|
|
<option>deployment.ec2.region</option>.
|
2011-10-25 03:59:39 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-27 01:44:13 +02:00
|
|
|
|
deployment.ec2.region = mkOption {
|
2011-10-25 03:59:39 +02:00
|
|
|
|
default = "";
|
|
|
|
|
example = "us-east-1";
|
|
|
|
|
type = types.uniq types.string;
|
|
|
|
|
description = ''
|
2011-10-27 01:44:13 +02:00
|
|
|
|
Amazon EC2 region in which the instance is to be deployed.
|
|
|
|
|
This option only applies when using EC2. It implicitly sets
|
2011-10-25 03:59:39 +02:00
|
|
|
|
<option>deployment.ec2.controller</option> and
|
|
|
|
|
<option>deployment.ec2.ami</option>.
|
2011-04-29 13:28:43 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
deployment.ec2.ami = mkOption {
|
|
|
|
|
example = "ami-ecb49e98";
|
2011-10-25 03:59:39 +02:00
|
|
|
|
type = types.uniq types.string;
|
2011-04-29 13:28:43 +02:00
|
|
|
|
description = ''
|
|
|
|
|
EC2 identifier of the AMI disk image used in the virtual
|
|
|
|
|
machine. This must be a NixOS image providing SSH access.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2011-04-29 13:28:43 +02:00
|
|
|
|
deployment.ec2.instanceType = mkOption {
|
|
|
|
|
default = "m1.small";
|
|
|
|
|
example = "m1.large";
|
2011-10-25 03:59:39 +02:00
|
|
|
|
type = types.uniq types.string;
|
2011-04-29 13:28:43 +02:00
|
|
|
|
description = ''
|
|
|
|
|
EC2 instance type. See <link
|
|
|
|
|
xlink:href='http://aws.amazon.com/ec2/instance-types/'/> for a
|
|
|
|
|
list of valid Amazon EC2 instance types.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-12 17:30:56 +02:00
|
|
|
|
deployment.ec2.keyPair = mkOption {
|
|
|
|
|
example = "my-keypair";
|
2011-10-25 17:27:29 +02:00
|
|
|
|
type = types.uniq types.string;
|
2011-05-12 17:30:56 +02:00
|
|
|
|
description = ''
|
|
|
|
|
Name of the SSH key pair to be used to communicate securely
|
|
|
|
|
with the instance. Key pairs can be created using the
|
|
|
|
|
<command>ec2-add-keypair</command> command.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-25 17:27:29 +02:00
|
|
|
|
deployment.ec2.securityGroups = mkOption {
|
|
|
|
|
default = [ "default" ];
|
|
|
|
|
example = [ "my-group" "my-other-group" ];
|
|
|
|
|
type = types.list types.string;
|
2011-10-24 21:27:58 +02:00
|
|
|
|
description = ''
|
2011-10-25 17:27:29 +02:00
|
|
|
|
Security groups for the instance. These determine the
|
|
|
|
|
firewall rules applied to the instance.
|
2011-10-24 21:27:58 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-29 13:28:43 +02:00
|
|
|
|
# Ad hoc cloud options.
|
|
|
|
|
|
|
|
|
|
deployment.adhoc.controller = mkOption {
|
2011-04-29 15:24:24 +02:00
|
|
|
|
example = "cloud.example.org";
|
2011-10-26 20:08:58 +02:00
|
|
|
|
type = types.uniq types.string;
|
2011-04-29 13:28:43 +02:00
|
|
|
|
description = ''
|
|
|
|
|
Hostname or IP addres of the machine to which
|
|
|
|
|
<command>nixos-deploy-network</command> should connect (via
|
|
|
|
|
SSH) to execute commands to start VMs or query their status.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2011-05-08 22:51:40 +02:00
|
|
|
|
deployment.adhoc.createVMCommand = mkOption {
|
2011-04-29 13:28:43 +02:00
|
|
|
|
default = "create-vm";
|
2011-10-26 20:08:58 +02:00
|
|
|
|
type = types.uniq types.string;
|
2011-04-29 13:28:43 +02:00
|
|
|
|
description = ''
|
|
|
|
|
Remote command to create a NixOS virtual machine. It should
|
|
|
|
|
print an identifier denoting the VM on standard output.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2011-05-10 15:12:35 +02:00
|
|
|
|
deployment.adhoc.destroyVMCommand = mkOption {
|
|
|
|
|
default = "destroy-vm";
|
2011-10-26 20:08:58 +02:00
|
|
|
|
type = types.uniq types.string;
|
2011-05-10 15:12:35 +02:00
|
|
|
|
description = ''
|
|
|
|
|
Remote command to destroy a previously created NixOS virtual
|
|
|
|
|
machine.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2011-04-29 13:28:43 +02:00
|
|
|
|
deployment.adhoc.queryVMCommand = mkOption {
|
|
|
|
|
default = "query-vm";
|
2011-10-26 20:08:58 +02:00
|
|
|
|
type = types.uniq types.string;
|
2011-04-29 13:28:43 +02:00
|
|
|
|
description = ''
|
|
|
|
|
Remote command to query information about a previously created
|
|
|
|
|
NixOS virtual machine. It should print the IPv6 address of
|
|
|
|
|
the VM on standard output.
|
2010-12-14 14:36:54 +01:00
|
|
|
|
'';
|
2010-11-25 00:00:21 +01:00
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2011-10-25 06:01:34 +02:00
|
|
|
|
# Computed options useful for referring to other machines in
|
|
|
|
|
# network specifications.
|
|
|
|
|
|
|
|
|
|
networking.privateIPv4 = mkOption {
|
|
|
|
|
example = "10.1.2.3";
|
|
|
|
|
type = types.uniq types.string;
|
|
|
|
|
description = ''
|
|
|
|
|
IPv4 address of this machine within in the logical network.
|
|
|
|
|
This address can be used by other machines in the logical
|
|
|
|
|
network to reach this machine. However, it need not be
|
|
|
|
|
visible to the outside (i.e., publicly routable).
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
networking.publicIPv4 = mkOption {
|
|
|
|
|
example = "198.51.100.123";
|
|
|
|
|
type = types.uniq types.string;
|
|
|
|
|
description = ''
|
|
|
|
|
Publicly routable IPv4 address of this machine.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2010-11-25 00:00:21 +01:00
|
|
|
|
};
|
2011-10-25 03:59:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
|
2011-10-27 01:44:13 +02:00
|
|
|
|
deployment.ec2 = mkIf (cfg.ec2.region != "") {
|
2011-10-25 03:59:39 +02:00
|
|
|
|
|
2011-10-27 01:44:13 +02:00
|
|
|
|
controller = mkDefault "https://ec2.${cfg.ec2.region}.amazonaws.com/";
|
2011-11-08 22:28:42 +01:00
|
|
|
|
|
|
|
|
|
# The list below is generated by running the "create-amis.sh" script, then doing:
|
|
|
|
|
# $ while read system region ami; do echo " if cfg.ec2.region == \"$region\" && config.nixpkgs.system == \"$system\" then \"$ami\" else"; done < amis
|
2011-10-25 03:59:39 +02:00
|
|
|
|
ami = mkDefault (
|
2011-11-08 22:28:42 +01:00
|
|
|
|
if cfg.ec2.region == "eu-west-1" && config.nixpkgs.system == "x86_64-linux" then "ami-65dae711" else
|
|
|
|
|
if cfg.ec2.region == "us-east-1" && config.nixpkgs.system == "x86_64-linux" then "ami-95bb72fc" else
|
|
|
|
|
if cfg.ec2.region == "us-west-1" && config.nixpkgs.system == "x86_64-linux" then "ami-0b0c534e" else
|
2011-10-25 03:59:39 +02:00
|
|
|
|
# !!! Doesn't work, not lazy enough.
|
2011-10-27 01:44:13 +02:00
|
|
|
|
# throw "I don't know an AMI for region ‘${cfg.ec2.region}’ and platform type ‘${config.nixpkgs.system}’"
|
2011-10-25 03:59:39 +02:00
|
|
|
|
"");
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2010-11-25 00:00:21 +01:00
|
|
|
|
}
|