diff --git a/nixos/maintainers/scripts/ec2/amazon-image.nix b/nixos/maintainers/scripts/ec2/amazon-image.nix index 9ce667a30995..e117b1d28d52 100644 --- a/nixos/maintainers/scripts/ec2/amazon-image.nix +++ b/nixos/maintainers/scripts/ec2/amazon-image.nix @@ -11,7 +11,6 @@ let mkOption optionalString types - versionAtLeast ; inherit (lib.options) literalExpression; cfg = config.amazonImage; @@ -46,16 +45,6 @@ in }) ]; - # Amazon recommends setting this to the highest possible value for a good EBS - # experience, which prior to 4.15 was 255. - # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html#timeout-nvme-ebs-volumes - config.boot.kernelParams = - let - timeout = - if versionAtLeast config.boot.kernelPackages.kernel.version "4.15" then "4294967295" else "255"; - in - [ "nvme_core.io_timeout=${timeout}" ]; - options.amazonImage = { contents = mkOption { example = literalExpression '' diff --git a/nixos/modules/virtualisation/amazon-image.nix b/nixos/modules/virtualisation/amazon-image.nix index 1e267bfdad95..640c81cff474 100644 --- a/nixos/modules/virtualisation/amazon-image.nix +++ b/nixos/modules/virtualisation/amazon-image.nix @@ -59,10 +59,19 @@ in ]; boot.initrd.kernelModules = [ "xen-blkfront" ]; boot.initrd.availableKernelModules = [ "nvme" ]; - boot.kernelParams = [ - "console=ttyS0,115200n8" - "random.trust_cpu=on" - ]; + boot.kernelParams = + let + # Amazon recommends setting this to the highest possible value for a good EBS + # experience, which prior to 4.15 was 255. + # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html#timeout-nvme-ebs-volumes + nvmeTimeout = + if lib.versionAtLeast config.boot.kernelPackages.kernel.version "4.15" then "4294967295" else "255"; + in + [ + "console=ttyS0,115200n8" + "random.trust_cpu=on" + "nvme_core.io_timeout=${nvmeTimeout}" + ]; # Prevent the nouveau kernel module from being loaded, as it # interferes with the nvidia/nvidia-uvm modules needed for CUDA.