summaryrefslogtreecommitdiff
path: root/zscripts/nixshell.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'zscripts/nixshell.zsh')
-rwxr-xr-x[-rw-r--r--]zscripts/nixshell.zsh12
1 files changed, 12 insertions, 0 deletions
diff --git a/zscripts/nixshell.zsh b/zscripts/nixshell.zsh
index dfc884a..16d0ee3 100644..100755
--- a/zscripts/nixshell.zsh
+++ b/zscripts/nixshell.zsh
@@ -10,3 +10,15 @@ if [ -n "$IN_NIX_SHELL" ]; then
# Add nix-shell prefix to prompt in the same style as python venv
PS1PREFIX="(nix-shell) "
fi
+
+
+# Read requirements.txt in to nix-shell
+function nix-shell-py() {
+ if [ ! -f ./requirements.txt ]; then
+ echo "No requirements.txt file was found in the current directory. Exiting..." 1>&2
+ exit 1
+ fi
+
+ requirements="$(sed 's/#.*//;s/^/python3Packages./' ./requirements.txt | tr -s '\n' ' ')"
+ nix-shell -p ${=requirements}
+}