nixos/appvm: init at unstable-2021-12-20

Co-authored-by: Mikhail Klementev <blame@dumpstack.io>
Co-authored-by: Cabia Rangris <me@cab404.ru>
This commit is contained in:
Jonas Heinrich 2022-05-20 14:21:27 +02:00 committed by Yt
parent 87d9910cef
commit f81c763c1d
10 changed files with 157 additions and 3 deletions

View File

@ -43,8 +43,9 @@
<itemizedlist spacing="compact">
<listitem>
<para>
Please remove this line when you add the first item since
docbook requires the section to be non-empty
<link xlink:href="https://github.com/jollheef/appvm">appvm</link>,
Nix based app VMs. Available as
<link xlink:href="options.html#opt-virtualisation.appvm.enable">virtualisation.appvm</link>.
</para>
</listitem>
</itemizedlist>

View File

@ -23,7 +23,7 @@ In addition to numerous new and upgraded packages, this release has the followin
## New Services {#sec-release-22.11-new-services}
- Please remove this line when you add the first item since docbook requires the section to be non-empty
- [appvm](https://github.com/jollheef/appvm), Nix based app VMs. Available as [virtualisation.appvm](options.html#opt-virtualisation.appvm.enable).
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

View File

@ -1236,6 +1236,7 @@
./tasks/powertop.nix
./testing/service-runner.nix
./virtualisation/anbox.nix
./virtualisation/appvm.nix
./virtualisation/build-vm.nix
./virtualisation/container-config.nix
./virtualisation/containerd.nix

View File

@ -0,0 +1,49 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.virtualisation.appvm;
in {
options = {
virtualisation.appvm = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
This enables AppVMs and related virtualisation settings.
'';
};
user = mkOption {
type = types.str;
description = ''
AppVM user login. Currenly only AppVMs are supported for a single user only.
'';
};
};
};
config = mkIf cfg.enable {
virtualisation.libvirtd = {
enable = true;
qemu.verbatimConfig = ''
namespaces = []
user = "${cfg.user}"
group = "users"
remember_owner = 0
'';
};
users.users."${cfg.user}" = {
packages = [ pkgs.appvm ];
extraGroups = [ "libvirtd" ];
};
};
}

View File

@ -0,0 +1,12 @@
diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui
index 430f879..68856fc 100644
--- a/src/resources/ui/virt-viewer.ui
+++ b/src/resources/ui/virt-viewer.ui
@@ -137,7 +137,6 @@
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
- <property name="visible">True</property>
<property name="can-focus">False</property>
<property name="show-close-button">True</property>
<child>

View File

@ -0,0 +1,15 @@
diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index 2265f02..1d60d81 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -317,8 +317,8 @@ virt_viewer_display_spice_new(VirtViewerSessionSpice *session,
gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->display));
gtk_widget_show(GTK_WIDGET(self->display));
g_object_set(self->display,
- "grab-keyboard", TRUE,
- "grab-mouse", TRUE,
+ "grab-keyboard", FALSE,
+ "grab-mouse", FALSE,
"resize-guest", FALSE,
"scaling", TRUE,
NULL);

View File

@ -0,0 +1,14 @@
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index fe740ce..d45fd4f 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -1342,6 +1342,9 @@ virt_viewer_window_update_title(VirtViewerWindow *self)
grabhint,
g_get_application_name());
}
+ } else if (g_str_has_prefix(self->subtitle, "appvm_")) {
+ /* Use name of the application as a title */
+ title = g_strdup_printf(_("%s"), &self->subtitle[strlen("appvm_")]);
} else if (self->subtitle) {
/* translators:
* This is "<subtitle> - <appname>"

View File

@ -0,0 +1,12 @@
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index b977b7b..36bce34 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -976,6 +976,7 @@ virt_viewer_app_set_window_subtitle(VirtViewerApp *app,
*d = '%';
} else
subtitle = g_strdup_printf("%s (%s)", title, desc);
+ subtitle = g_strdup_printf("%s", title);
g_free(desc);
}

View File

@ -0,0 +1,48 @@
{ lib
, buildGoModule
, fetchFromGitHub
, nix
, virt-viewer
, fetchpatch
, makeWrapper }:
let
# Upstream patches fail with newer virt-viewer. These are own ports to the
# newest virt-viewer version, see:
# https://github.com/jollheef/appvm/issues/28
virt-manager-without-menu = virt-viewer.overrideAttrs(oldAttrs: {
patches = oldAttrs.patches ++ [
./0001-Remove-menu-bar.patch
./0002-Do-not-grab-keyboard-mouse.patch
./0003-Use-name-of-appvm-applications-as-a-title.patch
./0004-Use-title-application-name-as-subtitle.patch
];
});
in
buildGoModule rec {
pname = "appvm";
version = "unstable-2021-12-20";
src = fetchFromGitHub {
owner = "jollheef";
repo = pname;
rev = "17f17be7846d872e7e26d5cb6759a52ea4113587";
sha256 = "sha256-FL5olOy1KufULyqI2dJeS0OnKzC3LfPWxnia2i4f4yY=";
};
vendorSha256 = "sha256-8eU+Mf5dxL/bAMMShXvj8I1Kdd4ysBTWvgYIXwLStPI=";
buildInputs = [ makeWrapper ];
postFixup = ''
wrapProgram $out/bin/appvm \
--prefix PATH : "${lib.makeBinPath [ nix virt-manager-without-menu ]}"
'';
meta = with lib; {
description = "Nix-based app VMs";
homepage = "https://code.dumpstack.io/tools/${pname}";
maintainers = with maintainers; [ dump_stack cab404 onny ];
license = licenses.gpl3;
};
}

View File

@ -25095,6 +25095,8 @@ with pkgs;
adobe-reader = pkgsi686Linux.callPackage ../applications/misc/adobe-reader { };
appvm = callPackage ../applications/virtualization/appvm { };
masterpdfeditor = libsForQt5.callPackage ../applications/misc/masterpdfeditor { };
masterpdfeditor4 = libsForQt5.callPackage ../applications/misc/masterpdfeditor4 { };