Utoljára aktív 1 year ago

nix-shell for python + poetry + psycopg

Revízió e8894135394379a52c8946f7390b4b0a6c612034

shell.nix Eredeti
1# Small nix-shell environment for python 3.10 + poetry
2#
3# See https://nixos.wiki/wiki/Python
4# launch with nix-shell (and not 'nix shell' !)
5#
6# nix-shell --run 'python --version; poetry --version'
7# Python 3.10.13
8# Poetry (version 1.7.1)
9#
10# Also, you can heck https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-mkShell
11#
12let
13 pkgs = import <nixpkgs> { };
14in
15pkgs.mkShell {
16 packages = with pkgs; [
17 (python310.withPackages (python-pkgs: with python-pkgs; [
18 pip
19 # poetry-core
20 numpy
21 psycopg
22 virtualenv
23 ]))
24 postgresql_14
25 stdenv.cc.cc.lib
26 ];
27 shellHook = ''
28 export LD_LIBRARY_PATH="${pkgs.postgresql_14.lib}/lib:${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH"
29 python --version
30 if test ! -d /tmp/.venv; then
31 python -m venv /tmp/.venv
32 fi
33
34 export VIRTUAL_ENV_DISABLE_PROMPT=1
35 source /tmp/.venv/bin/activate
36
37 if test ! -e /tmp/.venv/bin/poetry; then
38 pip install poetry
39 fi
40 '';
41}