summary refs log tree commit diff
path: root/nixos/modules/virtualisation/spice-usb-redirection.nix
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2020-09-12 09:10:06 +0200
committerLinus Heckemann <git@sphalerite.org>2020-09-12 09:16:31 +0200
commite2fd022d633127cf9349333ad40e507387a859bf (patch)
tree4d5088f3b1ada3be9f7adb2646505d8f53e83c47 /nixos/modules/virtualisation/spice-usb-redirection.nix
parent61525137fd1002f6f2a5eb0ea27d480713362cd5 (diff)
nixos/spice-usb-redirection: init
Fixes #39618
Diffstat (limited to 'nixos/modules/virtualisation/spice-usb-redirection.nix')
-rw-r--r--nixos/modules/virtualisation/spice-usb-redirection.nix21
1 files changed, 21 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/spice-usb-redirection.nix b/nixos/modules/virtualisation/spice-usb-redirection.nix
new file mode 100644
index 0000000000000..39bfa0e6047bf
--- /dev/null
+++ b/nixos/modules/virtualisation/spice-usb-redirection.nix
@@ -0,0 +1,21 @@
+{ config, pkgs, lib, ... }:
+{
+  options.virtualisation.spiceUSBRedirection.enable = lib.mkOption {
+    type = lib.types.bool;
+    default = false;
+    description = ''
+      Install the SPICE USB redirection helper with setuid
+      privileges. This allows unprivileged users to pass USB devices
+      connected to this machine to libvirt VMs, both local and
+      remote. Note that this allows users arbitrary access to USB
+      devices.
+    '';
+  };
+
+  config = lib.mkIf config.virtualisation.spiceUSBRedirection.enable {
+    environment.systemPackages = [ pkgs.spice_gtk ];
+    security.wrappers.spice-client-glib-usb-acl-helper.source = "${pkgs.spice_gtk}/bin/spice-client-glib-usb-acl-helper";
+  };
+
+  meta.maintainers = [ lib.maintainers.lheckemann ];
+}