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