summary refs log tree commit diff
path: root/nixos/modules/virtualisation/hyperv-guest.nix
blob: ecd2a8117710fea7a2b9370434b59a0dc8fbacc3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.virtualisation.hypervGuest;

in {
  options = {
    virtualisation.hypervGuest = {
      enable = mkEnableOption "Hyper-V Guest Support";
    };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = [ config.boot.kernelPackages.hyperv-daemons.bin ];

    security.rngd.enable = false;

    # enable hotadding memory
    services.udev.packages = lib.singleton (pkgs.writeTextFile {
      name = "hyperv-memory-hotadd-udev-rules";
      destination = "/etc/udev/rules.d/99-hyperv-memory-hotadd.rules";
      text = ''
        ACTION="add", SUBSYSTEM=="memory", ATTR{state}="online"
      '';
    });

    systemd = {
      packages = [ config.boot.kernelPackages.hyperv-daemons.lib ];

      targets.hyperv-daemons = {
        wantedBy = [ "multi-user.target" ];
      };
    };
  };
}