Commit 34b62f7c authored by Fabián Heredia Montiel's avatar Fabián Heredia Montiel
Browse files

Merge remote-tracking branch 'origin/master' into staging-next

parents cae0fd41 e52c5b67
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -192,3 +192,11 @@ ce21e97a1f20dee15da85c084f9d1148d84f853b

# percona: apply nixfmt
8d14fa2886fec877690c6d28cfcdba4503dbbcea

# nixos/virtualisation: format image-related files
# Original formatting commit that was reverted
04fadac429ca7d6b92025188652376c230205730
# Revert commit
4cec81a9959ce612b653860dcca53101a36f328a
# Final commit that does the formatting
88b285c01d84de82c0b2b052fd28eaf6709c2d26
+5 −0
Original line number Diff line number Diff line
@@ -942,6 +942,11 @@ lib.mapAttrs mkLicense ({
    url = "https://license.coscl.org.cn/MulanPSL2";
  };

  naist-2003 = {
    spdxId = "NAIST-2003";
    fullName = "Nara Institute of Science and Technology License (2003)";
  };

  nasa13 = {
    spdxId = "NASA-1.3";
    fullName = "NASA Open Source Agreement 1.3";
+35 −7
Original line number Diff line number Diff line
@@ -743,6 +743,11 @@
    githubId = 37664775;
    name = "Yuto Oguchi";
  };
  airrnot = {
    name = "airRnot";
    github = "airRnot1106";
    githubId = 62370527;
  };
  airwoodix = {
    email = "airwoodix@posteo.me";
    github = "airwoodix";
@@ -5871,7 +5876,10 @@
    github = "jollheef";
    githubId = 1749762;
    name = "Mikhail Klementev";
    keys = [ { fingerprint = "5DD7 C6F6 0630 F08E DAE7  4711 1525 585D 1B43 C62A"; } ];
    keys = [
      { fingerprint = "5AC8 C9A1 68C7 9451 1A91  2295 C990 5BA7 2B5E 02BB"; }
      { fingerprint = "5DD7 C6F6 0630 F08E DAE7  4711 1525 585D 1B43 C62A"; }
    ];
  };
  dunxen = {
    email = "git@dunxen.dev";
@@ -10507,6 +10515,13 @@
    githubId = 168684553;
    name = "João Marques";
  };
  joinemm = {
    email = "joonas@rautiola.co";
    github = "joinemm";
    githubId = 26210439;
    name = "Joonas Rautiola";
    keys = [ { fingerprint = "87EC DD30 6614 E510 5299  F0D4 090E B48A 4669 AA54"; } ];
  };
  jojosch = {
    name = "Johannes Schleifenbaum";
    email = "johannes@js-webcoding.de";
@@ -12396,6 +12411,13 @@
    githubId = 169170;
    name = "Mathias Schreck";
  };
  loc = {
    matrix = "@loc:locrealloc.de";
    github = "LoCrealloc";
    githubId = 64095253;
    name = "LoC";
    keys = [ { fingerprint = "DCCE F73B 209A 6024 CAE7  F926 5563 EB4A 8634 4F15"; } ];
  };
  locallycompact = {
    email = "dan.firth@homotopic.tech";
    github = "locallycompact";
@@ -14822,6 +14844,11 @@
    githubId = 96225281;
    name = "Mustafa Çalışkan";
  };
  musjj = {
    name = "musjj";
    github = "musjj";
    githubId = 72612857;
  };
  mvisonneau = {
    name = "Maxime VISONNEAU";
    email = "maxime@visonneau.fr";
@@ -23135,6 +23162,13 @@
    githubId = 1215623;
    keys = [ { fingerprint = "DA03 D6C6 3F58 E796 AD26  E99B 366A 2940 479A 06FC"; } ];
  };
  wilhelmines = {
    email = "mail@aesz.org";
    matrix = "@wilhelmines:matrix.org";
    name = "Ronja Schwarz";
    github = "wilhelmines";
    githubId = 71409721;
  };
  willbush = {
    email = "git@willbush.dev";
    matrix = "@willbush:matrix.org";
@@ -24248,12 +24282,6 @@
    githubId = 71881325;
    name = "Stefan Bordei";
  };
  zzamboni = {
    email = "diego@zzamboni.org";
    github = "zzamboni";
    githubId = 32876;
    name = "Diego Zamboni";
  };
  zzzsy = {
    email = "me@zzzsy.top";
    github = "zzzsyyy";
+142 −106
Original line number Diff line number Diff line
{ config, lib, pkgs, ... }:
{
  config,
  lib,
  pkgs,
  ...
}:

let
  inherit (lib) mkOption optionalString types versionAtLeast;
  inherit (lib)
    mkOption
    optionalString
    types
    versionAtLeast
    ;
  inherit (lib.options) literalExpression;
  cfg = config.amazonImage;
  amiBootMode = if config.ec2.efi then "uefi" else "legacy-bios";

in {

  imports = [ ../../../modules/virtualisation/amazon-image.nix ];
in
{
  imports = [
    ../../../modules/virtualisation/amazon-image.nix
    ../../../modules/virtualisation/disk-size-option.nix
    (lib.mkRenamedOptionModuleWith {
      sinceRelease = 2411;
      from = [
        "amazonImage"
        "sizeMB"
      ];
      to = [
        "virtualisation"
        "diskSize"
      ];
    })
  ];

  # 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}" ];
    let
      timeout =
        if versionAtLeast config.boot.kernelPackages.kernel.version "4.15" then "4294967295" else "255";
    in
    [ "nvme_core.io_timeout=${timeout}" ];

  options.amazonImage = {
    name = mkOption {
@@ -41,23 +64,25 @@ in {
      '';
    };

    sizeMB = mkOption {
      type = with types; either (enum [ "auto" ]) int;
      default = 3072;
      example = 8192;
      description = "The size in MB of the image";
    };

    format = mkOption {
      type = types.enum [ "raw" "qcow2" "vpc" ];
      type = types.enum [
        "raw"
        "qcow2"
        "vpc"
      ];
      default = "vpc";
      description = "The image format to output";
    };
  };

  config.system.build.amazonImage = let
    configFile = pkgs.writeText "configuration.nix"
      ''
  # Use a priority just below mkOptionDefault (1500) instead of lib.mkDefault
  # to avoid breaking existing configs using that.
  config.virtualisation.diskSize = lib.mkOverride 1490 (3 * 1024);
  config.virtualisation.diskSizeAutoSupported = !config.ec2.zfs.enable;

  config.system.build.amazonImage =
    let
      configFile = pkgs.writeText "configuration.nix" ''
        { modulesPath, ... }: {
          imports = [ "''${modulesPath}/virtualisation/amazon-image.nix" ];
          ${optionalString config.ec2.efi ''
@@ -71,14 +96,19 @@ in {
      '';

      zfsBuilder = import ../../../lib/make-multi-disk-zfs-image.nix {
      inherit lib config configFile pkgs;
        inherit
          lib
          config
          configFile
          pkgs
          ;
        inherit (cfg) contents format name;

        includeChannel = true;

        bootSize = 1000; # 1G is the minimum EBS volume

      rootSize = cfg.sizeMB;
        rootSize = config.virtualisation.diskSize;
        rootPoolProperties = {
          ashift = 12;
          autoexpand = "on";
@@ -119,14 +149,19 @@ in {
      };

      extBuilder = import ../../../lib/make-disk-image.nix {
      inherit lib config configFile pkgs;
        inherit
          lib
          config
          configFile
          pkgs
          ;

        inherit (cfg) contents format name;

        fsType = "ext4";
        partitionTableType = if config.ec2.efi then "efi" else "legacy+gpt";

      diskSize = cfg.sizeMB;
        inherit (config.virtualisation) diskSize;

        postVM = ''
           extension=''${diskImage##*.}
@@ -154,7 +189,8 @@ in {
             ' > $out/nix-support/image-info.json
        '';
      };
  in if config.ec2.zfs.enable then zfsBuilder else extBuilder;
    in
    if config.ec2.zfs.enable then zfsBuilder else extBuilder;

  meta.maintainers = with lib.maintainers; [ arianvp ];
}
+35 −18
Original line number Diff line number Diff line
# nix-build '<nixpkgs/nixos>' -A config.system.build.openstackImage --arg configuration "{ imports = [ ./nixos/maintainers/scripts/openstack/openstack-image.nix ]; }"

{ config, lib, pkgs, ... }:
{
  config,
  lib,
  pkgs,
  ...
}:
let
  inherit (lib) mkOption types;
  copyChannel = true;
@@ -10,9 +15,20 @@ in
{
  imports = [
    ../../../modules/virtualisation/openstack-config.nix
    ../../../modules/virtualisation/disk-size-option.nix
    (lib.mkRenamedOptionModuleWith {
      sinceRelease = 2411;
      from = [
        "openstackImage"
        "sizeMB"
      ];
      to = [
        "virtualisation"
        "diskSize"
      ];
    })
  ] ++ (lib.optional copyChannel ../../../modules/installer/cd-dvd/channel.nix);


  options.openstackImage = {
    name = mkOption {
      type = types.str;
@@ -22,18 +38,15 @@ in

    ramMB = mkOption {
      type = types.int;
      default = 1024;
      default = (3 * 1024);
      description = "RAM allocation for build VM";
    };

    sizeMB = mkOption {
      type = types.int;
      default = 8192;
      description = "The size in MB of the image";
    };

    format = mkOption {
      type = types.enum [ "raw" "qcow2" ];
      type = types.enum [
        "raw"
        "qcow2"
      ];
      default = "qcow2";
      description = "The image format to output";
    };
@@ -54,13 +67,17 @@ in
      };
    };

    # Use a priority just below mkOptionDefault (1500) instead of lib.mkDefault
    # to avoid breaking existing configs using that.
    virtualisation.diskSize = lib.mkOverride 1490 (8 * 1024);
    virtualisation.diskSizeAutoSupported = false;

    system.build.openstackImage = import ../../../lib/make-single-disk-zfs-image.nix {
      inherit lib config;
      inherit (cfg) contents format name;
      pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package

      configFile = pkgs.writeText "configuration.nix"
        ''
      configFile = pkgs.writeText "configuration.nix" ''
        { modulesPath, ... }: {
          imports = [ "''${modulesPath}/virtualisation/openstack-config.nix" ];
          openstack.zfs.enable = true;
@@ -71,7 +88,7 @@ in

      bootSize = 1000;
      memSize = cfg.ramMB;
      rootSize = cfg.sizeMB;
      rootSize = config.virtualisation.diskSize;
      rootPoolProperties = {
        ashift = 12;
        autoexpand = "on";
Loading