2015-09-27 20:01:43 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2017-02-22 23:47:24 +00:00
|
|
|
let
|
|
|
|
cfg = config.amazonImage;
|
|
|
|
in {
|
2015-09-27 20:01:43 +01:00
|
|
|
|
2017-04-17 04:08:37 +01:00
|
|
|
imports = [ ../../../modules/virtualisation/amazon-image.nix ];
|
2015-09-27 20:01:43 +01:00
|
|
|
|
2017-02-22 23:47:24 +00:00
|
|
|
options.amazonImage = {
|
|
|
|
contents = mkOption {
|
|
|
|
example = literalExample ''
|
|
|
|
[ { source = pkgs.memtest86 + "/memtest.bin";
|
|
|
|
target = "boot/memtest.bin";
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
This option lists files to be copied to fixed locations in the
|
|
|
|
generated image. Glob patterns work.
|
|
|
|
'';
|
|
|
|
};
|
2017-08-10 22:40:21 +01:00
|
|
|
|
2017-08-11 02:57:38 +01:00
|
|
|
sizeMB = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = if config.ec2.hvm then 2048 else 8192;
|
|
|
|
description = "The size in MB of the image";
|
|
|
|
};
|
|
|
|
|
2017-08-10 22:40:21 +01:00
|
|
|
format = mkOption {
|
2017-08-10 23:57:26 +01:00
|
|
|
type = types.enum [ "raw" "qcow2" "vpc" ];
|
2017-08-10 22:40:21 +01:00
|
|
|
default = "qcow2";
|
|
|
|
description = "The image format to output";
|
|
|
|
};
|
2017-02-22 23:47:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config.system.build.amazonImage = import ../../../lib/make-disk-image.nix {
|
2016-03-30 20:48:12 +01:00
|
|
|
inherit lib config;
|
2017-08-10 22:40:21 +01:00
|
|
|
inherit (cfg) contents format;
|
2016-03-30 20:48:12 +01:00
|
|
|
pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
|
2015-09-27 20:01:43 +01:00
|
|
|
partitioned = config.ec2.hvm;
|
2017-08-11 02:57:38 +01:00
|
|
|
diskSize = sizeMB;
|
2015-09-27 20:01:43 +01:00
|
|
|
configFile = pkgs.writeText "configuration.nix"
|
|
|
|
''
|
|
|
|
{
|
|
|
|
imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
|
|
|
|
${optionalString config.ec2.hvm ''
|
|
|
|
ec2.hvm = true;
|
|
|
|
''}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|