1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.xe-guest-utilities;
9in
10{
11 options = {
12 services.xe-guest-utilities = {
13 enable = lib.mkEnableOption "the XenServer guest utilities daemon";
14 };
15 };
16 config = lib.mkIf cfg.enable {
17 services.udev.packages = [ pkgs.xe-guest-utilities ];
18 systemd.tmpfiles.rules = [ "d /run/xenstored 0755 - - -" ];
19
20 systemd.services.xe-daemon = {
21 description = "xen daemon file";
22 wantedBy = [ "multi-user.target" ];
23 after = [ "xe-linux-distribution.service" ];
24 requires = [ "proc-xen.mount" ];
25 path = [
26 pkgs.coreutils
27 pkgs.iproute2
28 ];
29 serviceConfig = {
30 PIDFile = "/run/xe-daemon.pid";
31 ExecStart = "${pkgs.xe-guest-utilities}/bin/xe-daemon -p /run/xe-daemon.pid";
32 ExecStop = "${pkgs.procps}/bin/pkill -TERM -F /run/xe-daemon.pid";
33 };
34 };
35
36 systemd.services.xe-linux-distribution = {
37 description = "xen linux distribution service";
38 wantedBy = [ "multi-user.target" ];
39 before = [ "xend.service" ];
40 path = [
41 pkgs.xe-guest-utilities
42 pkgs.coreutils
43 pkgs.gawk
44 pkgs.gnused
45 ];
46 serviceConfig = {
47 Type = "simple";
48 RemainAfterExit = "yes";
49 ExecStart = "${pkgs.xe-guest-utilities}/bin/xe-linux-distribution /var/cache/xe-linux-distribution";
50 };
51 };
52
53 systemd.mounts = [
54 {
55 description = "Mount /proc/xen files";
56 what = "xenfs";
57 where = "/proc/xen";
58 type = "xenfs";
59 unitConfig = {
60 ConditionPathExists = "/proc/xen";
61 RefuseManualStop = "true";
62 };
63 }
64 ];
65 };
66}