• Python 77.5%
  • Nix 13%
  • HTML 9.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Renovate 31ef78938f chore(deps): lock file maintenance (#19)
This PR contains the following updates:

| Update | Change |
|---|---|
| lockFileMaintenance | All locks refreshed |

🔧 This Pull Request updates lock files to use the latest dependency versions.

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM, on day 1 of the month ( * 0-3 1 * * ) in timezone America/Edmonton, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNjkuMyIsInVwZGF0ZWRJblZlciI6IjQxLjE2OS4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: #19
2026-06-01 07:24:06 -06:00
byos_django nix-based deployment and dev environment 2025-03-07 08:50:09 -07:00
data Initial commit 2025-02-12 20:26:27 -05:00
etc fix csrf validation when not running in debug 2025-02-12 20:48:34 -05:00
templates chore(deps): update dependency monaco-editor to v0.53.0 (#10) 2025-09-08 10:02:15 -06:00
trmnl Add 'delete_other_device_screens' option in generate_screen API (#3) 2025-03-07 09:05:54 -07:00
.envrc nix-based deployment and dev environment 2025-03-07 08:50:09 -07:00
.gitignore nix-based deployment and dev environment 2025-03-07 08:50:09 -07:00
.isort.cfg Initial commit 2025-02-12 20:26:27 -05:00
flake.lock chore(deps): lock file maintenance (#19) 2026-06-01 07:24:06 -06:00
flake.nix nix-based deployment and dev environment 2025-03-07 08:50:09 -07:00
LICENSE Initial commit 2025-02-12 20:26:27 -05:00
manage.py Initial commit 2025-02-12 20:26:27 -05:00
module-trmnl-django.nix nix-based deployment and dev environment 2025-03-07 08:50:09 -07:00
package-trmnl-django.nix nix-based deployment and dev environment 2025-03-07 08:50:09 -07:00
README.md Add 'delete_other_device_screens' option in generate_screen API (#3) 2025-03-07 09:05:54 -07:00
renovate.json5 chore: centralize renovate config 2025-05-06 21:11:34 -06:00

TRMNL BYOS - Python / Django

This is a fork of TRMNL's Django BYOS app. This fork adds Nix-based packaging and deployment of the application.

Original: This is an implementation of the TRMNL API in Python, which you can use your TRMNL device with.

Development

This app uses direnv and nix to provide all dependencies. Please install and use those.

Django App

python ./manage.py migrate
python ./manage.py createsuperuser
python ./manage.py collectstatic
daphne -b 0.0.0.0 -p 8000 byos_django.asgi:application

# your app is now up on http://localhost:8000

TRMNL Screens

Access http://localhost:8000/preview where you can test the rendering output of TRML screens.

Deployment

This is intended to be deployed as a NixOS module referenced by a flake; these instructions follow that approach:

  1. Add this repo as a flake input in flake.nix:

    {
      inputs = {
        # ...
        mathieu-trmnl.url = "git+ssh://[email protected]/mfenniak/mathieu-trmnl.git?ref=main";
      }
    }
    
  2. Install the package overlay and nixos module in flake.nix:

    {
      outputs = { ...other-inputs..., mathieu-trmnl, ... } = {
        nixosConfigurations.my-system = nixpkgs.lib.nixosSystem {
          system = "x86_64-linux";
          modules = [
            # other modules, configurations, etc.
            { nixpkgs.overlays = [ mathieu-trmnl.overlays.default ]; }
            mathieu-trmnl.nixosModules.trmnl-django
          ];
        };
      }
    }
    
  3. Enable the program in your system configuration:

    { config, ... }:
    
    let
      host = "trmnl.example.com";
    in {
      programs.trmnl-django = {
        enable = true;
        port = 8000;
        allowedHosts = "${host}";
      };
    
      services.nginx.virtualHosts."${host}" = {
        forceSSL = true;
        enableACME = true;
        locations."/" = {
          proxyPass = "http://localhost:${toString config.programs.trmnl-django.port}";
          proxyWebsockets = true;
        };
      };
    }
    
  4. Add /var/lib/trmnl-django to your backups.

  5. Rebuild NixOS and ensure that trmnl-django.service is running successfully.

  6. Create an initial superuser:

    Find the trmnl-django package in /nix/store in order to run the createsuperuser binary within:

    DB_FILE=/var/lib/trmnl-django/trmnl-django.db sudo /nix/store/gky87fqcwzp6kphrpc8spnzmchkkdqgz-trmnl-django-0.1/bin/createsuperuser
    

Usage

  • Point your TRMNL to your IP or Hostname http://your-ip-or-hostname:8000
  • Open your browser to the same URL, you'll be redirected to the admin page.
  • Once your start your TRMNL, you'll see a new device under the Devices section. To "pair" it, just assign it to your user.
  • If you see the Rover image, your device is paired and ready to use!
  • You can create a new Screen under the Screens section.
    • Use whatever HTML you want. I recommend using the boilerplate in temmplates/base.html to make use of the framework.
    • Click Save and wait a moment for the image to be generated.
    • On the next refresh (defaults to 900 seconds, can be configured on the Device edit page) your TRMNL will update to the new screen.

API

Generate a screen for a specific device by creating an API Key from Admin > API Keys > Add, then:

curl --location 'http://your.ip.address.here:8000/api/v1/generate_screen' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer xxxxxx' \
--data '{
  "device": "XXXXXX", # friendly ID
  "html": "<p>Made via API</p>"
}'

An optional body parameter delete_other_device_screens can be set to true, which will cause the new screen to be the only screen displayed to the requested device, deleting all other screens for that device. This allows the API to be used to remotely update the TRMNL device to one specific rendered output.

Troubleshooting:

  • After creating an API Key, it appears just once following Save > redirect
  • For the API Key to be valid, your device must belong to a user before creating and it with that user