diff options
author | pacien | 2021-07-25 21:53:11 +0200 |
---|---|---|
committer | pacien | 2021-07-25 21:53:11 +0200 |
commit | 1a74f19cd68e3b7264621e7231475c6b25505e6d (patch) | |
tree | 71eff90e1978f4a6606cdbcd068738a34d844980 | |
parent | ae3fc354f3b15dfefb8ce6f2294768e063e53d19 (diff) | |
download | uge_l2_rdbms_python_proto-1a74f19cd68e3b7264621e7231475c6b25505e6d.tar.gz |
flake: add python project dependencies
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | flake.nix | 35 |
2 files changed, 30 insertions, 6 deletions
@@ -1,3 +1,4 @@ | |||
1 | __pycache__ | ||
1 | development_database | 2 | development_database |
2 | *~ | 3 | *~ |
3 | *.swp | 4 | *.swp |
@@ -17,11 +17,18 @@ | |||
17 | 17 | ||
18 | python = python39; | 18 | python = python39; |
19 | 19 | ||
20 | develPackagesAndScripts = with python.pkgs; [ | 20 | pythonWithDependencies = python.withPackages (ps: with ps; [ |
21 | postgresql_13 # PostgreSQL server with the standard admin tools. | 21 | uvicorn # server for the web app |
22 | ipython # Interactive Python REPL for experimenting. | 22 | fastapi # simple Python framework to build web apps |
23 | psycopg2 # PostgreSQL driver for Python | 23 | python-multipart # to let fastapi handle form submissions |
24 | embrace # bridges raw SQL queries to Python functions | 24 | passlib # for account password hashing |
25 | psycopg2 # PostgreSQL driver for Python | ||
26 | embrace # bridges raw SQL queries to Python functions | ||
27 | ]); | ||
28 | |||
29 | develPackagesAndScripts = [ | ||
30 | postgresql_13 # PostgreSQL server with the standard admin tools. | ||
31 | python.pkgs.ipython # Interactive Python REPL for experimenting. | ||
25 | 32 | ||
26 | # More pleasant alternative to psql, with colours and auto-completion. | 33 | # More pleasant alternative to psql, with colours and auto-completion. |
27 | # Custom configuration to suppress irrelevant warnings and messages. | 34 | # Custom configuration to suppress irrelevant warnings and messages. |
@@ -54,6 +61,20 @@ | |||
54 | -d 2 \ | 61 | -d 2 \ |
55 | "$@" | 62 | "$@" |
56 | '') | 63 | '') |
64 | |||
65 | # Script for starting the Uvicorn local development server. | ||
66 | # `--reload-dir` arguments necessary to prevent the database directory | ||
67 | # from triggering automatic application reload. | ||
68 | # See: https://github.com/encode/uvicorn/issues/984 | ||
69 | (writeShellScriptBin "dev-serve" '' | ||
70 | uvicorn \ | ||
71 | --reload-dir app \ | ||
72 | --reload-dir templates \ | ||
73 | --reload \ | ||
74 | --app-dir app \ | ||
75 | app:main \ | ||
76 | "$@" | ||
77 | '') | ||
57 | ]; | 78 | ]; |
58 | 79 | ||
59 | exportEnvVar = k: v: ''export ${k}="${v}"; echo ${k}=\"${v}\"''; | 80 | exportEnvVar = k: v: ''export ${k}="${v}"; echo ${k}=\"${v}\"''; |
@@ -63,12 +84,14 @@ | |||
63 | PGHOST = "$PWD/development_database"; | 84 | PGHOST = "$PWD/development_database"; |
64 | PGPORT = "5432"; | 85 | PGPORT = "5432"; |
65 | PGDATABASE = "app"; | 86 | PGDATABASE = "app"; |
87 | DATABASE_URL = "postgresql:///${PGDATABASE}?host=${PGHOST}"; | ||
88 | COOKIE_SECRET_KEY = "insecure for development"; | ||
66 | }; | 89 | }; |
67 | 90 | ||
68 | in { | 91 | in { |
69 | 92 | ||
70 | devShell = mkShell rec { | 93 | devShell = mkShell rec { |
71 | buildInputs = develPackagesAndScripts; | 94 | buildInputs = [ pythonWithDependencies ] ++ develPackagesAndScripts; |
72 | 95 | ||
73 | shellHook = '' | 96 | shellHook = '' |
74 | echo -e "\nDEVSHELL ENVIRONMENT VARIABLES:" | 97 | echo -e "\nDEVSHELL ENVIRONMENT VARIABLES:" |