Ostatnio aktywny 1 year ago

nix-shell for python + poetry + psycopg

mycroft's Avatar Patrick Marie zrewidował ten Gist 1 year ago. Przejdź do rewizji

1 file changed, 11 insertions

shell.nix

@@ -23,6 +23,11 @@ let
23 23 postgresql_14
24 24 pythonEnv
25 25 stdenv.cc.cc.lib
26 + uwsgi
27 +
28 + nodejs
29 + yarn
30 + nodePackages."@angular/cli"
26 31 ];
27 32 in
28 33 pkgs.mkShell {
@@ -32,9 +37,15 @@ pkgs.mkShell {
32 37 python --version
33 38 poetry --version
34 39
40 +
35 41 export VIRTUAL_ENV_DISABLE_PROMPT=1
36 42 export POETRY_VENV=/tmp/.venv-py310-poetry
37 43
44 + # Remove nodePackages."@angular/cli" from packages to avoid installing it globally
45 + # npm set prefix ~/.npm-global-nix
46 + # export PATH=~/.npm-global-nix/bin:$PATH
47 + # which ng >/dev/null 2>/dev/null || (echo "Installing @angular/cli" && npm install -g @angular/cli)
48 +
38 49 if test ! -e $POETRY_VENV
39 50 then
40 51 python -m venv $POETRY_VENV

mycroft's Avatar Patrick Marie zrewidował ten Gist 1 year ago. Przejdź do rewizji

1 file changed, 22 insertions, 16 deletions

shell.nix

@@ -11,31 +11,37 @@
11 11 #
12 12 let
13 13 pkgs = import <nixpkgs> { };
14 - in
15 - pkgs.mkShell {
14 + pythonEnv = pkgs.python310.withPackages (pythonPackages: with pythonPackages; [
15 + jinja2
16 + pyyaml
17 + pip
18 + numpy
19 + psycopg
20 + virtualenv
21 + ]);
16 22 packages = with pkgs; [
17 - (python310.withPackages (python-pkgs: with python-pkgs; [
18 - pip
19 - # poetry-core
20 - numpy
21 - psycopg
22 - virtualenv
23 - ]))
24 23 postgresql_14
24 + pythonEnv
25 25 stdenv.cc.cc.lib
26 26 ];
27 + in
28 + pkgs.mkShell {
29 + packages = packages;
27 30 shellHook = ''
28 31 export LD_LIBRARY_PATH="${pkgs.postgresql_14.lib}/lib:${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH"
29 32 python --version
30 - if test ! -d /tmp/.venv; then
31 - python -m venv /tmp/.venv
32 - fi
33 + poetry --version
33 34
34 35 export VIRTUAL_ENV_DISABLE_PROMPT=1
35 - source /tmp/.venv/bin/activate
36 + export POETRY_VENV=/tmp/.venv-py310-poetry
36 37
37 - if test ! -e /tmp/.venv/bin/poetry; then
38 - pip install poetry
38 + if test ! -e $POETRY_VENV
39 + then
40 + python -m venv $POETRY_VENV
41 + $POETRY_VENV/bin/pip install poetry
39 42 fi
43 +
44 + alias ll='ls -ltr'
45 + alias poetry=$POETRY_VENV/bin/poetry
40 46 '';
41 - }
47 + }

mycroft's Avatar mycroft zrewidował ten Gist 1 year ago. Przejdź do rewizji

1 file changed, 16 insertions, 3 deletions

shell.nix

@@ -16,13 +16,26 @@ pkgs.mkShell {
16 16 packages = with pkgs; [
17 17 (python310.withPackages (python-pkgs: with python-pkgs; [
18 18 pip
19 + # poetry-core
20 + numpy
19 21 psycopg
20 22 virtualenv
21 23 ]))
22 - poetry
23 24 postgresql_14
25 + stdenv.cc.cc.lib
24 26 ];
25 27 shellHook = ''
26 - export LD_LIBRARY_PATH="${pkgs.postgresql_14.lib}/lib:$LD_LIBRARY_PATH"
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
27 40 '';
28 - }
41 + }

mycroft's Avatar Patrick Marie zrewidował ten Gist 1 year ago. Przejdź do rewizji

1 file changed, 7 insertions, 1 deletion

shell.nix

@@ -7,6 +7,8 @@
7 7 # Python 3.10.13
8 8 # Poetry (version 1.7.1)
9 9 #
10 + # Also, you can heck https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-mkShell
11 + #
10 12 let
11 13 pkgs = import <nixpkgs> { };
12 14 in
@@ -18,5 +20,9 @@ pkgs.mkShell {
18 20 virtualenv
19 21 ]))
20 22 poetry
23 + postgresql_14
21 24 ];
22 - }
25 + shellHook = ''
26 + export LD_LIBRARY_PATH="${pkgs.postgresql_14.lib}/lib:$LD_LIBRARY_PATH"
27 + '';
28 + }

mycroft's Avatar mycroft zrewidował ten Gist 1 year ago. Przejdź do rewizji

Brak zmian

mycroft's Avatar mycroft zrewidował ten Gist 1 year ago. Przejdź do rewizji

1 file changed, 22 insertions

shell.nix(stworzono plik)

@@ -0,0 +1,22 @@
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 + let
11 + pkgs = import <nixpkgs> { };
12 + in
13 + pkgs.mkShell {
14 + packages = with pkgs; [
15 + (python310.withPackages (python-pkgs: with python-pkgs; [
16 + pip
17 + psycopg
18 + virtualenv
19 + ]))
20 + poetry
21 + ];
22 + }
Nowsze Starsze