- Rust 94.4%
- Nix 3.5%
- Dockerfile 2.1%
| src | ||
| templates | ||
| .dockerignore | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| example.env | ||
| flake.lock | ||
| flake.nix | ||
| init.sql | ||
| LICENSE | ||
| README.md | ||
HomeLab Bot
Matrix bot for homelab management. Built with Rust and the Matrix Rust SDK.
Features
- Forgejo webhook integration: push commits and CI workflow notifications
- Daily commit reminder via scheduler
/ping- health check/commits- manual commit summary
Requirements
- Rust (edition 2024)
- PostgreSQL
- A Matrix account on any homeserver
Setup
Native
-
Clone the repository:
git clone https://git.geekiot.tech/geekiot/homelab-bot cd homelab-bot -
Create a
.envfile from the example:cp example.env .env -
Edit
.envwith your configuration:Variable Description Default MATRIX_HOMESERVERMatrix server URL - MATRIX_USER_IDFull bot MXID - MATRIX_USER_PASSWORDBot account password - MATRIX_SESSION_DIRDirectory for session.json./SERVER_PORTWebhook listen port 3000FORGEJO_WEBHOOK_SECRETHMAC-SHA256 secret for webhooks - FORGEJO_ROOM_IDMatrix room ID for notifications - DATABASE_URLPostgreSQL connection string - SCHEDULER_TIMEDaily reminder time (HH:MM) 18:00 -
Create the database table:
psql -d your_database -f init.sql -
Build and run:
RUST_LOG=info cargo runOn first run the bot logs in with password and saves the session to
session.json. Subsequent runs restore the session automatically.
Docker
-
Create a
.envfile from the example:cp example.env .env -
Edit
.envwith your configuration. -
Start the stack:
docker compose up -dThis starts both PostgreSQL and the bot. The bot connects to
postgreshostname internally, soDATABASE_URLshould be:DATABASE_URL=postgres://homelab:homelab@postgres:5432/homelabOn first run the bot logs in with password and saves the session to the
storagevolume. Subsequent runs restore the session automatically.
Nix
If you use Nix, a flake is provided:
nix develop
RUST_LOG=info cargo run
Webhook setup
In your Forgejo repository settings, add a webhook:
- Target URL:
http://your-bot:3000/webhook/forgejo - Secret: same as
FORGEJO_WEBHOOK_SECRET - Events: push, workflow run
Commands
| Command | Description |
|---|---|
/ping |
Health check, replies pong |
/commits |
Show commit summary for today |
Logging
RUST_LOG=homelab_bot=info cargo run # bot messages only
RUST_LOG=info cargo run # all logs (default)
RUST_LOG=debug cargo run # verbose logs
Project structure
.
├── Cargo.toml # Rust dependencies and metadata
├── flake.nix # Nix flake for development shell
├── example.env # Environment variable template
├── templates/ # Askama template files
└── src/
├── main.rs # Entry point
├── lib.rs # Core logic, session management
├── config.rs # Configuration
├── templates.rs # Template structs and markdown helper
├── bot.rs # Command dispatch
├── commands/ # Bot commands (ping, commits)
├── services/ # External integrations (forgejo)
├── scheduler/ # Background tasks (daily reminder)
└── storage/ # Bot data store (PostgreSQL)