diff --git a/README.md b/README.md index badb350..6fca128 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ The default values are below. `ntfy.server` (string url) Ntfy server to use. `ntfy.topic` (string) Ntfy topic for the notification. +Note : `$` will be expanded into the environment variables at runtime. Don't forget to escape it with `\`. + ### Usage * Adding a PR : `nixpkgs-notifier add PR1 PR2 PR3 ...` diff --git a/nixpkgs_notifier.py b/nixpkgs_notifier.py index f8f1c90..2b3dc0d 100644 --- a/nixpkgs_notifier.py +++ b/nixpkgs_notifier.py @@ -74,6 +74,32 @@ def load_config(): print("Config file is broken. Using default config.") return DEFAULT_CONFIG +import re + +def expand_env_vars(obj): + if isinstance(obj, dict): + return { + key: expand_env_vars(value) + for key, value in obj.items() + } + + elif isinstance(obj, list): + return [ + expand_env_vars(item) + for item in obj + ] + + elif isinstance(obj, str): + pattern = r"(?