mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-31 14:41:27 +00:00
Fix EC2 creation script for latest nixops
This commit is contained in:
parent
c93f57ba1c
commit
361eb3a5f5
5
nixos/maintainers/scripts/ec2/amazon-base-config.nix
Normal file
5
nixos/maintainers/scripts/ec2/amazon-base-config.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{ modulesPath, ...}:
|
||||
{
|
||||
imports = [ "${modulesPath}/virtualisation/amazon-config.nix" ];
|
||||
services.journald.rateLimitBurst = 0;
|
||||
}
|
@ -8,9 +8,11 @@ import nixops.util
|
||||
from nixops import deployment
|
||||
from boto.ec2.blockdevicemapping import BlockDeviceMapping, BlockDeviceType
|
||||
import boto.ec2
|
||||
from nixops.statefile import StateFile, get_default_state_file
|
||||
|
||||
parser = argparse.ArgumentParser(description='Create an EBS-backed NixOS AMI')
|
||||
parser.add_argument('--region', dest='region', required=True, help='EC2 region to create the image in')
|
||||
parser.add_argument('--channel', dest='channel', default="13.10", help='Channel to use')
|
||||
parser.add_argument('--keep', dest='keep', action='store_true', help='Keep NixOps machine after use')
|
||||
parser.add_argument('--hvm', dest='hvm', action='store_true', help='Create HVM image')
|
||||
parser.add_argument('--key', dest='key_name', action='store_true', help='Keypair used for HVM instance creation', default="rob")
|
||||
@ -37,11 +39,11 @@ f.write('''{{
|
||||
'''.format(args.region, ebs_size))
|
||||
f.close()
|
||||
|
||||
db = deployment.open_database(deployment.get_default_state_file())
|
||||
db = StateFile(get_default_state_file())
|
||||
try:
|
||||
depl = deployment.open_deployment(db, "ebs-creator")
|
||||
depl = db.open_deployment("ebs-creator")
|
||||
except Exception:
|
||||
depl = deployment.create_deployment(db)
|
||||
depl = db.create_deployment()
|
||||
depl.name = "ebs-creator"
|
||||
depl.auto_response = "y"
|
||||
depl.nix_exprs = [os.path.abspath("./ebs-creator.nix"), os.path.abspath("./ebs-creator-config.nix")]
|
||||
@ -64,7 +66,7 @@ m.run_command("mkdir -p /mnt")
|
||||
m.run_command("mount {0} /mnt".format(device))
|
||||
m.run_command("touch /mnt/.ebs")
|
||||
m.run_command("mkdir -p /mnt/etc/nixos")
|
||||
m.run_command("nix-channel --add http://nixos.org/channels/nixos-unstable")
|
||||
m.run_command("nix-channel --add http://nixos.org/channels/nixos-{} nixos".format(args.channel))
|
||||
m.run_command("nix-channel --update")
|
||||
m.run_command("nixos-rebuild switch")
|
||||
version = m.run_command("nixos-version", capture_stdout=True).replace('"', '').rstrip()
|
||||
|
Loading…
Reference in New Issue
Block a user