Add README content, add example/demo script

Fix setting license in pyproject.toml correctly

Point to main script in pyproject to run CLI
This commit is contained in:
Evie Litherland-Smith 2024-05-26 10:35:21 +01:00
parent 04399569d8
commit b48d53fa2a
5 changed files with 77 additions and 1 deletions

View file

@ -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.

View file

@ -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 <evie@xenia.me.uk>"]
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"

View file

@ -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()

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -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",
)