Loading nixos/modules/virtualisation/azure-agent.nix +3 −8 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ let ''; in { ###### interface Loading @@ -35,10 +34,6 @@ in config = lib.mkIf cfg.enable { assertions = [{ assertion = pkgs.stdenv.hostPlatform.isx86; message = "Azure not currently supported on ${pkgs.stdenv.hostPlatform.system}"; } { assertion = config.networking.networkmanager.enable == false; message = "Windows Azure Linux Agent is not compatible with NetworkManager"; }]; Loading nixos/modules/virtualisation/azure-common.nix +79 −61 Original line number Diff line number Diff line { lib, pkgs, ... }: { config, lib, pkgs, ... }: with lib; let cfg = config.virtualisation.azure; mlxDrivers = [ "mlx4_en" "mlx4_core" "mlx5_core" ]; in { imports = [ ../profiles/headless.nix ]; options.virtualisation.azure = { acceleratedNetworking = mkOption { default = false; description = "Whether the machine's network interface has enabled accelerated networking."; }; }; require = [ ./azure-agent.nix ]; imports = [ ../profiles/headless.nix ./azure-agent.nix ]; config = { virtualisation.azure.agent.enable = true; boot.kernelParams = [ "console=ttyS0" "earlyprintk=ttyS0" "rootdelay=300" "panic=1" "boot.panic_on_fail" ]; boot.initrd.kernelModules = [ "hv_vmbus" "hv_netvsc" "hv_utils" "hv_storvsc" ]; boot.initrd.availableKernelModules = lib.optionals cfg.acceleratedNetworking mlxDrivers; # Accelerated networking systemd.network.networks."99-azure-unmanaged-devices.network" = lib.mkIf cfg.acceleratedNetworking { matchConfig.Driver = mlxDrivers; linkConfig.Unmanaged = "yes"; }; networking.networkmanager.unmanaged = lib.mkIf cfg.acceleratedNetworking (builtins.map (drv: "driver:${drv}") mlxDrivers); # Generate a GRUB menu. boot.loader.grub.device = "/dev/sda"; boot.loader.timeout = 0; boot.growPartition = true; # Don't put old configurations in the GRUB menu. The user has no # way to select them anyway. boot.loader.grub.configurationLimit = 0; fileSystems."/" = { device = "/dev/disk/by-label/nixos"; fsType = "ext4"; Loading Loading @@ -63,5 +81,5 @@ with lib; ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:15", ATTR{removable}=="0", SYMLINK+="disk/by-lun/15" ''; }; } nixos/modules/virtualisation/azure-image.nix +27 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,8 @@ in { imports = [ ./azure-common.nix ]; options = { virtualisation.azureImage.diskSize = mkOption { options.virtualisation.azureImage = { diskSize = mkOption { type = with types; either (enum [ "auto" ]) int; default = "auto"; example = 2048; Loading @@ -16,14 +16,34 @@ in Size of disk image. Unit is MB. ''; }; virtualisation.azureImage.contents = mkOption { bootSize = mkOption { type = types.int; default = 256; description = '' ESP partition size. Unit is MB. Only effective when vmGeneration is `v2`. ''; }; contents = mkOption { type = with types; listOf attrs; default = [ ]; description = '' Extra contents to add to the image. ''; }; vmGeneration = mkOption { type = with types; enum [ "v1" "v2" ]; default = "v1"; description = '' VM Generation to use. For v2, secure boot needs to be turned off during creation. ''; }; }; config = { system.build.azureImage = import ../../lib/make-disk-image.nix { name = "azure-image"; Loading @@ -33,9 +53,12 @@ in ''; configFile = ./azure-config-user.nix; format = "raw"; bootSize = "${toString cfg.bootSize}M"; partitionTableType = if cfg.vmGeneration == "v2" then "efi" else "legacy"; inherit (cfg) diskSize contents; inherit config lib pkgs; }; }; } Loading
nixos/modules/virtualisation/azure-agent.nix +3 −8 Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ let ''; in { ###### interface Loading @@ -35,10 +34,6 @@ in config = lib.mkIf cfg.enable { assertions = [{ assertion = pkgs.stdenv.hostPlatform.isx86; message = "Azure not currently supported on ${pkgs.stdenv.hostPlatform.system}"; } { assertion = config.networking.networkmanager.enable == false; message = "Windows Azure Linux Agent is not compatible with NetworkManager"; }]; Loading
nixos/modules/virtualisation/azure-common.nix +79 −61 Original line number Diff line number Diff line { lib, pkgs, ... }: { config, lib, pkgs, ... }: with lib; let cfg = config.virtualisation.azure; mlxDrivers = [ "mlx4_en" "mlx4_core" "mlx5_core" ]; in { imports = [ ../profiles/headless.nix ]; options.virtualisation.azure = { acceleratedNetworking = mkOption { default = false; description = "Whether the machine's network interface has enabled accelerated networking."; }; }; require = [ ./azure-agent.nix ]; imports = [ ../profiles/headless.nix ./azure-agent.nix ]; config = { virtualisation.azure.agent.enable = true; boot.kernelParams = [ "console=ttyS0" "earlyprintk=ttyS0" "rootdelay=300" "panic=1" "boot.panic_on_fail" ]; boot.initrd.kernelModules = [ "hv_vmbus" "hv_netvsc" "hv_utils" "hv_storvsc" ]; boot.initrd.availableKernelModules = lib.optionals cfg.acceleratedNetworking mlxDrivers; # Accelerated networking systemd.network.networks."99-azure-unmanaged-devices.network" = lib.mkIf cfg.acceleratedNetworking { matchConfig.Driver = mlxDrivers; linkConfig.Unmanaged = "yes"; }; networking.networkmanager.unmanaged = lib.mkIf cfg.acceleratedNetworking (builtins.map (drv: "driver:${drv}") mlxDrivers); # Generate a GRUB menu. boot.loader.grub.device = "/dev/sda"; boot.loader.timeout = 0; boot.growPartition = true; # Don't put old configurations in the GRUB menu. The user has no # way to select them anyway. boot.loader.grub.configurationLimit = 0; fileSystems."/" = { device = "/dev/disk/by-label/nixos"; fsType = "ext4"; Loading Loading @@ -63,5 +81,5 @@ with lib; ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:15", ATTR{removable}=="0", SYMLINK+="disk/by-lun/15" ''; }; }
nixos/modules/virtualisation/azure-image.nix +27 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,8 @@ in { imports = [ ./azure-common.nix ]; options = { virtualisation.azureImage.diskSize = mkOption { options.virtualisation.azureImage = { diskSize = mkOption { type = with types; either (enum [ "auto" ]) int; default = "auto"; example = 2048; Loading @@ -16,14 +16,34 @@ in Size of disk image. Unit is MB. ''; }; virtualisation.azureImage.contents = mkOption { bootSize = mkOption { type = types.int; default = 256; description = '' ESP partition size. Unit is MB. Only effective when vmGeneration is `v2`. ''; }; contents = mkOption { type = with types; listOf attrs; default = [ ]; description = '' Extra contents to add to the image. ''; }; vmGeneration = mkOption { type = with types; enum [ "v1" "v2" ]; default = "v1"; description = '' VM Generation to use. For v2, secure boot needs to be turned off during creation. ''; }; }; config = { system.build.azureImage = import ../../lib/make-disk-image.nix { name = "azure-image"; Loading @@ -33,9 +53,12 @@ in ''; configFile = ./azure-config-user.nix; format = "raw"; bootSize = "${toString cfg.bootSize}M"; partitionTableType = if cfg.vmGeneration == "v2" then "efi" else "legacy"; inherit (cfg) diskSize contents; inherit config lib pkgs; }; }; }