diff --git a/examples/python-django/devenv.nix b/examples/python-django/devenv.nix index dd406dc1d..8a966c700 100644 --- a/examples/python-django/devenv.nix +++ b/examples/python-django/devenv.nix @@ -2,8 +2,6 @@ let db_user = "postgres"; - db_host = "localhost"; - db_port = "5432"; db_name = "db"; in { @@ -13,25 +11,28 @@ in poetry.enable = true; }; + # To load secrets like SECRET_KEY from .env + # dotenv.enable = true; + env = { - DATABASE_URL = "postgres://${db_user}@/${db_name}?host=${config.env.PGHOST}"; + DATABASE_URL = "postgres://${db_user}@${config.env.PGHOST}/${db_name}"; DEBUG = true; - SECRET_KEY = "123"; - STATIC_ROOT = "/tmp"; + SECRET_KEY = "supersecret"; + STATIC_ROOT = config.devenv.state + "/static"; }; services.postgres = { enable = true; initialScript = "CREATE USER ${db_user} SUPERUSER;"; initialDatabases = [{ name = db_name; }]; - listen_addresses = db_host; }; - processes.runserver.exec = "python manage.py runserver"; - processes.runserver.process-compose.depends_on.postgres.condition = "process_ready"; + processes.runserver = { + exec = "python manage.py runserver"; + process-compose.depends_on.postgres.condition = "process_ready"; + }; enterTest = '' - wait_for_port ${db_port} python manage.py test ''; }