summaryrefslogtreecommitdiff
path: root/zscripts/nixshell.zsh
blob: 16d0ee35af74efd8315f44a2fc04fb9ecc63fcd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env zsh

# Make nix shell run zsh
alias nix-shell="nix-shell --command zsh"

if [ -n "$IN_NIX_SHELL" ]; then
	# Export shell as zsh instead of bash
	export SHELL=zsh

	# 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}
}