-
Notifications
You must be signed in to change notification settings - Fork 2
/
nix-debug-shell
executable file
·46 lines (41 loc) · 1.12 KB
/
nix-debug-shell
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
#!/usr/bin/env bash
set -e
dir=$(dirname $(readlink -f "$0"))
declare -a args
for arg in "$@"; do
if [ -n "$nextArgIsPkg" ]; then
pkg="$arg"
nextArgIsPkg=
continue
fi
case "$arg" in
-A)
if [ -n "$pkg" ]; then
echo "$0: error: -A argument given twice."
exit 1
fi
nextArgIsPkg=1
;;
--no-ccache)
noCCache=1
;;
*)
args+=("$arg")
esac
done
if [ -z "$pkg" ]; then
echo "$0: -A argument must be given."
exit 1
fi
buildDir="/tmp/nds-build-$pkg"
if [ -d "$buildDir" ]; then
# TODO: maybe handle this instead of always wiping
# echo "Reusing existing build directory '$buildDir'. Run 'nd-reset' to wipe it and start the build from scratch."
echo "Wiping already existing build directory '$buildDir'."
rm -rf "$buildDir"
else
echo "Creating new build directory '$buildDir'."
fi
mkdir -p "$buildDir"
#echo "noCCache: $noCCache, pkg: $pkg, args: ${args[@]}"
nix-shell -A "$pkg" --command "cd $buildDir; source $dir/env.sh; return" "${args[@]}"