[jhbuild/wip/benzea/systemd-user-session] env: Set systemd unit and generator paths



commit d4a3c6afdb1ff157dd20e2fc95c85f882a1ac7b8
Author: Benjamin Berg <bberg redhat com>
Date:   Tue Mar 24 15:11:29 2020 +0100

    env: Set systemd unit and generator paths
    
    When starting a (nested) systemd user instance, we can get systemd to
    pick up unit and generator directories from inside the virtual
    environment (without re-compiling systemd to adjust the paths). This
    also means that units from the outside can still be picked up, with the
    corresponding advantages and disadvantages.

 jhbuild/environment.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/jhbuild/environment.py b/jhbuild/environment.py
index 9b96bdad..bd4a34a4 100644
--- a/jhbuild/environment.py
+++ b/jhbuild/environment.py
@@ -268,3 +268,29 @@ def setup_env(prefix):
         addpath('PYTHONPATH', os.path.join(PKGDATADIR, 'sitecustomize'))
     else:
         addpath('PYTHONPATH', os.path.join(SRCDIR, 'jhbuild', 'sitecustomize'))
+
+    # SYSTEMD unit and generators paths
+    # The following variables allow launching a full blown desktop including
+    # its own systemd instance. It is intended for use together with the
+    # gnome-launch-systemd script provided by gnome-session for testing
+    # purposes. It also requires an environment generator to ensure that
+    # the jhbuild environment is fully imported into systemd.
+    # Ensure an empty postfix so that systemd appends the default paths
+    addpath('SYSTEMD_UNIT_PATH', '')
+    addpath('SYSTEMD_GENERATOR_PATH', '')
+    addpath('SYSTEMD_ENVIRONMENT_GENERATOR_PATH', '')
+
+    # Generator paths are easy, just add the correct directories from lib
+    addpath('SYSTEMD_GENERATOR_PATH', os.path.join(libdir, 'systemd/user-generators'))
+    addpath('SYSTEMD_ENVIRONMENT_GENERATOR_PATH', os.path.join(libdir, 
'systemd/user-environment-generators'))
+
+    # For the systemd unit path, it makes sense to include some more directories
+    # to ensure correct priority from systemd (i.e. we intentionally repeat some
+    # default paths here). The first is the one we really care about.
+    addpath('SYSTEMD_UNIT_PATH', os.path.join(libdir, 'systemd/user'))
+    addpath('SYSTEMD_UNIT_PATH', os.path.join(os.environ['XDG_RUNTIME_DIR'], 'systemd/generator'))
+    addpath('SYSTEMD_UNIT_PATH', os.path.join(os.environ['XDG_RUNTIME_DIR'], 'systemd/user'))
+    addpath('SYSTEMD_UNIT_PATH', os.path.join(prefix, 'etc/systemd/user'))
+    # permit higher priority user configurations?
+    # addpath('SYSTEMD_UNIT_PATH', os.path.join(xdg_config_dir, 'systemd/user'))
+    addpath('SYSTEMD_UNIT_PATH', os.path.join(os.environ['XDG_RUNTIME_DIR'], 'systemd/generator.early'))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]