--- a/src/pyload/core/__init__.py +++ b/src/pyload/core/__init__.py @@ -130,6 +130,14 @@ class Core: else: self._debug = max(0, int(debug)) + # Process core config environment variables (NixOS declarative config) + for env, value in os.environ.items(): + if not env.startswith("PYLOAD__"): + continue + parts = env.removeprefix("PYLOAD__").lower().split("__", 1) + if len(parts) == 2 and parts[0] in self.config.config: + self.config.set(parts[0], parts[1], value) + # If no argument set, read storage dir from config file, # otherwise save setting to config dir if storagedir is None: @@ -226,6 +234,20 @@ class Core: self.acm = self.account_manager = AccountManager(self) self.thm = self.thread_manager = ThreadManager(self) self.cpm = self.captcha_manager = CaptchaManager(self) + + # Process plugin config environment variables BEFORE AddonManager (NixOS declarative config) + # This must happen before AddonManager reads the enabled flag to decide which addons to start + # Build case-insensitive lookup map for plugin names + plugin_name_map = {name.lower(): name for name in self.config.plugin.keys()} + + for env, value in os.environ.items(): + if not env.startswith("PYLOAD__"): + continue + parts = env.removeprefix("PYLOAD__").lower().split("__", 1) + if len(parts) == 2 and parts[0] in plugin_name_map: + actual_plugin_name = plugin_name_map[parts[0]] + self.config.set_plugin(actual_plugin_name, parts[1], value) + self.adm = self.addon_manager = AddonManager(self) def _setup_permissions(self):