forked from web2py/py4web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
57 lines (48 loc) · 1.29 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
let
nixpkgs-src = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/tarball/nixos-22.11";
};
pkgs = import nixpkgs-src {
config = {
allowUnfree = true;
};
};
# This is the Python version that will be used.
myPython = pkgs.python311;
pythonWithPkgs = myPython.withPackages (pythonPkgs: with pythonPkgs; [
pip
setuptools
wheel
]);
lib-path = with pkgs; lib.makeLibraryPath [
libffi
openssl
];
shell = pkgs.mkShell {
buildInputs = [
# my python and packages
pythonWithPkgs
pkgs.memcached
pkgs.redis
# other packages needed for compiling python libs
pkgs.readline
pkgs.libffi
pkgs.openssl
];
shellHook = ''
# Allow the use of wheels.
SOURCE_DATE_EPOCH=$(date +%s)
VENV_PATH=/home/$USER/.nix-venvs$(pwd)/venv${myPython.version}
# Augment the dynamic linker path
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lib-path}"
# Setup the virtual environment if it doesn't already exist.
if test ! -d $VENV_PATH; then
python -m venv $VENV_PATH
fi
$VENV_PATH/bin/pip install -U -r requirements.txt
source $VENV_PATH/bin/activate
export PYTHONPATH=$VENV_PATH/${myPython.sitePackages}/:$PYTHONPATH
'';
};
in
shell