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:
parent
04399569d8
commit
b48d53fa2a
39
README.md
39
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.
|
|
@ -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"
|
||||
|
|
17
src/nix_background_upgrade/main.py
Normal file
17
src/nix_background_upgrade/main.py
Normal 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()
|
BIN
src/nix_background_upgrade/nix-snowflake.png
Executable file
BIN
src/nix_background_upgrade/nix-snowflake.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
16
src/nix_background_upgrade/notification.py
Normal file
16
src/nix_background_upgrade/notification.py
Normal 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",
|
||||
)
|
Loading…
Reference in a new issue