diff options
author | Tim Keller <tjk@tjkeller.xyz> | 2025-05-30 17:17:06 -0500 |
---|---|---|
committer | Tim Keller <tjk@tjkeller.xyz> | 2025-05-30 17:17:06 -0500 |
commit | 3667b563069bb4ce0fbae66a114ff1173cf11ff7 (patch) | |
tree | 6be77b851c43df390d8b0b79b639b29cf7c5e8b5 /zscripts/nixshell.zsh | |
parent | 786b738adb3e491c79483fbf19e3216da801fbe2 (diff) | |
download | zsh-3667b563069bb4ce0fbae66a114ff1173cf11ff7.tar.xz zsh-3667b563069bb4ce0fbae66a114ff1173cf11ff7.zip |
add zscript for nix shell py
Diffstat (limited to 'zscripts/nixshell.zsh')
-rwxr-xr-x[-rw-r--r--] | zscripts/nixshell.zsh | 12 |
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} +} |