Skip to content

Commit

Permalink
nixos: xen: make packages configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
oxij committed Mar 5, 2017
1 parent 916fa0a commit 442b8d4
Showing 1 changed file with 48 additions and 18 deletions.
66 changes: 48 additions & 18 deletions nixos/modules/virtualisation/xen-dom0.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ in
'';
};

virtualisation.xen.package = mkOption {
type = types.package;
default = pkgs.xen;
defaultText = "pkgs.xen";
example = literalExample "pkgs.xen-light";
description = ''
The package used for Xen binary.
'';
};

virtualisation.xen.qemu = mkOption {
type = types.path;
default = "${pkgs.xen}/lib/xen/bin/qemu-system-i386";
defaultText = "''${pkgs.xen}/lib/xen/bin/qemu-system-i386";
example = literalExample "''${pkgs.qemu_xen-light}/bin/qemu-system-i386";
description = ''
The qemu binary to use for Dom-0 backend.
'';
};

virtualisation.xen.qemu-package = mkOption {
type = types.package;
default = pkgs.xen;
defaultText = "pkgs.xen";
example = literalExample "pkgs.qemu_xen-light";
description = ''
The package with qemu binaries for xendomains.
'';
};

virtualisation.xen.bootParams =
mkOption {
default = "";
Expand Down Expand Up @@ -106,9 +136,9 @@ in
message = "Xen currently does not support EFI boot";
} ];

virtualisation.xen.stored = mkDefault "${pkgs.xen}/bin/oxenstored";
virtualisation.xen.stored = mkDefault "${cfg.package}/bin/oxenstored";

environment.systemPackages = [ pkgs.xen ];
environment.systemPackages = [ cfg.package ];

# Make sure Domain 0 gets the required configuration
#boot.kernelPackages = pkgs.boot.kernelPackages.override { features={xen_dom0=true;}; };
Expand Down Expand Up @@ -144,7 +174,7 @@ in

system.extraSystemBuilderCmds =
''
ln -s ${pkgs.xen}/boot/xen.gz $out/xen.gz
ln -s ${cfg.package}/boot/xen.gz $out/xen.gz
echo "${toString cfg.bootParams}" > $out/xen-params
'';

Expand Down Expand Up @@ -180,19 +210,19 @@ in


environment.etc =
[ { source = "${pkgs.xen}/etc/xen/xl.conf";
[ { source = "${cfg.package}/etc/xen/xl.conf";
target = "xen/xl.conf";
}
{ source = "${pkgs.xen}/etc/xen/scripts";
{ source = "${cfg.package}/etc/xen/scripts";
target = "xen/scripts";
}
{ source = "${pkgs.xen}/etc/default/xendomains";
{ source = "${cfg.package}/etc/default/xendomains";
target = "default/xendomains";
}
];

# Xen provides udev rules.
services.udev.packages = [ pkgs.xen ];
services.udev.packages = [ cfg.package ];

services.udev.path = [ pkgs.bridge-utils pkgs.iproute ];

Expand All @@ -217,7 +247,7 @@ in
time=0
timeout=30
# Wait for xenstored to actually come up, timing out after 30 seconds
while [ $time -lt $timeout ] && ! `${pkgs.xen}/bin/xenstore-read -s / >/dev/null 2>&1` ; do
while [ $time -lt $timeout ] && ! `${cfg.package}/bin/xenstore-read -s / >/dev/null 2>&1` ; do
time=$(($time+1))
sleep 1
done
Expand All @@ -228,8 +258,8 @@ in
exit 1
fi
${pkgs.xen}/bin/xenstore-write "/local/domain/0/name" "Domain-0"
${pkgs.xen}/bin/xenstore-write "/local/domain/0/domid" 0
${cfg.package}/bin/xenstore-write "/local/domain/0/name" "Domain-0"
${cfg.package}/bin/xenstore-write "/local/domain/0/domid" 0
'';
};

Expand All @@ -256,7 +286,7 @@ in
'';
serviceConfig = {
ExecStart = ''
${pkgs.xen}/bin/xenconsoled${optionalString cfg.trace " --log=all --log-dir=/var/log/xen"}
${cfg.package}/bin/xenconsoled${optionalString cfg.trace " --log=all --log-dir=/var/log/xen"}
'';
};
};
Expand All @@ -267,8 +297,8 @@ in
wantedBy = [ "multi-user.target" ];
after = [ "xen-console.service" ];
serviceConfig.ExecStart = ''
${pkgs.xen}/lib/xen/bin/qemu-system-i386 -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv \
-monitor /dev/null -serial /dev/null -parallel /dev/null
${cfg.qemu} -xen-attach -xen-domid 0 -name dom0 -M xenpv \
-nographic -monitor /dev/null -serial /dev/null -parallel /dev/null
'';
};

Expand All @@ -277,7 +307,7 @@ in
description = "Xen Watchdog Daemon";
wantedBy = [ "multi-user.target" ];
after = [ "xen-qemu.service" ];
serviceConfig.ExecStart = "${pkgs.xen}/bin/xenwatchdogd 30 15";
serviceConfig.ExecStart = "${cfg.package}/bin/xenwatchdogd 30 15";
serviceConfig.Type = "forking";
serviceConfig.RestartSec = "1";
serviceConfig.Restart = "on-failure";
Expand Down Expand Up @@ -366,11 +396,11 @@ in
before = [ "dhcpd.service" ];
restartIfChanged = false;
serviceConfig.RemainAfterExit = "yes";
path = [ pkgs.xen ];
environment.XENDOM_CONFIG = "${pkgs.xen}/etc/sysconfig/xendomains";
path = [ cfg.package cfg.qemu-package ];
environment.XENDOM_CONFIG = "${cfg.package}/etc/sysconfig/xendomains";
preStart = "mkdir -p /var/lock/subsys -m 755";
serviceConfig.ExecStart = "${pkgs.xen}/etc/init.d/xendomains start";
serviceConfig.ExecStop = "${pkgs.xen}/etc/init.d/xendomains stop";
serviceConfig.ExecStart = "${cfg.package}/etc/init.d/xendomains start";
serviceConfig.ExecStop = "${cfg.package}/etc/init.d/xendomains stop";
};

};
Expand Down

0 comments on commit 442b8d4

Please sign in to comment.