-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathshells.nix
More file actions
103 lines (96 loc) · 2.02 KB
/
Copy pathshells.nix
File metadata and controls
103 lines (96 loc) · 2.02 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
awscli2,
eksctl,
coreutils,
mkShell,
execline,
findutils,
gnugrep,
gnused,
jq,
kubectl,
kubernetes-helm,
openshift,
s6,
python311,
}:
let
python = with python311.pkgs; [
# Project runtime dependencies.
click
kubernetes
boto3
jinja2
typing-extensions
inotify
# TODO: add lint and test dependencies.
# Standard python stuff.
pep517
pip
pytest
pytestCheckHook
pytest-mock
setuptools
wheel
];
in
let
devshell = mkShell {
packages = [
awscli2
coreutils
eksctl
execline
findutils
gnugrep
gnused
jq
kubectl
kubernetes-helm
openshift
s6
python
];
shellHook = ''
# Heurisitic to cd to the root of the project.
#
#
src="$(dirname "$(dirname "$out")")"
cd "$src"
venv="$src"/venv
if test -w default.nix; then
# Create a virtual environment and install the project
# in editable mode.
python -mvenv "$venv"
# shellcheck disable=SC1091
source "$venv"/bin/activate
cd "$venv"/lib64/python3.11/site-packages
IFS=':' read -ra array <<< "$PYTHONPATH"
for element in "''${array[@]}"; do
find $element -maxdepth 1 -mindepth 1 -name '*.dist-info' | \
while read -r i; do
fname="$(cut -d'-' -f1 <<< $(basename "$i"))".pth
if ! diff -q "$fname" - <<< "$element" > /dev/null 2>&1; then
echo $element > "$fname"
fi
done
done
unset PYTHONPATH
cd "$src"
"$venv"/bin/pip install -e '.[dev]'
else
# Assume existing virtual environment.
# TODO: consider installing into different venv for each user.
unset PYTHONPATH
# shellcheck disable=SC1091
source "$venv"/bin/activate
fi
# Debug output to confirm where local tools are coming from.
which hostfactory
export PS1="+ $PS1"
'';
};
in
{
inherit devshell;
}