From 85e507ebeaa1958d04335c38ded126093a1fb409 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Fri, 7 Apr 2017 17:40:17 +0800 Subject: [PATCH] hyperv-daemons: add nixos module --- nixos/modules/module-list.nix | 1 + nixos/modules/virtualisation/hyperv-guest.nix | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 nixos/modules/virtualisation/hyperv-guest.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index f32fb50368e3..93ba90bdc5d8 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -746,6 +746,7 @@ ./virtualisation/lxcfs.nix ./virtualisation/lxd.nix ./virtualisation/amazon-options.nix + ./virtualisation/hyperv-guest.nix ./virtualisation/openvswitch.nix ./virtualisation/parallels-guest.nix ./virtualisation/rkt.nix diff --git a/nixos/modules/virtualisation/hyperv-guest.nix b/nixos/modules/virtualisation/hyperv-guest.nix new file mode 100644 index 000000000000..ecd2a8117710 --- /dev/null +++ b/nixos/modules/virtualisation/hyperv-guest.nix @@ -0,0 +1,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" ]; + }; + }; + }; +}