33 lines
798 B
Nix
33 lines
798 B
Nix
{ pkgs, ... }:
|
|
pkgs.mkShell {
|
|
packages = with pkgs; [
|
|
(python3.withPackages (
|
|
python-pkgs: with python-pkgs; [
|
|
pip
|
|
numpy
|
|
pandas
|
|
python-dotenv
|
|
requests
|
|
]
|
|
))
|
|
];
|
|
|
|
shellHook = ''
|
|
if git rev-parse --is-inside-work-tree &> /dev/null; then
|
|
TOP="$(git rev-parse --show-toplevel)"
|
|
if ! grep -q "^\.venv$" "$TOP/.gitignore" "$TOP/.git/info/exclude"; then echo ".venv" >> "$TOP/.git/info/exclude"; fi
|
|
else
|
|
TOP="$(pwd)"
|
|
fi
|
|
|
|
if [ -d "$TOP/.venv" ]; then
|
|
source "$TOP/.venv/bin/activate"
|
|
else
|
|
python -m venv "$TOP/.venv"
|
|
source "$TOP/.venv/bin/activate"
|
|
pip install --upgrade pip
|
|
if [ -f "$TOP/requirements.txt" ]; then pip install -r "$TOP/requirements.txt"; fi
|
|
fi
|
|
'';
|
|
}
|