Hi,
I am trying to deploy a Django application using NixOps and I am not able to. Here is what I have tried:
I build the python package like this (I have a setup.py):
with import <nixpkgs> { };
python38Packages.callPackage buildPythonApplication rec {
name = "django-example";
src = ./backend;
doCheck = false;
propagatedBuildInputs = [
python38
python38Packages.django
python38Packages.gunicorn
];
}
Then in a droplet.nix I want to add lines similar to this (hoping the nginx reverse proxy config will be easy)
# django-example = import ./django-example/default.nix;
# systemd.services.django-example = {
# enable = true;
# script = ''
# ${pkgs.python38Packages.gunicorn}/bin/gunicorn -b 0.0.0.0 -p 8000 --chdir ${django-example} django-example.wsgi:application
# '';
# };
This is throwing an error about about tmp files. I assume because gunicorn tries to create a tmp directory in django-example but it can’t.
The idea I was trying was:
- build python package. I found setup.py and poetry for this and got setup.py working first.
- Get nix to build the python package. This is what I pasted above.
- deploy using NixOps. It seems to me systemd might be a good fit here.
Is there an example deployment that uses gunicorn that I can use?