asciinema-director/shell.nix
2024-06-03 19:28:18 +02:00

61 lines
1.7 KiB
Nix

{ pkgs ? import <nixpkgs> {
config = {
# allowUnfree may be necessary for some packages, but in general you should not need it.
allowUnfree = false;
};
}
}:
with pkgs;
let
# This is the Python version that will be used.
myPython = python311;
pythonWithPkgs = myPython.withPackages (pythonPkgs: with pythonPkgs; [
# This list contains tools for Python development.
# You can also add other tools, like black.
#
# Note that even if you add Python packages here like PyTorch or Tensorflow,
# they will be reinstalled when running `pip -r requirements.txt` because
# python -m venv is used below in the shellHook.
pip
pip-tools
setuptools
wheel
twine
]);
in mkShell {
buildInputs = [
# my python and packages
pythonWithPkgs
poetry
];
shellHook = ''
# Allow the use of wheels.
SOURCE_DATE_EPOCH=$(date +%s)
# Virtual environments are handled by poetry in this project, so the following lines are commented!
## Setup the virtual environment if it doesn't already exist.
#VENV=.venv
#if test ! -d $VENV; then
# python -m venv $VENV
#fi
#source ./$VENV/bin/activate
#export PYTHONPATH=`pwd`/$VENV/${myPython.sitePackages}/:$PYTHONPATH
# Poetry's virtualenv will be created inside the project path and vscode will recognize it for the correct interpreter path
poetry config virtualenvs.in-project true
# Load .env if exists
if test -f .env; then
# Mark variables which are modified or created for export.
set -a
source .env
# or to make it relative to the directory of this shell.nix file
# source ${toString ./.env}
set +a
fi
'';
}