at 23.11-pre 1.8 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.virtualisation.hypervGuest; 7 8in { 9 options = { 10 virtualisation.hypervGuest = { 11 enable = mkEnableOption (lib.mdDoc "Hyper-V Guest Support"); 12 13 videoMode = mkOption { 14 type = types.str; 15 default = "1152x864"; 16 example = "1024x768"; 17 description = lib.mdDoc '' 18 Resolution at which to initialize the video adapter. 19 20 Supports screen resolution up to Full HD 1920x1080 with 32 bit color 21 on Windows Server 2012, and 1600x1200 with 16 bit color on Windows 22 Server 2008 R2 or earlier. 23 ''; 24 }; 25 }; 26 }; 27 28 config = mkIf cfg.enable { 29 boot = { 30 initrd.kernelModules = [ 31 "hv_balloon" "hv_netvsc" "hv_storvsc" "hv_utils" "hv_vmbus" 32 ]; 33 34 initrd.availableKernelModules = [ "hyperv_keyboard" ]; 35 36 kernelParams = [ 37 "video=hyperv_fb:${cfg.videoMode}" "elevator=noop" 38 ]; 39 }; 40 41 environment.systemPackages = [ config.boot.kernelPackages.hyperv-daemons.bin ]; 42 43 # enable hotadding cpu/memory 44 services.udev.packages = lib.singleton (pkgs.writeTextFile { 45 name = "hyperv-cpu-and-memory-hotadd-udev-rules"; 46 destination = "/etc/udev/rules.d/99-hyperv-cpu-and-memory-hotadd.rules"; 47 text = '' 48 # Memory hotadd 49 SUBSYSTEM=="memory", ACTION=="add", DEVPATH=="/devices/system/memory/memory[0-9]*", TEST=="state", ATTR{state}="online" 50 51 # CPU hotadd 52 SUBSYSTEM=="cpu", ACTION=="add", DEVPATH=="/devices/system/cpu/cpu[0-9]*", TEST=="online", ATTR{online}="1" 53 ''; 54 }); 55 56 systemd = { 57 packages = [ config.boot.kernelPackages.hyperv-daemons.lib ]; 58 59 targets.hyperv-daemons = { 60 wantedBy = [ "multi-user.target" ]; 61 }; 62 }; 63 }; 64}