about summary refs log tree commit diff
path: root/nixos/modules/virtualisation
diff options
context:
space:
mode:
authorPeter Hoeg <peter@hoeg.com>2017-04-07 17:40:17 +0800
committerPeter Hoeg <peter@hoeg.com>2018-01-04 21:09:01 +0800
commit85e507ebeaa1958d04335c38ded126093a1fb409 (patch)
tree09e76db77ee2e22a500f8660ab1b488b7f55d63e /nixos/modules/virtualisation
parentae20c22531d802f4acc45ab72b3dccb9b9205a3b (diff)
downloadnixlib-85e507ebeaa1958d04335c38ded126093a1fb409.tar
nixlib-85e507ebeaa1958d04335c38ded126093a1fb409.tar.gz
nixlib-85e507ebeaa1958d04335c38ded126093a1fb409.tar.bz2
nixlib-85e507ebeaa1958d04335c38ded126093a1fb409.tar.lz
nixlib-85e507ebeaa1958d04335c38ded126093a1fb409.tar.xz
nixlib-85e507ebeaa1958d04335c38ded126093a1fb409.tar.zst
nixlib-85e507ebeaa1958d04335c38ded126093a1fb409.zip
hyperv-daemons: add nixos module
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r--nixos/modules/virtualisation/hyperv-guest.nix37
1 files changed, 37 insertions, 0 deletions
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" ];
+      };
+    };
+  };
+}