Skip to content

Commit

Permalink
feat[close #340]: Propose the Vanilla OS VM image on virtual machines
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkobrombin committed Jan 9, 2024
1 parent fd73446 commit cbd85be
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 1 deletion.
2 changes: 2 additions & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vanilla_installer/gtk/default-keyboard.ui
vanilla_installer/gtk/default-language.ui
vanilla_installer/gtk/default-network.ui
vanilla_installer/gtk/default-nvidia.ui
vanilla_installer/gtk/default-vm.ui
vanilla_installer/gtk/default-theme.ui
vanilla_installer/gtk/default-timezone.ui
vanilla_installer/gtk/default-users.ui
Expand Down Expand Up @@ -43,6 +44,7 @@ vanilla_installer/defaults/keyboard.py
vanilla_installer/defaults/language.py
vanilla_installer/defaults/network.py
vanilla_installer/defaults/nvidia.py
vanilla_installer/defaults/vm.py
vanilla_installer/defaults/theme.py
vanilla_installer/defaults/timezone.py
vanilla_installer/defaults/welcome.py
Expand Down
9 changes: 8 additions & 1 deletion recipe.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"distro_logo": "org.vanillaos.Installer-flower",
"images": {
"default": "ghcr.io/vanilla-os/desktop:main",
"nvidia": "ghcr.io/vanilla-os/nvidia:main"
"nvidia": "ghcr.io/vanilla-os/nvidia:main",
"vm": "ghcr.io/vanilla-os/vm:main"
},
"default_root_size": 12288,
"min_disk_size": 28680,
Expand Down Expand Up @@ -55,6 +56,12 @@
"lspci | grep -i '.* nvidia .*'"
]
},
"vm": {
"template": "vm",
"display-conditions": [
"grep 'hypervisor' /proc/cpuinfo"
]
},
"disk": {
"template": "disk"
},
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/defaults/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sources = [
'disk.py',
'encryption.py',
'nvidia.py',
'vm.py',
'conn_check.py',
'network.py',
]
Expand Down
53 changes: 53 additions & 0 deletions vanilla_installer/defaults/vm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# vm.py
#
# Copyright 2023 mirkobrombin
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundationat version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from gi.repository import Adw, Gtk


@Gtk.Template(resource_path="/org/vanillaos/Installer/gtk/default-vm.ui")
class VanillaDefaultVm(Adw.Bin):
__gtype_name__ = "VanillaDefaultVm"

btn_no = Gtk.Template.Child()
btn_yes = Gtk.Template.Child()

use_vm_tools = None

def __init__(self, window, distro_info, key, step, **kwargs):
super().__init__(**kwargs)
self.__window = window
self.__distro_info = distro_info
self.__key = key
self.__step = step

self.btn_yes.connect("clicked", self.use_vm_tools_fn)
self.btn_no.connect("clicked", self.skip_vm_tools_fn)

def get_finals(self):
return {
"vm": {
"use-vm-tools": self.use_vm_tools,
}
}

def skip_vm_tools_fn(self, _):
self.use_vm_tools = False
self.__window.next()

def use_vm_tools_fn(self, _):
self.use_vm_tools = True
self.__window.next()
53 changes: 53 additions & 0 deletions vanilla_installer/gtk/default.vm.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="VanillaDefaultVm" parent="AdwBin">
<property name="halign">0</property>
<property name="valign">0</property>
<property name="hexpand">true</property>
<child>
<object class="AdwStatusPage" id="status_page">
<property name="halign">0</property>
<property name="valign">0</property>
<property name="hexpand">true</property>
<property name="icon-name">video-display-symbolic</property>
<property name="title" translatable="yes">VM Tools</property>
<property name="description" translatable="yes">Choose whether to install VM Tools for better compatibility and performance.</property>
<child>
<object class="GtkBox">
<property name="orientation">1</property>
<property name="vexpand">true</property>
<property name="hexpand">true</property>
<property name="valign">3</property>
<child>
<object class="GtkBox">
<property name="valign">3</property>
<property name="spacing">10</property>
<property name="halign">3</property>
<child>
<object class="GtkButton" id="btn_no">
<property name="label" translatable="yes">Skip</property>
<property name="halign">3</property>
<style>
<class name="pill"/>
</style>
</object>
</child>
<child>
<object class="GtkButton" id="btn_yes">
<property name="label" translatable="yes">Install (Recommended)</property>
<property name="halign">3</property>
<style>
<class name="pill"/>
<class name="suggested-action"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
2 changes: 2 additions & 0 deletions vanilla_installer/utils/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from vanilla_installer.defaults.language import VanillaDefaultLanguage
from vanilla_installer.defaults.network import VanillaDefaultNetwork
from vanilla_installer.defaults.nvidia import VanillaDefaultNvidia
from vanilla_installer.defaults.vm import VanillaDefaultVm
from vanilla_installer.defaults.timezone import VanillaDefaultTimezone
from vanilla_installer.defaults.welcome import VanillaDefaultWelcome
from vanilla_installer.layouts.preferences import VanillaLayoutPreferences
Expand All @@ -47,6 +48,7 @@
"disk": VanillaDefaultDisk,
"encryption": VanillaDefaultEncryption,
"nvidia": VanillaDefaultNvidia,
"vm": VanillaDefaultVm,
"yes-no": VanillaLayoutYesNo,
}

Expand Down
3 changes: 3 additions & 0 deletions vanilla_installer/utils/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ def gen_install_recipe(log_path, finals, sys_recipe):
elif "nvidia" in final.keys():
if final["nvidia"]["use-proprietary"]:
oci_image = images["nvidia"]
elif "vm" in final.keys():
if final["vm"]["use-vm-tools"]:
oci_image = images["vm"]

# Installation
recipe.set_installation("oci", oci_image)
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/vanilla-installer.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<file>gtk/default-conn-check.ui</file>
<file>gtk/default-network.ui</file>
<file>gtk/default-nvidia.ui</file>
<file>gtk/default-vm.ui</file>
<file>gtk/widget-choice.ui</file>
<file>gtk/widget-choice-expander.ui</file>
<file>gtk/widget-disk.ui</file>
Expand Down

0 comments on commit cbd85be

Please sign in to comment.