-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython-dev-shell.nix
36 lines (30 loc) · 1.09 KB
/
python-dev-shell.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# python-dev-shell.nix
# python development shell used with virtual environments
# source/inspiration: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md#how-to-consume-python-modules-using-pip-in-a-virtual-environment-like-i-am-used-to-on-other-operating-systems-how-to-consume-python-modules-using-pip-in-a-virtual-environment-like-i-am-used-to-on-other-operating-systems
{ pkgs ? import <nixpkgs> { } }:
let
lib-path = with pkgs; lib.makeLibraryPath [
stdenv.cc.cc
zlib
];
in
pkgs.mkShell {
# virtual environment folder sourced on shell start ( or created if missing )
venvDir = "./.venv";
# run time deps
buildInputs = with pkgs; [
python3Packages.python
# creates and sources virtual env on shell start
python3Packages.venvShellHook
];
# command ran after creating venv
postVenvCreation = ''
unset SOURCE_DATE_EPOCH
pip install --upgrade pip
pip install -r ./requirements.txt
'';
# command ran after sourcing virtual env
postShellHook = ''
export LD_LIBRARY_PATH=''${LD_LIBRARY_PATH}:${lib-path}
'';
}