Adding a Pipewire application profile (#821)

* Adding a Pipewire application profile

This to better manage the pipewire setup process and minimize guided a bit. This also adds the concept of @archinstall.plugin decorators to add a plugin in run-time. Which pipewire uses to detect user creation and enable the pipewire-pulse service for new users.

* Forgot to run .install() on pipewire Application()
* Backwards compatible variable insertion for installation session
This commit is contained in:
Anton Hvornum 2022-01-02 16:36:50 +01:00
parent 93aa4aa6cc
commit 240f688cce
4 changed files with 28 additions and 5 deletions

View File

@ -172,7 +172,11 @@ define_arguments()
arguments = get_arguments()
post_process_arguments(arguments)
# TODO: Learn the dark arts of argparse... (I summon thee dark spawn of cPython)
# @archinstall.plugin decorator hook to programmatically add
# plugins in runtime. Useful in profiles and other things.
def plugin(f, *args, **kwargs):
plugins[f.__name__] = f
def run_as_a_module():
"""

View File

@ -109,7 +109,9 @@ class Installer:
self.post_base_install = []
# TODO: Figure out which one of these two we'll use.. But currently we're mixing them..
storage['session'] = self
storage['installation_session'] = self
self.MODULES = []
self.BINARIES = []
@ -782,13 +784,18 @@ class Installer:
handled_by_plugin = False
for plugin in plugins.values():
if hasattr(plugin, 'on_user_create'):
if result := plugin.on_user_create(user):
if result := plugin.on_user_create(self, user):
handled_by_plugin = result
if not handled_by_plugin:
self.log(f'Creating user {user}', level=logging.INFO)
SysCommand(f'/usr/bin/arch-chroot {self.target} useradd -m -G wheel {user}')
for plugin in plugins.values():
if hasattr(plugin, 'on_user_created'):
if result := plugin.on_user_created(self, user):
handled_by_plugin = result
if password:
self.user_set_pw(user, password)

View File

@ -295,9 +295,7 @@ def perform_installation(mountpoint):
if archinstall.arguments.get('audio', None) is not None:
installation.log(f"This audio server will be used: {archinstall.arguments.get('audio', None)}", level=logging.INFO)
if archinstall.arguments.get('audio', None) == 'pipewire':
print('Installing pipewire ...')
installation.add_additional_packages(["pipewire", "pipewire-alsa", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"])
archinstall.Application(installation, 'pipewire').install()
elif archinstall.arguments.get('audio', None) == 'pulseaudio':
print('Installing pulseaudio ...')
installation.add_additional_packages("pulseaudio")

View File

@ -0,0 +1,14 @@
import archinstall
import logging
# Define the package list in order for lib to source
# which packages will be installed by this profile
__packages__ = ["pipewire", "pipewire-alsa", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"]
archinstall.log('Installing pipewire', level=logging.INFO)
archinstall.storage['installation_session'].add_additional_packages(__packages__)
@archinstall.plugin
def on_user_created(installation :archinstall.Installer, user :str):
archinstall.log(f"Enabling pipewire-pulse for {user}", level=logging.INFO)
installation.chroot('systemctl enable --user pipewire-pulse.service', run_as=user)