diff --git a/README.md b/README.md index e69de29..a2a0f4e 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,39 @@ +# Nix Background Upgrade +Upgrade NixOS system (and/or home-manager) in the background, with notification support. + +**Early stages of development, subject to change and likely not working at the current stage.** + +## Install +Clone the repository and install with pip (or preferred Python packaging system): + +```bash +git clone https://git.xenia.me.uk/pixelifytica/nix-background-upgrade.git +python3 -m pip install ./nix-background-upgrade +``` + +### For development +Project uses [Poetry](https://python-poetry.org/ "Poetry: Python packaging and dependency management tool") to manage dependencies. + +Install Poetry (see [documentation](https://python-poetry.org/docs/#installation) for more details), for example using `pipx`: + +```bash +pipx install poetry +``` + +Then install project using `poetry`: + +```bash +poetry install +``` + +Python code is formatted using [black](https://pypi.org/project/black/ "The uncompromising code formatter") and [isort](https://pypi.org/project/isort/ "A Python utility / library to sort Python imports"). + +#### `pre-commit` +[pre-commit](https://pre-commit.com/ "A framework for managing and maintaining multi-language pre-commit hooks") is used to ensure formatting of new/changed files. Install pre-commit hooks with: + +```bash +pre-commit install --install-hooks +``` + +### Nix Flake +Project provides a Nix `flake.nix` to get up and running quickly. diff --git a/pyproject.toml b/pyproject.toml index 325b1f6..5dfc48e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,13 @@ version = "0.1.0" description = "Upgrade NixOS system (and/or home-manager) in the background, with notification support" authors = ["Evie Litherland-Smith "] readme = "README.md" -license = "LICENSE" +license = "MIT" +repository = "https://git.xenia.me.uk/pixelifytica/nix-background-upgrade" packages = [{include = "nix_background_upgrade", from = "src"}] +[tool.poetry.scripts] +nbu = 'nix_background_upgrade.main:main' + [tool.poetry.dependencies] python = "^3.9" notify-py = "^0.3.0" diff --git a/src/nix_background_upgrade/main.py b/src/nix_background_upgrade/main.py new file mode 100644 index 0000000..0ccf2e6 --- /dev/null +++ b/src/nix_background_upgrade/main.py @@ -0,0 +1,17 @@ +from .notification import create_notification + + +def main(*args, **kwargs) -> None: + """ + Sends a test notification to check everything is working + + :returns: None + """ + notification = create_notification() + notification.message = "This is a test notification" + notification.send() + return + + +if __name__ == "__main__": + main() diff --git a/src/nix_background_upgrade/nix-snowflake.png b/src/nix_background_upgrade/nix-snowflake.png new file mode 100755 index 0000000..04a04bc Binary files /dev/null and b/src/nix_background_upgrade/nix-snowflake.png differ diff --git a/src/nix_background_upgrade/notification.py b/src/nix_background_upgrade/notification.py new file mode 100644 index 0000000..8c7f4ce --- /dev/null +++ b/src/nix_background_upgrade/notification.py @@ -0,0 +1,16 @@ +from pathlib import Path + +from notifypy import Notify + + +def create_notification() -> Notify: + """ + Create notification class + + :returns: Notify class with custom defaults + """ + return Notify( + default_notification_title="Nix Background Update", + default_notification_message="Message from Nix process", + default_notification_icon=Path(__file__).parent / "./nix-snowflake.png", + )