nixpkgs/nixos/modules/virtualisation/hyperv-guest.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
1.6 KiB
Nix
Raw Normal View History

2017-04-07 17:40:17 +08:00
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.virtualisation.hypervGuest;
in
{
imports = [
(mkRemovedOptionModule [
"virtualisation"
"hypervGuest"
"videoMode"
] "The video mode can now be configured via standard tools, or in Hyper-V VM settings.")
];
2017-04-07 17:40:17 +08:00
options = {
virtualisation.hypervGuest = {
enable = mkEnableOption "Hyper-V Guest Support";
};
};
config = mkIf cfg.enable {
boot = {
initrd.kernelModules = [
"hv_balloon"
"hv_netvsc"
"hv_storvsc"
"hv_utils"
"hv_vmbus"
];
initrd.availableKernelModules = [ "hyperv_keyboard" ];
kernelParams = [
"elevator=noop"
];
};
2017-04-07 17:40:17 +08:00
environment.systemPackages = [ config.boot.kernelPackages.hyperv-daemons.bin ];
2018-09-28 22:27:52 +08:00
# enable hotadding cpu/memory
2017-04-07 17:40:17 +08:00
services.udev.packages = lib.singleton (
pkgs.writeTextFile {
2018-09-28 22:27:52 +08:00
name = "hyperv-cpu-and-memory-hotadd-udev-rules";
destination = "/etc/udev/rules.d/99-hyperv-cpu-and-memory-hotadd.rules";
2017-04-07 17:40:17 +08:00
text = ''
2018-09-28 22:27:52 +08:00
# Memory hotadd
SUBSYSTEM=="memory", ACTION=="add", DEVPATH=="/devices/system/memory/memory[0-9]*", TEST=="state", ATTR{state}="online"
2018-09-28 22:27:52 +08:00
# CPU hotadd
SUBSYSTEM=="cpu", ACTION=="add", DEVPATH=="/devices/system/cpu/cpu[0-9]*", TEST=="online", ATTR{online}="1"
2017-04-07 17:40:17 +08:00
'';
}
);
systemd = {
packages = [ config.boot.kernelPackages.hyperv-daemons.lib ];
targets.hyperv-daemons = {
wantedBy = [ "multi-user.target" ];
};
};
};
}