1 { config, lib, pkgs, ... }:
6 cfg = config.virtualisation.hypervGuest;
10 virtualisation.hypervGuest = {
11 enable = mkEnableOption "Hyper-V Guest Support";
13 videoMode = mkOption {
18 Resolution at which to initialize the video adapter.
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.
28 config = mkIf cfg.enable {
30 initrd.kernelModules = [
31 "hv_balloon" "hv_netvsc" "hv_storvsc" "hv_utils" "hv_vmbus"
34 initrd.availableKernelModules = [ "hyperv_keyboard" ];
37 "video=hyperv_fb:${cfg.videoMode}" "elevator=noop"
41 environment.systemPackages = [ config.boot.kernelPackages.hyperv-daemons.bin ];
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";
49 SUBSYSTEM=="memory", ACTION=="add", DEVPATH=="/devices/system/memory/memory[0-9]*", TEST=="state", ATTR{state}="online"
52 SUBSYSTEM=="cpu", ACTION=="add", DEVPATH=="/devices/system/cpu/cpu[0-9]*", TEST=="online", ATTR{online}="1"
57 packages = [ config.boot.kernelPackages.hyperv-daemons.lib ];
59 targets.hyperv-daemons = {
60 wantedBy = [ "multi-user.target" ];