at 23.11-pre 1.2 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.qemuGuest; 7in { 8 9 options.services.qemuGuest = { 10 enable = mkOption { 11 type = types.bool; 12 default = false; 13 description = lib.mdDoc "Whether to enable the qemu guest agent."; 14 }; 15 package = mkOption { 16 type = types.package; 17 default = pkgs.qemu_kvm.ga; 18 defaultText = literalExpression "pkgs.qemu_kvm.ga"; 19 description = lib.mdDoc "The QEMU guest agent package."; 20 }; 21 }; 22 23 config = mkIf cfg.enable ( 24 mkMerge [ 25 { 26 27 services.udev.extraRules = '' 28 SUBSYSTEM=="virtio-ports", ATTR{name}=="org.qemu.guest_agent.0", TAG+="systemd" ENV{SYSTEMD_WANTS}="qemu-guest-agent.service" 29 ''; 30 31 systemd.services.qemu-guest-agent = { 32 description = "Run the QEMU Guest Agent"; 33 serviceConfig = { 34 ExecStart = "${cfg.package}/bin/qemu-ga --statedir /run/qemu-ga"; 35 Restart = "always"; 36 RestartSec = 0; 37 # Runtime directory and mode 38 RuntimeDirectory = "qemu-ga"; 39 RuntimeDirectoryMode = "0755"; 40 }; 41 }; 42 } 43 ] 44 ); 45}