at 25.11-pre 967 B view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8with lib; 9 10let 11 cfg = config.services.qemuGuest; 12in 13{ 14 15 options.services.qemuGuest = { 16 enable = mkOption { 17 type = types.bool; 18 default = false; 19 description = "Whether to enable the qemu guest agent."; 20 }; 21 package = mkPackageOption pkgs [ "qemu_kvm" "ga" ] { }; 22 }; 23 24 config = mkIf cfg.enable (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}