libvirt-guest: add autoStart option
This commit is contained in:
parent
64e35cb2f7
commit
4d6e3477d6
@ -35,6 +35,10 @@ let
|
|||||||
guestsOptions = { name, ... }: {
|
guestsOptions = { name, ... }: {
|
||||||
options = rec {
|
options = rec {
|
||||||
# TODO
|
# TODO
|
||||||
|
autoStart = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
guestOsType = mkOption {
|
guestOsType = mkOption {
|
||||||
type = types.enum [ "linux" "windows" ];
|
type = types.enum [ "linux" "windows" ];
|
||||||
default = "linux";
|
default = "linux";
|
||||||
@ -67,9 +71,14 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
devices = {
|
devices = {
|
||||||
disks = mkOption { type = with types; listOf (submodule diskOptions); };
|
disks = mkOption {
|
||||||
mounts =
|
type = with types; listOf (submodule diskOptions);
|
||||||
mkOption { type = with types; listOf (submodule mountOptions); };
|
default = [ ];
|
||||||
|
};
|
||||||
|
mounts = mkOption {
|
||||||
|
type = with types; listOf (submodule mountOptions);
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
tablet = mkOption {
|
tablet = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
@ -185,7 +194,7 @@ in {
|
|||||||
lib.nameValuePair "libvirtd-guest-${name}" {
|
lib.nameValuePair "libvirtd-guest-${name}" {
|
||||||
after = [ "libvirtd.service" ];
|
after = [ "libvirtd.service" ];
|
||||||
requires = [ "libvirtd.service" ];
|
requires = [ "libvirtd.service" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = lib.mkIf guest.autoStart [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = "yes";
|
RemainAfterExit = "yes";
|
||||||
@ -245,7 +254,9 @@ in {
|
|||||||
''
|
''
|
||||||
}
|
}
|
||||||
</cpu>
|
</cpu>
|
||||||
<clock offset="utc">
|
<clock offset="${
|
||||||
|
if guest.guestOsType == "windows" then "localtime" else "utc"
|
||||||
|
}">
|
||||||
<timer name="rtc" tickpolicy="catchup"/>
|
<timer name="rtc" tickpolicy="catchup"/>
|
||||||
<timer name="pit" tickpolicy="delay"/>
|
<timer name="pit" tickpolicy="delay"/>
|
||||||
<timer name="hpet" present="no"/>
|
<timer name="hpet" present="no"/>
|
||||||
@ -384,7 +395,7 @@ in {
|
|||||||
${pkgs.libvirt}/bin/virsh define <(sed "s/UUID/$uuid/" '${xml}')
|
${pkgs.libvirt}/bin/virsh define <(sed "s/UUID/$uuid/" '${xml}')
|
||||||
${lib.optionalString
|
${lib.optionalString
|
||||||
(guest.devices.network.interfaceType == "network")
|
(guest.devices.network.interfaceType == "network")
|
||||||
"${pkgs.libvirt}/bin/virsh net-start ${guest.devices.network.sourceDev}"}
|
"${pkgs.libvirt}/bin/virsh net-start ${guest.devices.network.sourceDev} || true"}
|
||||||
${pkgs.libvirt}/bin/virsh start '${name}'
|
${pkgs.libvirt}/bin/virsh start '${name}'
|
||||||
'';
|
'';
|
||||||
preStop = ''
|
preStop = ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user