2015-09-27 21:01:43 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2017-02-23 00:47:24 +01:00
|
|
|
let
|
|
|
|
cfg = config.amazonImage;
|
|
|
|
in {
|
2015-09-27 21:01:43 +02:00
|
|
|
|
2017-04-17 05:08:37 +02:00
|
|
|
imports = [ ../../../modules/virtualisation/amazon-image.nix ];
|
2015-09-27 21:01:43 +02:00
|
|
|
|
2017-02-23 00:47:24 +01: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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config.system.build.amazonImage = import ../../../lib/make-disk-image.nix {
|
2016-03-30 21:48:12 +02:00
|
|
|
inherit lib config;
|
2017-02-23 00:47:24 +01:00
|
|
|
inherit (cfg) contents;
|
2016-03-30 21:48:12 +02:00
|
|
|
pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
|
2015-09-27 21:01:43 +02:00
|
|
|
partitioned = config.ec2.hvm;
|
2015-09-28 20:24:27 +02:00
|
|
|
diskSize = if config.ec2.hvm then 2048 else 8192;
|
2016-03-30 21:48:12 +02:00
|
|
|
format = "qcow2";
|
2015-09-27 21:01:43 +02:00
|
|
|
configFile = pkgs.writeText "configuration.nix"
|
|
|
|
''
|
|
|
|
{
|
|
|
|
imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
|
|
|
|
${optionalString config.ec2.hvm ''
|
|
|
|
ec2.hvm = true;
|
|
|
|
''}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|