mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-15 14:09:17 +03:00
ec2/amazon-image: use system.build.image
and rename: - amazonImage.name -> image.baseName
This commit is contained in:
parent
a582fba754
commit
fdb144fb41
2 changed files with 23 additions and 15 deletions
|
@ -20,6 +20,7 @@ in
|
||||||
imports = [
|
imports = [
|
||||||
../../../modules/virtualisation/amazon-image.nix
|
../../../modules/virtualisation/amazon-image.nix
|
||||||
../../../modules/virtualisation/disk-size-option.nix
|
../../../modules/virtualisation/disk-size-option.nix
|
||||||
|
../../../modules/image/file-options.nix
|
||||||
(lib.mkRenamedOptionModuleWith {
|
(lib.mkRenamedOptionModuleWith {
|
||||||
sinceRelease = 2411;
|
sinceRelease = 2411;
|
||||||
from = [
|
from = [
|
||||||
|
@ -31,6 +32,17 @@ in
|
||||||
"diskSize"
|
"diskSize"
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
|
(lib.mkRenamedOptionModuleWith {
|
||||||
|
sinceRelease = 2505;
|
||||||
|
from = [
|
||||||
|
"amazonImage"
|
||||||
|
"name"
|
||||||
|
];
|
||||||
|
to = [
|
||||||
|
"image"
|
||||||
|
"baseName"
|
||||||
|
];
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
# Amazon recommends setting this to the highest possible value for a good EBS
|
# Amazon recommends setting this to the highest possible value for a good EBS
|
||||||
|
@ -44,12 +56,6 @@ in
|
||||||
[ "nvme_core.io_timeout=${timeout}" ];
|
[ "nvme_core.io_timeout=${timeout}" ];
|
||||||
|
|
||||||
options.amazonImage = {
|
options.amazonImage = {
|
||||||
name = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "The name of the generated derivation";
|
|
||||||
default = "nixos-amazon-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}";
|
|
||||||
};
|
|
||||||
|
|
||||||
contents = mkOption {
|
contents = mkOption {
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
[ { source = pkgs.memtest86 + "/memtest.bin";
|
[ { source = pkgs.memtest86 + "/memtest.bin";
|
||||||
|
@ -80,6 +86,10 @@ in
|
||||||
config.virtualisation.diskSize = lib.mkOverride 1490 (3 * 1024);
|
config.virtualisation.diskSize = lib.mkOverride 1490 (3 * 1024);
|
||||||
config.virtualisation.diskSizeAutoSupported = !config.ec2.zfs.enable;
|
config.virtualisation.diskSizeAutoSupported = !config.ec2.zfs.enable;
|
||||||
|
|
||||||
|
config.system.nixos.tags = [ "amazon" ];
|
||||||
|
config.system.build.image = config.system.build.amazonImage;
|
||||||
|
config.image.extension = cfg.format;
|
||||||
|
|
||||||
config.system.build.amazonImage =
|
config.system.build.amazonImage =
|
||||||
let
|
let
|
||||||
configFile = pkgs.writeText "configuration.nix" ''
|
configFile = pkgs.writeText "configuration.nix" ''
|
||||||
|
@ -102,7 +112,8 @@ in
|
||||||
configFile
|
configFile
|
||||||
pkgs
|
pkgs
|
||||||
;
|
;
|
||||||
inherit (cfg) contents format name;
|
inherit (cfg) contents format;
|
||||||
|
name = config.image.baseName;
|
||||||
|
|
||||||
includeChannel = true;
|
includeChannel = true;
|
||||||
|
|
||||||
|
@ -118,7 +129,7 @@ in
|
||||||
|
|
||||||
postVM = ''
|
postVM = ''
|
||||||
extension=''${rootDiskImage##*.}
|
extension=''${rootDiskImage##*.}
|
||||||
friendlyName=$out/${cfg.name}
|
friendlyName=$out/${config.image.baseName}
|
||||||
rootDisk="$friendlyName.root.$extension"
|
rootDisk="$friendlyName.root.$extension"
|
||||||
bootDisk="$friendlyName.boot.$extension"
|
bootDisk="$friendlyName.boot.$extension"
|
||||||
mv "$rootDiskImage" "$rootDisk"
|
mv "$rootDiskImage" "$rootDisk"
|
||||||
|
@ -156,7 +167,9 @@ in
|
||||||
pkgs
|
pkgs
|
||||||
;
|
;
|
||||||
|
|
||||||
inherit (cfg) contents format name;
|
inherit (cfg) contents format;
|
||||||
|
inherit (config.image) baseName;
|
||||||
|
name = config.image.baseName;
|
||||||
|
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
partitionTableType = if config.ec2.efi then "efi" else "legacy+gpt";
|
partitionTableType = if config.ec2.efi then "efi" else "legacy+gpt";
|
||||||
|
@ -164,11 +177,6 @@ in
|
||||||
inherit (config.virtualisation) diskSize;
|
inherit (config.virtualisation) diskSize;
|
||||||
|
|
||||||
postVM = ''
|
postVM = ''
|
||||||
extension=''${diskImage##*.}
|
|
||||||
friendlyName=$out/${cfg.name}.$extension
|
|
||||||
mv "$diskImage" "$friendlyName"
|
|
||||||
diskImage=$friendlyName
|
|
||||||
|
|
||||||
mkdir -p $out/nix-support
|
mkdir -p $out/nix-support
|
||||||
echo "file ${cfg.format} $diskImage" >> $out/nix-support/hydra-build-products
|
echo "file ${cfg.format} $diskImage" >> $out/nix-support/hydra-build-products
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ let
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}).config;
|
}).config;
|
||||||
image = "${imageCfg.system.build.amazonImage}/${imageCfg.amazonImage.name}.qcow2";
|
image = "${imageCfg.system.build.amazonImage}/${imageCfg.image.imageFile}";
|
||||||
|
|
||||||
sshKeys = import ./ssh-keys.nix pkgs;
|
sshKeys = import ./ssh-keys.nix pkgs;
|
||||||
snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;
|
snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue