From 3667b563069bb4ce0fbae66a114ff1173cf11ff7 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Fri, 30 May 2025 17:17:06 -0500 Subject: add zscript for nix shell py --- zscripts/nixshell.zsh | 12 ++++++++++++ 1 file changed, 12 insertions(+) mode change 100644 => 100755 zscripts/nixshell.zsh (limited to 'zscripts/nixshell.zsh') diff --git a/zscripts/nixshell.zsh b/zscripts/nixshell.zsh old mode 100644 new mode 100755 index dfc884a..16d0ee3 --- 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} +} -- cgit v1.2.3