Allow running the VM using virt-viewer
This commit is contained in:
parent
2b5fe69994
commit
90368fcda8
1 changed files with 36 additions and 15 deletions
|
@ -31,6 +31,11 @@ in {
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virt-viewer = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
qemu = {
|
qemu = {
|
||||||
runInBackground = lib.mkOption {
|
runInBackground = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
|
@ -70,18 +75,23 @@ in {
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
runAsRoot = lib.mkIf vmVariant.virtualisation.sharedHostKeys true;
|
runAsRoot = lib.mkIf vmVariant.virtualisation.sharedHostKeys true;
|
||||||
|
|
||||||
qemu.options =
|
qemu = {
|
||||||
with {
|
spice.enable = lib.mkIf vmVariant.virtualisation.virt-viewer true;
|
||||||
inherit (vmVariant.virtualisation.qemu) spice;
|
runInBackground = lib.mkIf vmVariant.virtualisation.virt-viewer true;
|
||||||
};
|
|
||||||
(
|
options =
|
||||||
lib.optional (spice.enable)
|
with {
|
||||||
("-spice " + (
|
inherit (vmVariant.virtualisation.qemu) spice;
|
||||||
lib.concatStringsSep "," [
|
};
|
||||||
"addr=${lib.escapeShellArg spice.bindAddress}"
|
(
|
||||||
"port=${toString spice.port}"
|
lib.optional (spice.enable)
|
||||||
"disable-ticketing=on"
|
("-spice " + (
|
||||||
])));
|
lib.concatStringsSep "," [
|
||||||
|
"addr=${lib.escapeShellArg spice.bindAddress}"
|
||||||
|
"port=${toString spice.port}"
|
||||||
|
"disable-ticketing=on"
|
||||||
|
])));
|
||||||
|
};
|
||||||
|
|
||||||
sharedDirectories = lib.optionalAttrs (vmVariant.virtualisation.sharedHostKeys) {
|
sharedDirectories = lib.optionalAttrs (vmVariant.virtualisation.sharedHostKeys) {
|
||||||
hostKeys =
|
hostKeys =
|
||||||
|
@ -126,9 +136,20 @@ in {
|
||||||
|
|
||||||
wrapped = pkgs.writeShellApplication {
|
wrapped = pkgs.writeShellApplication {
|
||||||
name = "run-${config.system.name}-vm";
|
name = "run-${config.system.name}-vm";
|
||||||
text = ''
|
text = lib.strings.concatLines (
|
||||||
${prefix} ${vm}/bin/run-${config.system.name}-vm ${suffix}
|
[
|
||||||
'';
|
"${prefix} ${vm}/bin/run-${config.system.name}-vm ${suffix}"
|
||||||
|
] ++ (
|
||||||
|
let
|
||||||
|
spice = config.virtualisation.qemu.spice;
|
||||||
|
in
|
||||||
|
(
|
||||||
|
lib.optionals
|
||||||
|
config.virtualisation.virt-viewer
|
||||||
|
[
|
||||||
|
"${pkgs.virt-viewer}/bin/remote-viewer spice://${lib.escapeShellArg spice.bindAddress}:${toString spice.port}"
|
||||||
|
"kill %1"
|
||||||
|
])));
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
pkgs.symlinkJoin {
|
pkgs.symlinkJoin {
|
||||||
|
|
Loading…
Reference in a new issue