summary refs log tree commit diff
path: root/nixos/modules/virtualisation/xe-guest-utilities.nix
blob: 25ccbaebc0772ff6b49024038fb62e12dee9ec2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{ config, lib, pkgs, ... }:
with lib;
let
  cfg = config.services.xe-guest-utilities;
in {
  options = {
    services.xe-guest-utilities = {
      enable = mkEnableOption "the Xen guest utilities daemon";
    };
  };
  config = mkIf cfg.enable {
    services.udev.packages = [ pkgs.xe-guest-utilities ];
    systemd.tmpfiles.rules = [ "d /run/xenstored 0755 - - -" ];

    systemd.services.xe-daemon = {
      description = "xen daemon file";
      wantedBy    = [ "multi-user.target" ];
      after = [ "xe-linux-distribution.service" ];
      requires = [ "proc-xen.mount" ];
      path = [ pkgs.coreutils pkgs.iproute2 ];
      serviceConfig = {
        PIDFile = "/run/xe-daemon.pid";
        ExecStart = "${pkgs.xe-guest-utilities}/bin/xe-daemon -p /run/xe-daemon.pid";
        ExecStop = "${pkgs.procps}/bin/pkill -TERM -F /run/xe-daemon.pid";
      };
    };

    systemd.services.xe-linux-distribution = {
      description = "xen linux distribution service";
      wantedBy    = [ "multi-user.target" ];
      before = [ "xend.service" ];
      path = [ pkgs.xe-guest-utilities pkgs.coreutils pkgs.gawk pkgs.gnused ];
      serviceConfig = {
        Type = "simple";
        RemainAfterExit = "yes";
        ExecStart = "${pkgs.xe-guest-utilities}/bin/xe-linux-distribution /var/cache/xe-linux-distribution";
      };
    };

    systemd.mounts = [
      { description = "Mount /proc/xen files";
        what = "xenfs";
        where = "/proc/xen";
        type = "xenfs";
        unitConfig = {
          ConditionPathExists = "/proc/xen";
          RefuseManualStop = "true";
        };
      }
    ];
  };
}