-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshell.nix
59 lines (51 loc) · 1.73 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
58
59
{
pkgs ? (import (builtins.fetchGit {
url = "https://github.com/avanov/nix-common.git";
ref = "master";
rev = "be2dc05bf6beac92fc12da9a2adae6994c9f2ee6";
}) {}).pkgs
, pyVersion ? "310"
, isDevEnv ? true
}:
let
python = pkgs."python${pyVersion}";
pythonPkgs = pkgs."python${pyVersion}Packages";
devLibs = if isDevEnv then [ pythonPkgs.twine pythonPkgs.wheel ] else [ pythonPkgs.coveralls ];
in
# Make a new "derivation" that represents our shell
pkgs.mkShellNoCC {
name = "openapi-type";
# The packages in the `buildInputs` list will be added to the PATH in our shell
# Python-specific guide:
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md
nativeBuildInputs = with pkgs; [
# see https://nixos.org/nixos/packages.html
# Python distribution
python
pythonPkgs.virtualenv
ncurses
libxml2
libxslt
libzip
zlib
which
jq
] ++ devLibs;
shellHook = ''
# set SOURCE_DATE_EPOCH so that we can use python wheels
export SOURCE_DATE_EPOCH=$(date +%s)
export VENV_DIR="$PWD/.venv${pyVersion}"
export PATH=$VENV_DIR/bin:$PATH
export PYTHONPATH=""
export LANG=en_US.UTF-8
# https://python-poetry.org/docs/configuration/
export PIP_CACHE_DIR="$PWD/.local/pip-cache${pyVersion}"
# Setup virtualenv
if [ ! -d $VENV_DIR ]; then
virtualenv $VENV_DIR
$VENV_DIR/bin/python -m pip install -e $PWD
$VENV_DIR/bin/python -m pip install -r $PWD/requirements/test.txt
$VENV_DIR/bin/python -m pip install -r $PWD/requirements/extras/*
fi
'';
}