mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-23 09:29:02 +08:00
整理休眠虚拟机的服务
This commit is contained in:
parent
e440a96dbf
commit
83b7fae8e9
@ -34,7 +34,7 @@ inputs:
|
||||
''
|
||||
if [ "$(LANG=C ${virsh} domstate $1)" = 'shut off' ] && [ -f "/tmp/libvirt.$1.suspended" ]
|
||||
then
|
||||
if virsh start "$1"
|
||||
if ${virsh} start "$1"
|
||||
then
|
||||
echo "Waiting for $1 to resume"
|
||||
while ! [ "$(LANG=C ${virsh} domstate $1)" = 'running' ]
|
||||
@ -48,40 +48,24 @@ inputs:
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
makeServices = machine:
|
||||
{
|
||||
"libvirt-hibernate-${machine}" =
|
||||
{
|
||||
description = "libvirt hibernate ${machine}";
|
||||
wantedBy = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
before = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
serviceConfig = { Type = "oneshot"; ExecStart = "${hibernate} ${machine}"; };
|
||||
};
|
||||
"libvirt-resume-${machine}" =
|
||||
{
|
||||
description = "libvirt resume ${machine}";
|
||||
wantedBy = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
after = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
serviceConfig = { Type = "oneshot"; ExecStart = "${resume} ${machine}"; };
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
"libvirt-hibernate@" =
|
||||
{
|
||||
description = "libvirt hibernate";
|
||||
before = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
serviceConfig = { Type = "oneshot"; ExecStart = "${hibernate} %i"; };
|
||||
};
|
||||
"libvirt-resume@" =
|
||||
{
|
||||
description = "libvirt resume";
|
||||
after = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
serviceConfig = { Type = "oneshot"; ExecStart = "${resume} %i"; };
|
||||
};
|
||||
"libvirt-hibernate@win10" =
|
||||
{
|
||||
wantedBy = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
overrideStrategy = "asDropin";
|
||||
};
|
||||
"libvirt-resume@win10" =
|
||||
{
|
||||
wantedBy = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
overrideStrategy = "asDropin";
|
||||
};
|
||||
"libvirt-hibernate@hardconnect" =
|
||||
{
|
||||
wantedBy = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
overrideStrategy = "asDropin";
|
||||
};
|
||||
"libvirt-resume@hardconnect" =
|
||||
{
|
||||
wantedBy = [ "systemd-hibernate.service" "systemd-suspend.service" ];
|
||||
overrideStrategy = "asDropin";
|
||||
};
|
||||
};
|
||||
(makeServices "win10") // (makeServices "hardconnect");
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user