Commit f6fe3b3b authored by codgician's avatar codgician
Browse files

azure-common: add accelerated networking configs

parent 0799550a
Loading
Loading
Loading
Loading
+78 −57
Original line number Diff line number Diff line
{ lib, pkgs, ... }:

with lib;
let
  cfg = config.virtualisation.azure;
in
{
  options.virtualisation.azure = {
    acceleratedNetworking = mkOption {
      default = false;
      description = "Whether the machine's network interface has enabled accelerated networking.";
    };
  };

  imports = [ ../profiles/headless.nix ];

  require = [ ./azure-agent.nix ];

  config = let
    mlxDrivers = [ "mlx4_en" "mlx4_core" "mlx5_core" ];
  in
  {
    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.kernelModules = [ "hv_vmbus" "hv_netvsc" "hv_utils" "hv_storvsc" ] ++ (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";
    };

    # Generate a GRUB menu.
    boot.loader.grub.device = "/dev/sda";
@@ -63,5 +84,5 @@ with lib;
      ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:15", ATTR{removable}=="0", SYMLINK+="disk/by-lun/15"

    '';

  };
}